@api-client/ui 0.5.39 → 0.5.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/elements/contextual-menu/{internals/ContextualMenu.d.ts → ContextualMenu.d.ts} +11 -6
- package/build/src/elements/contextual-menu/ContextualMenu.d.ts.map +1 -0
- package/build/src/elements/contextual-menu/{internals/ContextualMenu.js → ContextualMenu.js} +25 -3
- package/build/src/elements/contextual-menu/ContextualMenu.js.map +1 -0
- package/build/src/elements/contextual-menu/internals/types.d.ts +16 -7
- package/build/src/elements/contextual-menu/internals/types.d.ts.map +1 -1
- package/build/src/elements/contextual-menu/internals/types.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/elements/contextual-menu/{internals/ContextualMenu.ts → ContextualMenu.ts} +31 -7
- package/src/elements/contextual-menu/internals/types.ts +17 -7
- package/.aiexclude +0 -3
- package/.cursor/rules/html-and-css-best-practices.mdc +0 -63
- package/.cursor/rules/lit-best-practices.mdc +0 -89
- package/.editorconfig +0 -29
- package/.github/CONTRIBUTING.md +0 -24
- package/.github/instructions/html-and-css-best-practices.instructions.md +0 -70
- package/.github/instructions/lit-best-practices.instructions.md +0 -90
- package/.github/release.yml +0 -14
- package/.github/stale.yml +0 -23
- package/.github/workflows/auto-release.yml +0 -182
- package/.github/workflows/release.yml +0 -82
- package/.prettierrc.js +0 -14
- package/.vscode/settings.json +0 -18
- package/RELEASE.md +0 -163
- package/RELEASE_SETUP.md +0 -235
- package/build/src/demo/DemoPage.d.ts +0 -81
- package/build/src/demo/DemoPage.d.ts.map +0 -1
- package/build/src/demo/DemoPage.js +0 -175
- package/build/src/demo/DemoPage.js.map +0 -1
- package/build/src/demo/DemoStyles.d.ts +0 -3
- package/build/src/demo/DemoStyles.d.ts.map +0 -1
- package/build/src/demo/DemoStyles.js +0 -60
- package/build/src/demo/DemoStyles.js.map +0 -1
- package/build/src/elements/contextual-menu/internals/ContextualMenu.d.ts.map +0 -1
- package/build/src/elements/contextual-menu/internals/ContextualMenu.js.map +0 -1
- package/build/test/elements/navigation/Navigation.test.d.ts +0 -3
- package/build/test/elements/navigation/Navigation.test.d.ts.map +0 -1
- package/build/test/elements/navigation/Navigation.test.js +0 -113
- package/build/test/elements/navigation/Navigation.test.js.map +0 -1
- package/commitlint.config.cjs +0 -2
- package/demo/elements/authorization/AuthPlugin.js +0 -57
- package/demo/elements/authorization/AuthProxy.js +0 -215
- package/demo/elements/authorization/api-key.html +0 -27
- package/demo/elements/authorization/api-key.ts +0 -44
- package/demo/elements/authorization/basic.html +0 -27
- package/demo/elements/authorization/basic.ts +0 -43
- package/demo/elements/authorization/bearer.html +0 -27
- package/demo/elements/authorization/bearer.ts +0 -43
- package/demo/elements/authorization/env.js +0 -8
- package/demo/elements/authorization/index.html +0 -44
- package/demo/elements/authorization/ntlm.html +0 -27
- package/demo/elements/authorization/ntlm.ts +0 -43
- package/demo/elements/authorization/oauth-authorize.html +0 -75
- package/demo/elements/authorization/oauth-authorize.ts +0 -40
- package/demo/elements/authorization/oauth-error.html +0 -18
- package/demo/elements/authorization/oauth-error.ts +0 -10
- package/demo/elements/authorization/oauth-popup.html +0 -36
- package/demo/elements/authorization/oauth2.html +0 -27
- package/demo/elements/authorization/oauth2.ts +0 -100
- package/demo/elements/authorization/oidc.html +0 -27
- package/demo/elements/authorization/oidc.ts +0 -139
- package/demo/elements/authorization/private.crt +0 -31
- package/demo/elements/authorization/private.csr +0 -28
- package/demo/elements/authorization/private.key +0 -51
- package/demo/elements/authorization/private.pem +0 -31
- package/demo/elements/authorization/redirect.html +0 -20
- package/demo/elements/authorization/ssl-commands.sh +0 -30
- package/demo/elements/authorization/ssl.conf +0 -24
- package/demo/elements/autocomplete/index.html +0 -64
- package/demo/elements/autocomplete/index.ts +0 -171
- package/demo/elements/code-editor/CodeEditorDemo.ts +0 -173
- package/demo/elements/code-editor/index.html +0 -19
- package/demo/elements/context-menu/DemoIcons.ts +0 -21
- package/demo/elements/context-menu/basic.html +0 -25
- package/demo/elements/context-menu/basic.ts +0 -119
- package/demo/elements/context-menu/custom-data.html +0 -25
- package/demo/elements/context-menu/custom-data.ts +0 -62
- package/demo/elements/context-menu/demo.css +0 -28
- package/demo/elements/context-menu/enabled-state.html +0 -25
- package/demo/elements/context-menu/enabled-state.ts +0 -73
- package/demo/elements/context-menu/icons.html +0 -25
- package/demo/elements/context-menu/icons.ts +0 -64
- package/demo/elements/context-menu/index.html +0 -43
- package/demo/elements/context-menu/nested.html +0 -25
- package/demo/elements/context-menu/nestedt.ts +0 -152
- package/demo/elements/context-menu/no-execute.html +0 -25
- package/demo/elements/context-menu/no-execute.ts +0 -134
- package/demo/elements/context-menu/radio-menu.html +0 -25
- package/demo/elements/context-menu/radio-menu.ts +0 -83
- package/demo/elements/context-menu/separators.html +0 -25
- package/demo/elements/context-menu/separators.ts +0 -172
- package/demo/elements/currency/index.html +0 -91
- package/demo/elements/currency/index.ts +0 -352
- package/demo/elements/environment/environment-editor.html +0 -20
- package/demo/elements/environment/environment-editor.ts +0 -49
- package/demo/elements/environment/index.html +0 -33
- package/demo/elements/environment/server-editor.html +0 -20
- package/demo/elements/environment/server-editor.ts +0 -67
- package/demo/elements/environment/variables-editor.html +0 -20
- package/demo/elements/environment/variables-editor.ts +0 -94
- package/demo/elements/har/har-viewer.html +0 -20
- package/demo/elements/har/har-viewer.ts +0 -76
- package/demo/elements/har/har1.har +0 -3044
- package/demo/elements/har/har2.json +0 -439
- package/demo/elements/har/index.html +0 -26
- package/demo/elements/highlight/example.md +0 -27
- package/demo/elements/highlight/index.html +0 -31
- package/demo/elements/highlight/marked-highlight.html +0 -132
- package/demo/elements/highlight/marked-highlight.ts +0 -22
- package/demo/elements/highlight/prism-highlight.html +0 -62
- package/demo/elements/highlight/prism-highlight.ts +0 -17
- package/demo/elements/http/body-editor.html +0 -17
- package/demo/elements/http/body-editor.ts +0 -115
- package/demo/elements/http/headers.html +0 -17
- package/demo/elements/http/headers.ts +0 -59
- package/demo/elements/http/http-assertions.html +0 -20
- package/demo/elements/http/http-assertions.ts +0 -89
- package/demo/elements/http/http-flows.html +0 -23
- package/demo/elements/http/http-flows.ts +0 -89
- package/demo/elements/http/index.html +0 -45
- package/demo/elements/http/request-editor.html +0 -26
- package/demo/elements/http/request-editor.ts +0 -197
- package/demo/elements/http/request-log.html +0 -16
- package/demo/elements/http/request-log.ts +0 -136
- package/demo/elements/http/url-editing.html +0 -17
- package/demo/elements/http/url-editing.ts +0 -112
- package/demo/elements/icons/index.html +0 -81
- package/demo/elements/icons/index.ts +0 -52
- package/demo/elements/index.html +0 -72
- package/demo/elements/mention-textarea/index.html +0 -19
- package/demo/elements/mention-textarea/index.ts +0 -205
- package/demo/elements/navigation/navigation-item.html +0 -49
- package/demo/elements/navigation/navigation-item.ts +0 -131
- package/demo/elements/navigation/navigation.html +0 -20
- package/demo/elements/navigation/navigation.ts +0 -45
- package/demo/elements/project/index.html +0 -29
- package/demo/elements/project/project-run-report.html +0 -20
- package/demo/elements/project/project-run-report.ts +0 -132
- package/demo/elements/project/request-editor.html +0 -23
- package/demo/elements/project/request-editor.ts +0 -232
- package/demo/elements/user/user-avatar.html +0 -17
- package/demo/elements/user/user-avatar.ts +0 -60
- package/demo/env.js +0 -4
- package/demo/index.html +0 -34
- package/demo/layout/index.html +0 -94
- package/demo/layout/index.ts +0 -190
- package/demo/md/DemoStyles.ts +0 -61
- package/demo/md/UiDemoPage.ts +0 -6
- package/demo/md/buttons/button.html +0 -121
- package/demo/md/buttons/button.ts +0 -246
- package/demo/md/buttons/group.html +0 -36
- package/demo/md/buttons/group.ts +0 -171
- package/demo/md/checkbox/index.html +0 -39
- package/demo/md/checkbox/index.ts +0 -220
- package/demo/md/chip/chip.html +0 -70
- package/demo/md/chip/chip.ts +0 -219
- package/demo/md/chip/pawel6c9a.jpg +0 -0
- package/demo/md/collapse/CustomDetail.ts +0 -89
- package/demo/md/collapse/collapse.html +0 -21
- package/demo/md/collapse/collapse.ts +0 -78
- package/demo/md/date-picker/date-picker.ts +0 -336
- package/demo/md/date-picker/index.html +0 -171
- package/demo/md/dialog/confirm-dialog.html +0 -49
- package/demo/md/dialog/confirm-dialog.ts +0 -121
- package/demo/md/dialog/dialog.html +0 -25
- package/demo/md/dialog/dialog.ts +0 -468
- package/demo/md/dropdown-list/index.html +0 -31
- package/demo/md/dropdown-list/index.ts +0 -158
- package/demo/md/icon-button/index.html +0 -122
- package/demo/md/icon-button/index.ts +0 -132
- package/demo/md/index.html +0 -73
- package/demo/md/inputs/input.html +0 -73
- package/demo/md/inputs/input.ts +0 -278
- package/demo/md/inputs/radio.html +0 -39
- package/demo/md/inputs/radio.ts +0 -156
- package/demo/md/inputs/switch.html +0 -45
- package/demo/md/inputs/switch.ts +0 -144
- package/demo/md/list/list.html +0 -65
- package/demo/md/list/list.ts +0 -204
- package/demo/md/listbox/listbox.html +0 -31
- package/demo/md/listbox/listbox.ts +0 -27
- package/demo/md/menu/index.html +0 -19
- package/demo/md/menu/index.ts +0 -514
- package/demo/md/notification/snack.html +0 -21
- package/demo/md/notification/snack.ts +0 -70
- package/demo/md/progress/progress.html +0 -46
- package/demo/md/progress/progress.ts +0 -161
- package/demo/md/segmented-button/index.html +0 -21
- package/demo/md/segmented-button/index.ts +0 -55
- package/demo/md/select/index.html +0 -16
- package/demo/md/select/index.ts +0 -217
- package/demo/md/tabs/tabs.html +0 -40
- package/demo/md/tabs/tabs.ts +0 -214
- package/demo/oauth-popup.html +0 -36
- package/demo/page.css +0 -8
- package/demo/resources/calendar-month.png +0 -0
- package/demo/resources/favorite.png +0 -0
- package/demo/resources/fingerprint.png +0 -0
- package/demo/resources/home-work.png +0 -0
- package/demo/resources/mood.png +0 -0
- package/demo/resources/print.png +0 -0
- package/demo/resources/stars.png +0 -0
- package/demo/resources/theaters.png +0 -0
- package/demo/tsconfig.json +0 -4
- package/eslint.config.js +0 -97
- package/scripts/copy-assets.js +0 -21
- package/scripts/release.js +0 -66
- package/src/demo/DemoPage.ts +0 -169
- package/src/demo/DemoStyles.ts +0 -60
- package/test/README.md +0 -375
- package/test/contextual-menu/ContextMenu.test.ts +0 -760
- package/test/contextual-menu/ContextMenuElement.test.ts +0 -569
- package/test/core/activity.spec.ts +0 -413
- package/test/core/activity_manager.spec.ts +0 -544
- package/test/core/application.spec.ts +0 -218
- package/test/core/fragment.spec.ts +0 -565
- package/test/core/fragment_manager.spec.ts +0 -404
- package/test/core/live_data.spec.ts +0 -558
- package/test/core/renderer.spec.ts +0 -113
- package/test/dom-assertions.test.ts +0 -182
- package/test/elements/MonacoSetup.ts +0 -65
- package/test/elements/authorization/basic-method.test.ts +0 -177
- package/test/elements/authorization/bearer-method.test.ts +0 -143
- package/test/elements/authorization/ntlm-method.test.ts +0 -219
- package/test/elements/authorization/oauth2-client-credentials-method.test.ts +0 -334
- package/test/elements/authorization/oauth2-code-method.test.ts +0 -320
- package/test/elements/authorization/oauth2-custom-grant-method.test.ts +0 -255
- package/test/elements/authorization/oauth2-device-code-method.test.ts +0 -371
- package/test/elements/authorization/oauth2-implicit-method.test.ts +0 -407
- package/test/elements/authorization/oauth2-jwt-method.test.ts +0 -217
- package/test/elements/authorization/oauth2-password-method.test.ts +0 -275
- package/test/elements/authorization/openid-method.test.ts +0 -591
- package/test/elements/autocomplete/autocomplete-input.spec.ts +0 -646
- package/test/elements/code-editor/code-editor.accessibility.test.ts +0 -298
- package/test/elements/code-editor/code-editor.test.ts +0 -574
- package/test/elements/currency/CurrencyPicker.accessibility.test.ts +0 -328
- package/test/elements/currency/CurrencyPicker.core.test.ts +0 -318
- package/test/elements/currency/CurrencyPicker.integration.test.ts +0 -482
- package/test/elements/currency/CurrencyPicker.test.ts +0 -486
- package/test/elements/data-table/DataTable.browser.test.ts +0 -649
- package/test/elements/har/HarUtils.test.ts +0 -45
- package/test/elements/har/HarViewerElement.test.ts +0 -687
- package/test/elements/har/test-data/har1.har +0 -3044
- package/test/elements/highlight/MarkedHighlightElement.test.ts +0 -452
- package/test/elements/highlight/PrismHighlightElement.test.ts +0 -79
- package/test/elements/highlight/PrismHighlighter.test.ts +0 -94
- package/test/elements/highlight/remoteSanitization.md +0 -1
- package/test/elements/highlight/test.md +0 -3
- package/test/elements/highlight/test1.md +0 -3
- package/test/elements/highlight/test2.md +0 -1
- package/test/elements/http/BodyFormdataEditorElement.test.ts +0 -482
- package/test/elements/http/BodyMultipartEditorElement.test.ts +0 -658
- package/test/elements/http/BodyRawEditorElement.test.ts +0 -90
- package/test/elements/http/CertificateAdd.test.ts +0 -457
- package/test/elements/http/HttpAssertions.test.ts +0 -994
- package/test/elements/http/HttpFlows.test.ts +0 -502
- package/test/elements/http/UrlEncodeUtils.test.ts +0 -202
- package/test/elements/layout/SplitItem.test.ts +0 -440
- package/test/elements/layout/SplitLayoutManager.test.ts +0 -1501
- package/test/elements/layout/SplitPanel.test.ts +0 -1109
- package/test/elements/mention-textarea/MentionTextArea.basic.test.ts +0 -114
- package/test/elements/mention-textarea/MentionTextArea.test.ts +0 -613
- package/test/elements/navigation/Navigation.test.ts +0 -120
- package/test/env.ts +0 -15
- package/test/events/EventTypes.test.ts +0 -363
- package/test/events/EventsTestHelpers.ts +0 -16
- package/test/helpers/TestUtils.ts +0 -243
- package/test/helpers/UiMock.ts +0 -185
- package/test/lib/Dom.test.ts +0 -231
- package/test/md/button/UiButton.test.ts +0 -347
- package/test/md/button/UiIconButton.test.ts +0 -155
- package/test/md/chip/UiChip.test.ts +0 -219
- package/test/md/collapse/UiCollapse.test.ts +0 -250
- package/test/md/collapse/flex-layout.test.ts +0 -105
- package/test/md/date-time/DateTime.test.ts +0 -348
- package/test/md/dialog/UiConfirmDialog.test.ts +0 -131
- package/test/md/dialog/UiDialog.test.ts +0 -759
- package/test/md/menu/Menu.test.ts +0 -855
- package/test/md/menu/MenuIntegration.test.ts +0 -426
- package/test/md/menu/MenuItem.test.ts +0 -652
- package/test/md/menu/SubMenu.test.ts +0 -410
- package/test/md/progress/UiCircularProgressElement.test.ts +0 -481
- package/test/md/progress/UiProgressElement.test.ts +0 -117
- package/test/md/progress/UiRangeElement.test.ts +0 -156
- package/test/md/select/Select.test.ts +0 -925
- package/test/plugins/takeScreenshotPlugin.js +0 -35
- package/test/setup.test.ts +0 -217
- package/test/setup.ts +0 -117
- package/test/tsconfig.json +0 -7
- package/web-dev-server.config.js +0 -21
- package/web-test-runner.config.js +0 -90
package/src/demo/DemoStyles.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { css } from 'lit'
|
|
2
|
-
|
|
3
|
-
export default css`
|
|
4
|
-
:root {
|
|
5
|
-
--dot-size: 1px;
|
|
6
|
-
--dot-space: 7px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
html,
|
|
10
|
-
body {
|
|
11
|
-
margin: 0;
|
|
12
|
-
font-family: 'Roboto', 'Noto', sans-serif;
|
|
13
|
-
background-color: var(--md-sys-color-surface);
|
|
14
|
-
color: var(--md-sys-color-on-surface);
|
|
15
|
-
background-image: radial-gradient(var(--md-sys-color-inverse-on-surface) 1px, transparent 0);
|
|
16
|
-
background-size: var(--dot-space) var(--dot-space);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.demo {
|
|
20
|
-
margin: 0;
|
|
21
|
-
padding: 0;
|
|
22
|
-
min-height: 100vh;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
header {
|
|
26
|
-
background-color: var(--md-sys-color-surface-variant);
|
|
27
|
-
color: var(--md-sys-color-on-surface-variant);
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: center;
|
|
30
|
-
|
|
31
|
-
max-width: 1440px;
|
|
32
|
-
margin: 20px 40px;
|
|
33
|
-
padding: 0 24px;
|
|
34
|
-
border-radius: 40px;
|
|
35
|
-
|
|
36
|
-
font-family: var(--md-sys-typescale-title-large-font);
|
|
37
|
-
font-weight: var(--md-sys-typescale-title-large-weight);
|
|
38
|
-
font-size: var(--md-sys-typescale-title-large-size);
|
|
39
|
-
letter-spacing: var(--md-sys-typescale-title-large-tracking);
|
|
40
|
-
line-height: var(--md-sys-typescale-title-large-height);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
#app {
|
|
44
|
-
height: 100%;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
main {
|
|
48
|
-
/* max-width: 900px;
|
|
49
|
-
margin: 40px auto; */
|
|
50
|
-
border-radius: 40px;
|
|
51
|
-
padding: 24px;
|
|
52
|
-
|
|
53
|
-
/* background-color: var(--md-sys-color-primary-container);
|
|
54
|
-
color: var(--md-sys-color-on-primary-container); */
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.demo-section {
|
|
58
|
-
margin: 60px 0;
|
|
59
|
-
}
|
|
60
|
-
`
|
package/test/README.md
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
# Test Setup Guide
|
|
2
|
-
|
|
3
|
-
This document explains how to use the test infrastructure for the UI component library.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
The test setup provides:
|
|
8
|
-
|
|
9
|
-
- **Global test utilities** for common testing patterns
|
|
10
|
-
- **Custom matchers** for better assertions
|
|
11
|
-
- **UI interaction helpers** for simulating user actions
|
|
12
|
-
- **Async helpers** for handling asynchronous operations
|
|
13
|
-
- **Performance testing utilities**
|
|
14
|
-
|
|
15
|
-
## Test Configuration
|
|
16
|
-
|
|
17
|
-
### Web Test Runner
|
|
18
|
-
|
|
19
|
-
Tests run using [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) with:
|
|
20
|
-
|
|
21
|
-
- **Playwright** for browser automation
|
|
22
|
-
- **OAuth2 mock server** for authentication testing
|
|
23
|
-
- **Coverage reporting** with lcov format
|
|
24
|
-
- **Custom test HTML** with Material Design 3 styles
|
|
25
|
-
|
|
26
|
-
### File Structure
|
|
27
|
-
|
|
28
|
-
```plain
|
|
29
|
-
test/
|
|
30
|
-
├── setup.ts # Global test setup
|
|
31
|
-
├── setup.test.ts # Example test demonstrating setup
|
|
32
|
-
├── env.ts # Environment configuration
|
|
33
|
-
├── helpers/
|
|
34
|
-
│ ├── UiMock.ts # UI interaction utilities
|
|
35
|
-
│ └── TestUtils.ts # Extended test utilities
|
|
36
|
-
└── [component-tests]/ # Component-specific tests
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Running Tests
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# Run all tests
|
|
43
|
-
npm run test
|
|
44
|
-
|
|
45
|
-
# Run tests in watch mode
|
|
46
|
-
npm run test:watch
|
|
47
|
-
|
|
48
|
-
# Run tests with coverage
|
|
49
|
-
npm run test:coverage
|
|
50
|
-
|
|
51
|
-
# Run tests for a single file
|
|
52
|
-
npm test -- --files=".tmp/test/**/CurrencyPicker.integration.test.js"
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Global Test Utilities
|
|
56
|
-
|
|
57
|
-
The setup provides global utilities accessible via `window.testUtils`:
|
|
58
|
-
|
|
59
|
-
### waitForElement(selector, timeout?)
|
|
60
|
-
|
|
61
|
-
Wait for an element to appear in the DOM:
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
const element = await window.testUtils.waitForElement('#my-element', 5000)
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### waitForCondition(condition, timeout?)
|
|
68
|
-
|
|
69
|
-
Wait for a condition to become true:
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
await window.testUtils.waitForCondition(() => someVariable === true, 5000)
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Custom Matchers
|
|
76
|
-
|
|
77
|
-
Enhanced assertion helpers in `customMatchers`:
|
|
78
|
-
|
|
79
|
-
### toHaveClasses(element, ...classes)
|
|
80
|
-
|
|
81
|
-
Check if element has specific CSS classes:
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
const result = customMatchers.toHaveClasses(element, 'active', 'highlighted')
|
|
85
|
-
assert.isTrue(result.pass)
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### toBeVisible(element)
|
|
89
|
-
|
|
90
|
-
Check if element is visible (not hidden by CSS):
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
const result = customMatchers.toBeVisible(element)
|
|
94
|
-
assert.isTrue(result.pass)
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### toHaveAttribute(element, attribute, value?)
|
|
98
|
-
|
|
99
|
-
Check if element has specific attribute:
|
|
100
|
-
|
|
101
|
-
```typescript
|
|
102
|
-
const result = customMatchers.toHaveAttribute(element, 'data-test', 'value')
|
|
103
|
-
assert.isTrue(result.pass)
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## UI Interaction (UiMock)
|
|
107
|
-
|
|
108
|
-
Simulate user interactions:
|
|
109
|
-
|
|
110
|
-
### Keyboard Events
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
// Single key events
|
|
114
|
-
UiMock.keyDown(element, 'Enter')
|
|
115
|
-
UiMock.keyUp(element, 'Escape')
|
|
116
|
-
|
|
117
|
-
// Full key press (down + up)
|
|
118
|
-
await UiMock.keyPress(element, 'Space', { ctrlKey: true })
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### Mouse Events
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
// Get element center
|
|
125
|
-
const center = UiMock.getMiddleOfElement(element)
|
|
126
|
-
|
|
127
|
-
// Move mouse between points
|
|
128
|
-
await UiMock.moveMouse(fromPoint, toPoint, steps)
|
|
129
|
-
|
|
130
|
-
// Drag and drop
|
|
131
|
-
await UiMock.dragAndDrop(sourceElement, targetElement)
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### File Drag Events
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
const file = new File(['content'], 'test.txt', { type: 'text/plain' })
|
|
138
|
-
const dragEvent = UiMock.getFileDragEvent('drop', { file })
|
|
139
|
-
element.dispatchEvent(dragEvent)
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Async Helpers
|
|
143
|
-
|
|
144
|
-
Handle asynchronous operations:
|
|
145
|
-
|
|
146
|
-
### waitForAll(conditions, timeout?)
|
|
147
|
-
|
|
148
|
-
Wait for multiple conditions:
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
await asyncHelpers.waitForAll([
|
|
152
|
-
() => condition1,
|
|
153
|
-
() => condition2,
|
|
154
|
-
], 5000)
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### waitForAny(conditions, timeout?)
|
|
158
|
-
|
|
159
|
-
Wait for any condition to be true:
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
const index = await asyncHelpers.waitForAny([
|
|
163
|
-
() => condition1,
|
|
164
|
-
() => condition2,
|
|
165
|
-
])
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### retry(operation, maxAttempts?, baseDelay?)
|
|
169
|
-
|
|
170
|
-
Retry failed operations with exponential backoff:
|
|
171
|
-
|
|
172
|
-
```typescript
|
|
173
|
-
const result = await asyncHelpers.retry(async () => {
|
|
174
|
-
const response = await fetch('/api/data')
|
|
175
|
-
if (!response.ok) throw new Error('Failed')
|
|
176
|
-
return response.json()
|
|
177
|
-
}, 3, 100)
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
## Test Factories
|
|
181
|
-
|
|
182
|
-
Create reusable test data and element factories:
|
|
183
|
-
|
|
184
|
-
### Data Factory
|
|
185
|
-
|
|
186
|
-
```typescript
|
|
187
|
-
const userFactory = testFactory.createDataFactory({
|
|
188
|
-
id: 1,
|
|
189
|
-
name: 'Test User',
|
|
190
|
-
email: 'test@example.com',
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
const user1 = userFactory() // Uses defaults
|
|
194
|
-
const user2 = userFactory({ name: 'Custom User' }) // Override specific fields
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
### Element Test Suite
|
|
198
|
-
|
|
199
|
-
```typescript
|
|
200
|
-
const suite = testFactory.createElementTestSuite('my-element', '../src/my-element.js')
|
|
201
|
-
|
|
202
|
-
// In tests:
|
|
203
|
-
await suite.setup()
|
|
204
|
-
const element = await suite.createElement({ attribute: 'value' }, 'content')
|
|
205
|
-
// ... test element ...
|
|
206
|
-
suite.cleanup()
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## Performance Testing
|
|
210
|
-
|
|
211
|
-
Measure and assert performance:
|
|
212
|
-
|
|
213
|
-
### measureTime(fn)
|
|
214
|
-
|
|
215
|
-
```typescript
|
|
216
|
-
const { result, duration } = await performanceHelpers.measureTime(async () => {
|
|
217
|
-
return await someExpensiveOperation()
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
console.log(`Operation took ${duration}ms`)
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
### expectWithinTime(operation, maxDuration, message?)
|
|
224
|
-
|
|
225
|
-
```typescript
|
|
226
|
-
const result = await performanceHelpers.expectWithinTime(
|
|
227
|
-
() => renderLargeList(),
|
|
228
|
-
1000, // max 1 second
|
|
229
|
-
'List rendering should be fast'
|
|
230
|
-
)
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
## Writing Component Tests
|
|
234
|
-
|
|
235
|
-
### Basic Structure
|
|
236
|
-
|
|
237
|
-
```typescript
|
|
238
|
-
import { assert, fixture, html } from '@open-wc/testing'
|
|
239
|
-
import { customMatchers } from '../helpers/TestUtils.js'
|
|
240
|
-
import { UiMock } from '../helpers/UiMock.js'
|
|
241
|
-
|
|
242
|
-
// Import test setup
|
|
243
|
-
import '../setup.js'
|
|
244
|
-
|
|
245
|
-
// Import component
|
|
246
|
-
import '../src/my-component.js'
|
|
247
|
-
|
|
248
|
-
describe('MyComponent', () => {
|
|
249
|
-
async function basicFixture() {
|
|
250
|
-
return fixture(html`<my-component></my-component>`)
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
it('should render correctly', async () => {
|
|
254
|
-
const element = await basicFixture()
|
|
255
|
-
|
|
256
|
-
// Use custom matchers
|
|
257
|
-
const result = customMatchers.toBeVisible(element)
|
|
258
|
-
assert.isTrue(result.pass)
|
|
259
|
-
|
|
260
|
-
// Test functionality
|
|
261
|
-
await UiMock.keyPress(element, 'Enter')
|
|
262
|
-
|
|
263
|
-
// Wait for changes
|
|
264
|
-
await window.testUtils.waitForCondition(() =>
|
|
265
|
-
element.hasAttribute('data-processed')
|
|
266
|
-
)
|
|
267
|
-
|
|
268
|
-
assert.isTrue(element.hasAttribute('data-processed'))
|
|
269
|
-
})
|
|
270
|
-
})
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### Testing Custom Elements
|
|
274
|
-
|
|
275
|
-
```typescript
|
|
276
|
-
describe('CustomElement', () => {
|
|
277
|
-
let element: HTMLElement
|
|
278
|
-
|
|
279
|
-
beforeEach(async () => {
|
|
280
|
-
element = await fixture(html`<custom-element
|
|
281
|
-
.property="${'value'}"
|
|
282
|
-
@event="${(e) => console.log(e)}"
|
|
283
|
-
></custom-element>`)
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
it('should handle properties', () => {
|
|
287
|
-
// Test property binding
|
|
288
|
-
assert.equal(element.property, 'value')
|
|
289
|
-
})
|
|
290
|
-
|
|
291
|
-
it('should handle events', async () => {
|
|
292
|
-
let eventFired = false
|
|
293
|
-
element.addEventListener('custom-event', () => {
|
|
294
|
-
eventFired = true
|
|
295
|
-
})
|
|
296
|
-
|
|
297
|
-
// Trigger event
|
|
298
|
-
element.dispatchEvent(new CustomEvent('trigger'))
|
|
299
|
-
|
|
300
|
-
await window.testUtils.waitForCondition(() => eventFired)
|
|
301
|
-
assert.isTrue(eventFired)
|
|
302
|
-
})
|
|
303
|
-
})
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
## Environment Variables
|
|
307
|
-
|
|
308
|
-
Test environment configuration is available through the mock server:
|
|
309
|
-
|
|
310
|
-
- OAuth2 server details available in test environment
|
|
311
|
-
- Custom environment setup via `env.ts`
|
|
312
|
-
|
|
313
|
-
## Coverage Reports
|
|
314
|
-
|
|
315
|
-
Coverage reports are generated in `coverage/` directory:
|
|
316
|
-
|
|
317
|
-
- `lcov.info` - Machine-readable coverage data
|
|
318
|
-
- `lcov-report/` - Human-readable HTML reports
|
|
319
|
-
|
|
320
|
-
Open `coverage/lcov-report/index.html` to view detailed coverage information.
|
|
321
|
-
|
|
322
|
-
## Best Practices
|
|
323
|
-
|
|
324
|
-
1. **Use the global setup**: Import `../setup.js` in test files
|
|
325
|
-
2. **Leverage custom matchers**: Use `customMatchers` for better assertions
|
|
326
|
-
3. **Simulate real interactions**: Use `UiMock` for realistic user interactions
|
|
327
|
-
4. **Handle async operations**: Use `asyncHelpers` for waiting and retrying
|
|
328
|
-
5. **Create reusable factories**: Use `testFactory` for common test data
|
|
329
|
-
6. **Test performance**: Use `performanceHelpers` for timing-critical code
|
|
330
|
-
7. **Clean up properly**: The global setup handles cleanup automatically
|
|
331
|
-
8. **Use meaningful assertions**: Prefer descriptive custom matchers over generic ones
|
|
332
|
-
|
|
333
|
-
## DOM Element Assertions
|
|
334
|
-
|
|
335
|
-
When comparing DOM elements, always use the special DOM assertion methods from `@open-wc/testing`:
|
|
336
|
-
|
|
337
|
-
### assert.dom.equal(actual, expected)
|
|
338
|
-
|
|
339
|
-
Compare DOM elements for equality:
|
|
340
|
-
|
|
341
|
-
```typescript
|
|
342
|
-
const element1 = document.querySelector('#test')
|
|
343
|
-
const element2 = await window.testUtils.waitForElement('#test')
|
|
344
|
-
assert.dom.equal(element1, element2)
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
### assert.dom.notEqual(actual, expected)
|
|
348
|
-
|
|
349
|
-
Assert that DOM elements are not the same:
|
|
350
|
-
|
|
351
|
-
```typescript
|
|
352
|
-
const element1 = document.querySelector('#test1')
|
|
353
|
-
const element2 = document.querySelector('#test2')
|
|
354
|
-
assert.dom.notEqual(element1, element2)
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
### assert.dom.equalSnapshot(element, snapshot)
|
|
358
|
-
|
|
359
|
-
Compare element with a snapshot:
|
|
360
|
-
|
|
361
|
-
```typescript
|
|
362
|
-
const element = await fixture(html`<div>Content</div>`)
|
|
363
|
-
assert.dom.equalSnapshot(element, '<div>Content</div>')
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### assert.dom.notEqualSnapshot(element, snapshot)
|
|
367
|
-
|
|
368
|
-
Assert element doesn't match snapshot:
|
|
369
|
-
|
|
370
|
-
```typescript
|
|
371
|
-
const element = await fixture(html`<div>Changed</div>`)
|
|
372
|
-
assert.dom.notEqualSnapshot(element, '<div>Original</div>')
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
> ⚠️ **Important**: Never use regular `assert.equal()` for DOM elements as it won't work correctly. Always use `assert.dom.*` methods for DOM comparisons.
|