@api-client/ui 0.5.38 → 0.5.40
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/md/list/internals/ListItem.d.ts +24 -15
- package/build/src/md/list/internals/ListItem.d.ts.map +1 -1
- package/build/src/md/list/internals/ListItem.js +85 -59
- package/build/src/md/list/internals/ListItem.js.map +1 -1
- package/build/src/md/list/internals/ListItem.styles.js +11 -11
- package/build/src/md/list/internals/ListItem.styles.js.map +1 -1
- package/build/src/md/select/internals/Option.d.ts +4 -14
- package/build/src/md/select/internals/Option.d.ts.map +1 -1
- package/build/src/md/select/internals/Option.js +13 -28
- package/build/src/md/select/internals/Option.js.map +1 -1
- package/build/src/md/select/internals/Select.d.ts +1 -1
- package/build/src/md/select/internals/Select.d.ts.map +1 -1
- package/build/src/md/select/internals/Select.js +15 -5
- package/build/src/md/select/internals/Select.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/md/list/internals/ListItem.styles.ts +11 -11
- package/src/md/list/internals/ListItem.ts +68 -43
- package/src/md/select/internals/Option.ts +14 -26
- package/src/md/select/internals/Select.ts +15 -5
- 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/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 -207
- 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,413 +0,0 @@
|
|
|
1
|
-
import { assert } from '@esm-bundle/chai'
|
|
2
|
-
import { fixture, html } from '@open-wc/testing'
|
|
3
|
-
import sinon from 'sinon'
|
|
4
|
-
import { nothing } from 'lit'
|
|
5
|
-
import { Activity } from '../../src/core/Activity.js'
|
|
6
|
-
import { Application } from '../../src/core/Application.js'
|
|
7
|
-
import { IntentResult, ActivityLifecycle } from '../../src/core/ActivityManager.js'
|
|
8
|
-
import { EventTypes } from '../../src/events/EventTypes.js'
|
|
9
|
-
import { Fragment } from '../../src/core/Fragment.js'
|
|
10
|
-
import type { ActivityDetail } from '../../src/events/IntentEvents.js'
|
|
11
|
-
|
|
12
|
-
class TestActivity extends Activity {
|
|
13
|
-
static override action = 'test-activity'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
class TestActivity2 extends Activity {
|
|
17
|
-
static override action = 'test-activity2'
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
class TestApplication extends Application {
|
|
21
|
-
override async onStart(): Promise<void> {
|
|
22
|
-
this.manager.registerActivity(TestActivity.action, TestActivity)
|
|
23
|
-
this.manager.registerActivity(TestActivity2.action, TestActivity2)
|
|
24
|
-
// The creation below is for tests that require an activity to be present in the manager
|
|
25
|
-
// e.g. for setResult, getApplication, getActivity, hasRequestCode, onActivityResult
|
|
26
|
-
// For other tests, a new TestActivity is created directly.
|
|
27
|
-
// This helps isolate tests for lifecycle events from manager interactions.
|
|
28
|
-
await this.manager.createActivity({ action: TestActivity.action, data: { test: true } })
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
class TestFragment extends Fragment {}
|
|
33
|
-
|
|
34
|
-
async function basicFixture(): Promise<HTMLElement> {
|
|
35
|
-
return fixture(html`<div id="app"></div>`)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
describe('Activity Lifecycle and Events', () => {
|
|
39
|
-
let application: Application
|
|
40
|
-
let activity: Activity
|
|
41
|
-
|
|
42
|
-
beforeEach(async () => {
|
|
43
|
-
const renderRoot = await basicFixture()
|
|
44
|
-
application = new TestApplication(renderRoot)
|
|
45
|
-
activity = new TestActivity(application)
|
|
46
|
-
// Note: application.onStart() is not called here to isolate Activity's own lifecycle methods.
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('dispatches the activity:create event', async () => {
|
|
50
|
-
const spy = sinon.spy()
|
|
51
|
-
activity.addEventListener('activity:create', spy)
|
|
52
|
-
await activity.onCreate()
|
|
53
|
-
assert.isTrue(spy.calledOnce)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('dispatches the activity:start event', async () => {
|
|
57
|
-
const spy = sinon.spy()
|
|
58
|
-
activity.addEventListener('activity:start', spy)
|
|
59
|
-
await activity.onStart()
|
|
60
|
-
assert.isTrue(spy.calledOnce)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('dispatches the activity:resume event', async () => {
|
|
64
|
-
const spy = sinon.spy()
|
|
65
|
-
activity.addEventListener('activity:resume', spy)
|
|
66
|
-
await activity.onResume()
|
|
67
|
-
assert.isTrue(spy.calledOnce)
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('dispatches the activity:pause event', async () => {
|
|
71
|
-
const spy = sinon.spy()
|
|
72
|
-
activity.addEventListener('activity:pause', spy)
|
|
73
|
-
await activity.onPause()
|
|
74
|
-
assert.isTrue(spy.calledOnce)
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
it('dispatches the activity:stop event', async () => {
|
|
78
|
-
const spy = sinon.spy()
|
|
79
|
-
activity.addEventListener('activity:stop', spy)
|
|
80
|
-
await activity.onStop()
|
|
81
|
-
assert.isTrue(spy.calledOnce)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('dispatches the activity:restart event', async () => {
|
|
85
|
-
const spy = sinon.spy()
|
|
86
|
-
activity.addEventListener('activity:restart', spy)
|
|
87
|
-
await activity.onRestart()
|
|
88
|
-
assert.isTrue(spy.calledOnce)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('dispatches the activity:destroy event', async () => {
|
|
92
|
-
const spy = sinon.spy()
|
|
93
|
-
activity.addEventListener('activity:destroy', spy)
|
|
94
|
-
await activity.onDestroy()
|
|
95
|
-
assert.isTrue(spy.calledOnce)
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it('calls manager.onDestroy when activity is destroyed', async () => {
|
|
99
|
-
const spy = sinon.spy(activity['manager'], 'onDestroy')
|
|
100
|
-
await activity.onDestroy()
|
|
101
|
-
assert.isTrue(spy.calledOnce)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
it('sets the default state', async () => {
|
|
105
|
-
assert.equal(activity.lifecycle, ActivityLifecycle.Initialized)
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
it('sets the default resultCode', async () => {
|
|
109
|
-
assert.equal(activity.resultCode, IntentResult.RESULT_CANCELED)
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
it('onNewIntent can be called', async () => {
|
|
113
|
-
assert.doesNotThrow(async () => {
|
|
114
|
-
await activity.onNewIntent({ action: 'test' })
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it('onFirstRender can be called', () => {
|
|
119
|
-
assert.doesNotThrow(() => {
|
|
120
|
-
activity.onFirstRender()
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
it('render returns nothing by default', () => {
|
|
125
|
-
assert.strictEqual(activity.render(), nothing)
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
describe('setResult()', () => {
|
|
130
|
-
let application: Application
|
|
131
|
-
let activity: Activity
|
|
132
|
-
|
|
133
|
-
beforeEach(async () => {
|
|
134
|
-
const renderRoot = await basicFixture()
|
|
135
|
-
application = new TestApplication(renderRoot)
|
|
136
|
-
// application.onStart() creates an activity instance via the manager
|
|
137
|
-
await application.onStart()
|
|
138
|
-
activity = application.manager.findActiveActivity(TestActivity.action) as Activity
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
it('sets the resultData and resultCode', () => {
|
|
142
|
-
const data = { key: 'value' }
|
|
143
|
-
activity.setResult(IntentResult.RESULT_OK, data)
|
|
144
|
-
assert.equal(activity.resultCode, IntentResult.RESULT_OK)
|
|
145
|
-
assert.deepEqual(activity.getResult(), data)
|
|
146
|
-
})
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
describe('getResult()', () => {
|
|
150
|
-
let application: Application
|
|
151
|
-
let activity: Activity
|
|
152
|
-
|
|
153
|
-
beforeEach(async () => {
|
|
154
|
-
const renderRoot = await basicFixture()
|
|
155
|
-
application = new TestApplication(renderRoot)
|
|
156
|
-
activity = new TestActivity(application) // Test with a fresh activity not from manager
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
it('returns undefined by default', () => {
|
|
160
|
-
assert.isUndefined(activity.getResult())
|
|
161
|
-
})
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
describe('getApplication()', () => {
|
|
165
|
-
let application: Application
|
|
166
|
-
let activity: Activity
|
|
167
|
-
|
|
168
|
-
beforeEach(async () => {
|
|
169
|
-
const renderRoot = await basicFixture()
|
|
170
|
-
application = new TestApplication(renderRoot)
|
|
171
|
-
// application.onStart() creates an activity instance via the manager
|
|
172
|
-
await application.onStart()
|
|
173
|
-
activity = application.manager.findActiveActivity(TestActivity.action) as Activity
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
it('returns parent application for getApplication()', () => {
|
|
177
|
-
assert.isTrue(activity.getApplication() === application)
|
|
178
|
-
})
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
describe('getActivity()', () => {
|
|
182
|
-
let application: Application
|
|
183
|
-
let activity: Activity
|
|
184
|
-
|
|
185
|
-
beforeEach(async () => {
|
|
186
|
-
const renderRoot = await basicFixture()
|
|
187
|
-
application = new TestApplication(renderRoot)
|
|
188
|
-
// application.onStart() creates an activity instance via the manager
|
|
189
|
-
await application.onStart()
|
|
190
|
-
activity = application.manager.findActiveActivity(TestActivity.action) as Activity
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
it('returns self for getActivity()', () => {
|
|
194
|
-
assert.isTrue(activity.getActivity() === activity)
|
|
195
|
-
})
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
describe('hasRequestCode()', () => {
|
|
199
|
-
let application: Application
|
|
200
|
-
let activity: Activity
|
|
201
|
-
|
|
202
|
-
beforeEach(async () => {
|
|
203
|
-
const renderRoot = await basicFixture()
|
|
204
|
-
application = new TestApplication(renderRoot)
|
|
205
|
-
// application.onStart() creates an activity instance via the manager
|
|
206
|
-
await application.onStart()
|
|
207
|
-
activity = application.manager.findActiveActivity(TestActivity.action) as Activity
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
it('returns true when request code is pending', async () => {
|
|
211
|
-
const requestCode = await activity.startActivityForResult({ action: TestActivity.action })
|
|
212
|
-
assert.isTrue(activity.hasRequestCode(requestCode))
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
it('returns false when request code is not pending', async () => {
|
|
216
|
-
await activity.startActivityForResult({ action: TestActivity.action })
|
|
217
|
-
assert.isFalse(activity.hasRequestCode(1))
|
|
218
|
-
})
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
describe('onActivityResult()', () => {
|
|
222
|
-
let application: Application
|
|
223
|
-
let activity: Activity
|
|
224
|
-
|
|
225
|
-
beforeEach(async () => {
|
|
226
|
-
const renderRoot = await basicFixture()
|
|
227
|
-
application = new TestApplication(renderRoot)
|
|
228
|
-
// application.onStart() creates an activity instance via the manager
|
|
229
|
-
await application.onStart()
|
|
230
|
-
activity = application.manager.findActiveActivity(TestActivity.action) as Activity
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
it('does not crash when there is no pending request code', async () => {
|
|
234
|
-
assert.doesNotThrow(async () => {
|
|
235
|
-
await activity.onActivityResult(2, IntentResult.RESULT_OK, { action: 'test' })
|
|
236
|
-
})
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
it('removes request code if present', async () => {
|
|
240
|
-
const requestCode = await activity.startActivityForResult({ action: TestActivity.action })
|
|
241
|
-
assert.isTrue(activity.hasRequestCode(requestCode))
|
|
242
|
-
await activity.onActivityResult(requestCode, IntentResult.RESULT_OK, { action: 'test' })
|
|
243
|
-
assert.isFalse(activity.hasRequestCode(requestCode))
|
|
244
|
-
})
|
|
245
|
-
|
|
246
|
-
it('forwards to fragment if fragment has request code', async () => {
|
|
247
|
-
const fragment = new TestFragment()
|
|
248
|
-
const onActivityResultStub = sinon.spy(fragment, 'onActivityResult')
|
|
249
|
-
sinon.stub(fragment, 'hasRequestCode').returns(true)
|
|
250
|
-
sinon.stub(activity['manager'], 'findByRequestCode').returns(fragment as unknown as Fragment)
|
|
251
|
-
const requestCode = 123
|
|
252
|
-
await activity.onActivityResult(requestCode, IntentResult.RESULT_OK, { action: 'test' })
|
|
253
|
-
assert.isTrue(onActivityResultStub.calledOnceWith(requestCode, IntentResult.RESULT_OK, { action: 'test' }))
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
it('logs info if not handled by fragment and is base Activity', async () => {
|
|
257
|
-
sinon.stub(activity['manager'], 'findByRequestCode').returns(null)
|
|
258
|
-
const consoleSpy = sinon.spy(console, 'info')
|
|
259
|
-
const requestCode = 123
|
|
260
|
-
// Ensure the activity instance is exactly Activity, not a subclass that might override onActivityResult
|
|
261
|
-
Object.setPrototypeOf(activity, Activity.prototype)
|
|
262
|
-
|
|
263
|
-
await activity.onActivityResult(requestCode, IntentResult.RESULT_OK, { action: 'test-intent' })
|
|
264
|
-
assert.isTrue(
|
|
265
|
-
consoleSpy.calledWith(
|
|
266
|
-
`Activity#onActivityResult not implemented. Request code: ${requestCode}, result code: ${IntentResult.RESULT_OK}`,
|
|
267
|
-
{ action: 'test-intent' }
|
|
268
|
-
)
|
|
269
|
-
)
|
|
270
|
-
consoleSpy.restore()
|
|
271
|
-
})
|
|
272
|
-
})
|
|
273
|
-
|
|
274
|
-
describe('Activity Actions', () => {
|
|
275
|
-
let application: Application
|
|
276
|
-
let activity: Activity
|
|
277
|
-
|
|
278
|
-
beforeEach(async () => {
|
|
279
|
-
const renderRoot = await basicFixture()
|
|
280
|
-
application = new TestApplication(renderRoot)
|
|
281
|
-
// For these tests, we often need a fresh activity instance not necessarily from the manager's stack
|
|
282
|
-
// to avoid side effects from application.onStart() unless specifically testing manager interactions.
|
|
283
|
-
activity = new TestActivity(application)
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
it('startActivity calls application manager startActivity', async () => {
|
|
287
|
-
const intent = { action: TestActivity2.action }
|
|
288
|
-
const spy = sinon.spy(application.manager, 'startActivity')
|
|
289
|
-
await application.onStart() // Ensure the manager is initialized
|
|
290
|
-
await activity.startActivity(intent)
|
|
291
|
-
assert.isTrue(spy.calledOnceWith(intent))
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
it('startActivityForResult calls application manager startActivityForResult and stores request code', async () => {
|
|
295
|
-
const intent = { action: TestActivity2.action }
|
|
296
|
-
const managerSpy = sinon.spy(application.manager, 'startActivityForResult')
|
|
297
|
-
const createCodeSpy = sinon.stub(application.manager, 'createRequestCode').returns(999)
|
|
298
|
-
await application.onStart() // Ensure the manager is initialized
|
|
299
|
-
const requestCode = await activity.startActivityForResult(intent)
|
|
300
|
-
|
|
301
|
-
assert.equal(requestCode, 999)
|
|
302
|
-
assert.isTrue(managerSpy.calledOnceWith(intent, 999))
|
|
303
|
-
assert.isTrue(activity.hasRequestCode(999))
|
|
304
|
-
|
|
305
|
-
createCodeSpy.restore()
|
|
306
|
-
})
|
|
307
|
-
|
|
308
|
-
it('finish calls application manager finishActivity', async () => {
|
|
309
|
-
const spy = sinon.spy(application.manager, 'finishActivity')
|
|
310
|
-
await activity.finish()
|
|
311
|
-
assert.isTrue(spy.calledOnceWith(activity))
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
it('requestUpdate calls parent application requestUpdate and manager updateActiveFragments', () => {
|
|
315
|
-
const appSpy = sinon.spy(application, 'requestUpdate')
|
|
316
|
-
const managerSpy = sinon.spy(activity['manager'], 'updateActiveFragments')
|
|
317
|
-
const opts = { app: false, activity: true, fragment: false }
|
|
318
|
-
activity.requestUpdate(opts)
|
|
319
|
-
assert.isTrue(appSpy.calledOnceWith(opts))
|
|
320
|
-
assert.isTrue(managerSpy.calledOnce)
|
|
321
|
-
})
|
|
322
|
-
|
|
323
|
-
it('requestUpdate defaults to updating activity fragments', () => {
|
|
324
|
-
const managerSpy = sinon.spy(activity['manager'], 'updateActiveFragments')
|
|
325
|
-
activity.requestUpdate() // No opts, so activity should be true by default
|
|
326
|
-
assert.isTrue(managerSpy.calledOnce)
|
|
327
|
-
})
|
|
328
|
-
|
|
329
|
-
it('requestUpdate respects activity: false in opts', () => {
|
|
330
|
-
const managerSpy = sinon.spy(activity['manager'], 'updateActiveFragments')
|
|
331
|
-
activity.requestUpdate({ activity: false })
|
|
332
|
-
assert.isFalse(managerSpy.called)
|
|
333
|
-
})
|
|
334
|
-
})
|
|
335
|
-
|
|
336
|
-
describe('Fragment Management', () => {
|
|
337
|
-
let application: Application
|
|
338
|
-
let activity: Activity
|
|
339
|
-
|
|
340
|
-
beforeEach(async () => {
|
|
341
|
-
const renderRoot = await basicFixture()
|
|
342
|
-
application = new TestApplication(renderRoot)
|
|
343
|
-
activity = new TestActivity(application)
|
|
344
|
-
})
|
|
345
|
-
|
|
346
|
-
it('addFragment calls manager.attachFragment', async () => {
|
|
347
|
-
const spy = sinon.spy(activity['manager'], 'attachFragment')
|
|
348
|
-
const fragment = new TestFragment()
|
|
349
|
-
const data = { info: 'test' }
|
|
350
|
-
await activity.addFragment('testKey', fragment, data)
|
|
351
|
-
assert.isTrue(spy.calledOnceWith('testKey', fragment, activity, data))
|
|
352
|
-
})
|
|
353
|
-
|
|
354
|
-
it('showFragment calls manager.showFragment', async () => {
|
|
355
|
-
const spy = sinon.spy(activity['manager'], 'showFragment')
|
|
356
|
-
activity.addFragment('testKey', new TestFragment()) // Ensure fragment exists
|
|
357
|
-
const rootEl = document.createElement('div')
|
|
358
|
-
await activity.showFragment('testKey', rootEl)
|
|
359
|
-
assert.isTrue(spy.calledOnceWith('testKey', rootEl))
|
|
360
|
-
})
|
|
361
|
-
|
|
362
|
-
it('hideFragment calls manager.hideFragment if fragment exists', async () => {
|
|
363
|
-
const fragment = new TestFragment()
|
|
364
|
-
sinon.stub(activity['manager'], 'findFragment').returns(fragment)
|
|
365
|
-
const spy = sinon.spy(activity['manager'], 'hideFragment')
|
|
366
|
-
await activity.hideFragment('testKey')
|
|
367
|
-
assert.isTrue(spy.calledOnceWith(fragment))
|
|
368
|
-
})
|
|
369
|
-
|
|
370
|
-
it('hideFragment does not call manager.hideFragment if fragment does not exist', async () => {
|
|
371
|
-
sinon.stub(activity['manager'], 'findFragment').returns(undefined)
|
|
372
|
-
const spy = sinon.spy(activity['manager'], 'hideFragment')
|
|
373
|
-
await activity.hideFragment('testKey')
|
|
374
|
-
assert.isFalse(spy.called)
|
|
375
|
-
})
|
|
376
|
-
})
|
|
377
|
-
|
|
378
|
-
describe('handleIntentEvent', () => {
|
|
379
|
-
let activity: Activity
|
|
380
|
-
|
|
381
|
-
beforeEach(async () => {
|
|
382
|
-
const renderRoot = await basicFixture()
|
|
383
|
-
const application = new TestApplication(renderRoot)
|
|
384
|
-
await application.onStart() // Ensure the manager is initialized
|
|
385
|
-
activity = new TestActivity(application)
|
|
386
|
-
})
|
|
387
|
-
|
|
388
|
-
it('handles startActivityForResult event', async () => {
|
|
389
|
-
const startActivityForResultSpy = sinon.spy(activity, 'startActivityForResult')
|
|
390
|
-
const detail = { intent: { action: TestActivity2.action }, onResult: () => {} }
|
|
391
|
-
const event = new CustomEvent(EventTypes.Intent.startActivityForResult, { detail })
|
|
392
|
-
await activity.handleIntentEvent(event)
|
|
393
|
-
assert.isTrue(startActivityForResultSpy.calledOnceWith(detail.intent))
|
|
394
|
-
})
|
|
395
|
-
|
|
396
|
-
it('handles startActivity event', async () => {
|
|
397
|
-
const startActivitySpy = sinon.spy(activity, 'startActivity')
|
|
398
|
-
const detail = { intent: { action: TestActivity2.action } }
|
|
399
|
-
const event = new CustomEvent(EventTypes.Intent.startActivity, { detail })
|
|
400
|
-
await activity.handleIntentEvent(event)
|
|
401
|
-
assert.isTrue(startActivitySpy.calledOnceWith(detail.intent))
|
|
402
|
-
})
|
|
403
|
-
|
|
404
|
-
it('throws error for unrecognized event type', async () => {
|
|
405
|
-
const event = new CustomEvent('unknown-event', { detail: {} as unknown as ActivityDetail })
|
|
406
|
-
try {
|
|
407
|
-
await activity.handleIntentEvent(event)
|
|
408
|
-
assert.fail('Should have thrown an error')
|
|
409
|
-
} catch (e) {
|
|
410
|
-
assert.equal((e as Error).message, `Unrecognized intent event: unknown-event`)
|
|
411
|
-
}
|
|
412
|
-
})
|
|
413
|
-
})
|