@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
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
|
|
4
|
-
const root = path.join('test', 'screenshots')
|
|
5
|
-
|
|
6
|
-
export function takeScreenshotPlugin() {
|
|
7
|
-
return {
|
|
8
|
-
name: 'take-screen-command',
|
|
9
|
-
|
|
10
|
-
async executeCommand({ command, payload, session }) {
|
|
11
|
-
if (command === 'take-screenshot') {
|
|
12
|
-
await fs.mkdir(root, { recursive: true })
|
|
13
|
-
const config = /** @type {{ name: string }} */ (payload)
|
|
14
|
-
|
|
15
|
-
const file = `${config.name}.png`
|
|
16
|
-
const filePath = path.join(root, file)
|
|
17
|
-
|
|
18
|
-
if (session.browser.type === 'puppeteer') {
|
|
19
|
-
const page = session.browser.getPage(session.id)
|
|
20
|
-
const screenshot = await page.screenshot()
|
|
21
|
-
await fs.writeFile(filePath, screenshot)
|
|
22
|
-
return true
|
|
23
|
-
}
|
|
24
|
-
if (session.browser.type === 'playwright') {
|
|
25
|
-
const page = session.browser.getPage(session.id)
|
|
26
|
-
const screenshot = await page.screenshot()
|
|
27
|
-
await fs.writeFile(filePath, screenshot)
|
|
28
|
-
return true
|
|
29
|
-
}
|
|
30
|
-
throw new Error(`Taking screenshots is not supported for browser type ${session.browser.type}.`)
|
|
31
|
-
}
|
|
32
|
-
return undefined
|
|
33
|
-
},
|
|
34
|
-
}
|
|
35
|
-
}
|
package/test/setup.test.ts
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example test file demonstrating the test setup and utilities.
|
|
3
|
-
* This shows how to use the test infrastructure for UI components.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { assert } from '@open-wc/testing'
|
|
7
|
-
import { testFactory, asyncHelpers, customMatchers } from './helpers/TestUtils.js'
|
|
8
|
-
import { UiMock } from './helpers/UiMock.js'
|
|
9
|
-
|
|
10
|
-
// Import the setup to ensure it runs
|
|
11
|
-
import './setup.js'
|
|
12
|
-
|
|
13
|
-
describe('Test Setup Example', () => {
|
|
14
|
-
describe('Basic Test Infrastructure', () => {
|
|
15
|
-
it('should have test utilities available globally', () => {
|
|
16
|
-
assert.exists(window.testUtils)
|
|
17
|
-
assert.isFunction(window.testUtils.waitForElement)
|
|
18
|
-
assert.isFunction(window.testUtils.waitForCondition)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('should have custom matchers available', () => {
|
|
22
|
-
assert.exists(customMatchers.toHaveClasses)
|
|
23
|
-
assert.exists(customMatchers.toBeVisible)
|
|
24
|
-
assert.exists(customMatchers.toHaveAttribute)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('should have async helpers available', () => {
|
|
28
|
-
assert.exists(asyncHelpers.waitForAll)
|
|
29
|
-
assert.exists(asyncHelpers.waitForAny)
|
|
30
|
-
assert.exists(asyncHelpers.retry)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('should have UiMock utilities available', () => {
|
|
34
|
-
assert.exists(UiMock.keyDown)
|
|
35
|
-
assert.exists(UiMock.keyUp)
|
|
36
|
-
assert.exists(UiMock.keyPress)
|
|
37
|
-
assert.exists(UiMock.getMiddleOfElement)
|
|
38
|
-
assert.exists(UiMock.moveMouse)
|
|
39
|
-
assert.exists(UiMock.dragAndDrop)
|
|
40
|
-
assert.exists(UiMock.getFileDragEvent)
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
describe('Element Testing Example', () => {
|
|
45
|
-
let element: HTMLElement
|
|
46
|
-
|
|
47
|
-
beforeEach(() => {
|
|
48
|
-
// Clean setup is handled by global setup
|
|
49
|
-
element = document.createElement('div')
|
|
50
|
-
element.id = 'test-element'
|
|
51
|
-
element.className = 'test-class'
|
|
52
|
-
element.setAttribute('data-test', 'value')
|
|
53
|
-
document.body.appendChild(element)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
afterEach(() => {
|
|
57
|
-
// Cleanup is handled by global setup
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('should test element classes using custom matcher', () => {
|
|
61
|
-
const result = customMatchers.toHaveClasses(element, 'test-class')
|
|
62
|
-
assert.isTrue(result.pass)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('should test element visibility using custom matcher', () => {
|
|
66
|
-
const result = customMatchers.toBeVisible(element)
|
|
67
|
-
assert.isTrue(result.pass)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('should test element attributes using custom matcher', () => {
|
|
71
|
-
const result = customMatchers.toHaveAttribute(element, 'data-test', 'value')
|
|
72
|
-
assert.isTrue(result.pass)
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
it('should wait for element to appear', async () => {
|
|
76
|
-
// Remove element temporarily
|
|
77
|
-
element.remove()
|
|
78
|
-
|
|
79
|
-
// Add it back after a delay
|
|
80
|
-
setTimeout(() => {
|
|
81
|
-
document.body.appendChild(element)
|
|
82
|
-
}, 10)
|
|
83
|
-
|
|
84
|
-
// Wait for it to appear
|
|
85
|
-
const foundElement = await window.testUtils.waitForElement('#test-element')
|
|
86
|
-
assert.dom.equal(foundElement, element)
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
it('should wait for condition to be true', async () => {
|
|
90
|
-
let conditionMet = false
|
|
91
|
-
|
|
92
|
-
// Set condition to true after delay
|
|
93
|
-
setTimeout(() => {
|
|
94
|
-
conditionMet = true
|
|
95
|
-
}, 100)
|
|
96
|
-
|
|
97
|
-
// Wait for condition
|
|
98
|
-
await window.testUtils.waitForCondition(() => conditionMet)
|
|
99
|
-
assert.isTrue(conditionMet)
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
describe('Async Helpers Example', () => {
|
|
104
|
-
it('should wait for all conditions', async () => {
|
|
105
|
-
let condition1 = false
|
|
106
|
-
let condition2 = false
|
|
107
|
-
|
|
108
|
-
setTimeout(() => {
|
|
109
|
-
condition1 = true
|
|
110
|
-
}, 50)
|
|
111
|
-
setTimeout(() => {
|
|
112
|
-
condition2 = true
|
|
113
|
-
}, 100)
|
|
114
|
-
|
|
115
|
-
await asyncHelpers.waitForAll([() => condition1, () => condition2])
|
|
116
|
-
|
|
117
|
-
assert.isTrue(condition1)
|
|
118
|
-
assert.isTrue(condition2)
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
it('should wait for any condition', async () => {
|
|
122
|
-
let condition1 = false
|
|
123
|
-
let condition2 = false
|
|
124
|
-
|
|
125
|
-
setTimeout(() => {
|
|
126
|
-
condition1 = true
|
|
127
|
-
}, 50)
|
|
128
|
-
setTimeout(() => {
|
|
129
|
-
condition2 = true
|
|
130
|
-
}, 100)
|
|
131
|
-
|
|
132
|
-
const index = await asyncHelpers.waitForAny([() => condition1, () => condition2])
|
|
133
|
-
|
|
134
|
-
assert.equal(index, 0) // First condition should be met first
|
|
135
|
-
assert.isTrue(condition1)
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
it('should retry failed operations', async () => {
|
|
139
|
-
let attempts = 0
|
|
140
|
-
|
|
141
|
-
const operation = async () => {
|
|
142
|
-
attempts++
|
|
143
|
-
if (attempts < 3) {
|
|
144
|
-
throw new Error('Not ready yet')
|
|
145
|
-
}
|
|
146
|
-
return 'success'
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const result = await asyncHelpers.retry(operation, 5, 10)
|
|
150
|
-
assert.equal(result, 'success')
|
|
151
|
-
assert.equal(attempts, 3)
|
|
152
|
-
})
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
describe('Test Factory Example', () => {
|
|
156
|
-
it('should create data factory', () => {
|
|
157
|
-
const userFactory = testFactory.createDataFactory({
|
|
158
|
-
id: 1,
|
|
159
|
-
name: 'Test User',
|
|
160
|
-
email: 'test@example.com',
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
const user1 = userFactory()
|
|
164
|
-
assert.equal(user1.name, 'Test User')
|
|
165
|
-
|
|
166
|
-
const user2 = userFactory({ name: 'Custom User' })
|
|
167
|
-
assert.equal(user2.name, 'Custom User')
|
|
168
|
-
assert.equal(user2.email, 'test@example.com') // Keeps default
|
|
169
|
-
})
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
describe('UI Interaction Example', () => {
|
|
173
|
-
let button: HTMLButtonElement
|
|
174
|
-
|
|
175
|
-
beforeEach(() => {
|
|
176
|
-
button = document.createElement('button')
|
|
177
|
-
button.textContent = 'Click me'
|
|
178
|
-
button.style.width = '100px'
|
|
179
|
-
button.style.height = '40px'
|
|
180
|
-
button.style.position = 'absolute'
|
|
181
|
-
button.style.top = '100px'
|
|
182
|
-
button.style.left = '100px'
|
|
183
|
-
document.body.appendChild(button)
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
it('should simulate keyboard interaction', async () => {
|
|
187
|
-
let keyPressed = false
|
|
188
|
-
|
|
189
|
-
button.addEventListener('keydown', (e) => {
|
|
190
|
-
if (e.code === 'Enter') {
|
|
191
|
-
keyPressed = true
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
await UiMock.keyPress(button, 'Enter')
|
|
196
|
-
assert.isTrue(keyPressed)
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
it('should get element center position', () => {
|
|
200
|
-
const center = UiMock.getMiddleOfElement(button)
|
|
201
|
-
assert.isNumber(center.x)
|
|
202
|
-
assert.isNumber(center.y)
|
|
203
|
-
assert.isAbove(center.x, 0)
|
|
204
|
-
assert.isAbove(center.y, 0)
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
it('should create file drag event', () => {
|
|
208
|
-
const file = new File(['test content'], 'test.txt', { type: 'text/plain' })
|
|
209
|
-
const dragEvent = UiMock.getFileDragEvent('drop', { file })
|
|
210
|
-
|
|
211
|
-
assert.equal(dragEvent.type, 'drop')
|
|
212
|
-
assert.exists(dragEvent.dataTransfer)
|
|
213
|
-
assert.equal(dragEvent.dataTransfer!.files.length, 1)
|
|
214
|
-
assert.equal(dragEvent.dataTransfer!.files[0].name, 'test.txt')
|
|
215
|
-
})
|
|
216
|
-
})
|
|
217
|
-
})
|
package/test/setup.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test setup configuration for the UI component library.
|
|
3
|
-
* This file is imported by all test files to ensure consistent test environment.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// // Global test setup
|
|
7
|
-
// before(() => {
|
|
8
|
-
// // Set up global test configuration
|
|
9
|
-
// // eslint-disable-next-line no-console
|
|
10
|
-
// console.log('Setting up test environment...')
|
|
11
|
-
// })
|
|
12
|
-
|
|
13
|
-
// beforeEach(() => {
|
|
14
|
-
// // Clean up DOM before each test
|
|
15
|
-
// document.body.innerHTML = ''
|
|
16
|
-
|
|
17
|
-
// // Reset any global state
|
|
18
|
-
// if (window.localStorage) {
|
|
19
|
-
// window.localStorage.clear()
|
|
20
|
-
// }
|
|
21
|
-
// if (window.sessionStorage) {
|
|
22
|
-
// window.sessionStorage.clear()
|
|
23
|
-
// }
|
|
24
|
-
// })
|
|
25
|
-
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
// Clean up after each test
|
|
28
|
-
// document.body.innerHTML = ''
|
|
29
|
-
|
|
30
|
-
// Clear any pending timers
|
|
31
|
-
const highestTimeoutId = window.setTimeout(() => {}, 0)
|
|
32
|
-
for (let i = 0; i < highestTimeoutId; i++) {
|
|
33
|
-
window.clearTimeout(i)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Clear any pending intervals
|
|
37
|
-
const highestIntervalId = window.setInterval(() => {}, 9999)
|
|
38
|
-
for (let i = 0; i < highestIntervalId; i++) {
|
|
39
|
-
window.clearInterval(i)
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
// after(() => {
|
|
44
|
-
// // eslint-disable-next-line no-console
|
|
45
|
-
// console.log('Test environment cleanup complete.')
|
|
46
|
-
// })
|
|
47
|
-
|
|
48
|
-
// Global test utilities
|
|
49
|
-
declare global {
|
|
50
|
-
interface Window {
|
|
51
|
-
testUtils: {
|
|
52
|
-
waitForElement: (selector: string, timeout?: number) => Promise<Element>
|
|
53
|
-
waitForCondition: (condition: () => boolean, timeout?: number) => Promise<void>
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Add test utilities to global scope
|
|
59
|
-
window.testUtils = {
|
|
60
|
-
/**
|
|
61
|
-
* Wait for an element to appear in the DOM
|
|
62
|
-
*/
|
|
63
|
-
async waitForElement(selector: string, timeout = 5000): Promise<Element> {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
const startTime = Date.now()
|
|
66
|
-
|
|
67
|
-
function checkElement() {
|
|
68
|
-
const element = document.querySelector(selector)
|
|
69
|
-
if (element) {
|
|
70
|
-
resolve(element)
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (Date.now() - startTime > timeout) {
|
|
75
|
-
reject(new Error(`Element with selector "${selector}" not found within ${timeout}ms`))
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
setTimeout(checkElement, 50)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
checkElement()
|
|
83
|
-
})
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Wait for a condition to be true
|
|
88
|
-
*/
|
|
89
|
-
async waitForCondition(condition: () => boolean, timeout = 5000): Promise<void> {
|
|
90
|
-
return new Promise((resolve, reject) => {
|
|
91
|
-
const startTime = Date.now()
|
|
92
|
-
|
|
93
|
-
function checkCondition() {
|
|
94
|
-
try {
|
|
95
|
-
if (condition()) {
|
|
96
|
-
resolve()
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
} catch {
|
|
100
|
-
// Condition threw an error, continue waiting
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (Date.now() - startTime > timeout) {
|
|
104
|
-
reject(new Error(`Condition not met within ${timeout}ms`))
|
|
105
|
-
return
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
setTimeout(checkCondition, 50)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
checkCondition()
|
|
112
|
-
})
|
|
113
|
-
},
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Export setup for explicit imports
|
|
117
|
-
export {}
|
package/test/tsconfig.json
DELETED
package/web-dev-server.config.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import AuthPlugin from './demo/elements/authorization/AuthPlugin.js'
|
|
2
|
-
|
|
3
|
-
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
4
|
-
open: '/demo/',
|
|
5
|
-
nodeResolve: {
|
|
6
|
-
browser: true,
|
|
7
|
-
dedupe: [
|
|
8
|
-
'lit',
|
|
9
|
-
'lit-html',
|
|
10
|
-
'lit-element',
|
|
11
|
-
'lit-html/directives',
|
|
12
|
-
'@material/web',
|
|
13
|
-
'@open-wc/dedupe-mixin',
|
|
14
|
-
'@api-client/core',
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
preserveSymlinks: true,
|
|
19
|
-
|
|
20
|
-
plugins: [AuthPlugin],
|
|
21
|
-
})
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { OAuth2Server } from 'oauth2-mock-server'
|
|
2
|
-
import getPort, { portNumbers } from 'get-port'
|
|
3
|
-
|
|
4
|
-
const oauth2server = new OAuth2Server()
|
|
5
|
-
let oauth2env
|
|
6
|
-
|
|
7
|
-
/** @typedef {import('@web/test-runner').TestRunnerConfig} TestRunnerConfig */
|
|
8
|
-
|
|
9
|
-
const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode', 'Lit is in dev mode']
|
|
10
|
-
|
|
11
|
-
export default /** @type TestRunnerConfig */ ({
|
|
12
|
-
nodeResolve: {
|
|
13
|
-
browser: true,
|
|
14
|
-
},
|
|
15
|
-
files: ['.tmp/test/**/*.test.js', '.tmp/test/**/*.spec.js'],
|
|
16
|
-
// files: ['.tmp/test/core/fragment_manager.spec.js'],
|
|
17
|
-
|
|
18
|
-
concurrentBrowsers: 3,
|
|
19
|
-
concurrency: 10,
|
|
20
|
-
rootDir: './',
|
|
21
|
-
|
|
22
|
-
/** Filter out lit dev mode logs */
|
|
23
|
-
filterBrowserLogs(log) {
|
|
24
|
-
for (const arg of log.args) {
|
|
25
|
-
if (typeof arg === 'string' && filteredLogs.some((l) => arg.includes(l))) {
|
|
26
|
-
return false
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return true
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
plugins: [
|
|
33
|
-
{
|
|
34
|
-
name: 'mock-api',
|
|
35
|
-
serve(context) {
|
|
36
|
-
if (context.path === '/.tmp/test/env.js') {
|
|
37
|
-
const data = {
|
|
38
|
-
oauth2: oauth2env,
|
|
39
|
-
}
|
|
40
|
-
return `export default ${JSON.stringify(data)}`
|
|
41
|
-
}
|
|
42
|
-
return undefined
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
name: 'servers',
|
|
48
|
-
async serverStart() {
|
|
49
|
-
const port = await getPort({ port: portNumbers(8000, 8100) })
|
|
50
|
-
const jwtKey = await oauth2server.issuer.keys.generate('RS256')
|
|
51
|
-
await oauth2server.start(port, 'localhost')
|
|
52
|
-
oauth2env = {
|
|
53
|
-
port,
|
|
54
|
-
jwtKey,
|
|
55
|
-
issuer: oauth2server.issuer.url,
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
async serverStop() {
|
|
60
|
-
await oauth2server.stop()
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
|
|
65
|
-
testRunnerHtml: (testFramework) =>
|
|
66
|
-
`<html class="theme-light">
|
|
67
|
-
<head>
|
|
68
|
-
<!-- m3 styles -->
|
|
69
|
-
<link rel="stylesheet" href="/src/styles/m3/tokens.css" data-theme="tokens" />
|
|
70
|
-
<link rel="stylesheet" href="/src/styles/m3/theme.css" data-theme="light" />
|
|
71
|
-
</head>
|
|
72
|
-
<body>
|
|
73
|
-
<script type="module" src="${testFramework}"></script>
|
|
74
|
-
</body>
|
|
75
|
-
</html>`,
|
|
76
|
-
|
|
77
|
-
testFramework: {
|
|
78
|
-
config: {
|
|
79
|
-
timeout: 60000,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
browserStartTimeout: 20000,
|
|
83
|
-
testsStartTimeout: 20000,
|
|
84
|
-
testsFinishTimeout: 30000,
|
|
85
|
-
|
|
86
|
-
coverageConfig: {
|
|
87
|
-
report: true,
|
|
88
|
-
reporters: ['lcov', 'text'],
|
|
89
|
-
},
|
|
90
|
-
})
|