@happyvertical/smrt-svelte 0.53.1 → 0.53.2
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/package.json +15 -15
- package/dist/__tests__/app-state.test.js +0 -156
- package/dist/__tests__/data-surface-bridge.test.js +0 -351
- package/dist/__tests__/provider-mode-harness.svelte +0 -14
- package/dist/__tests__/provider-mode-harness.svelte.d.ts +0 -11
- package/dist/__tests__/provider-mode-harness.svelte.d.ts.map +0 -1
- package/dist/__tests__/provider-mode-probe.svelte +0 -13
- package/dist/__tests__/provider-mode-probe.svelte.d.ts +0 -8
- package/dist/__tests__/provider-mode-probe.svelte.d.ts.map +0 -1
- package/dist/__tests__/provider-webmcp-harness.svelte +0 -14
- package/dist/__tests__/provider-webmcp-harness.svelte.d.ts +0 -8
- package/dist/__tests__/provider-webmcp-harness.svelte.d.ts.map +0 -1
- package/dist/__tests__/success-never-text.test.js +0 -100
- package/dist/__tests__/warm-clients.test.js +0 -186
- package/dist/browser-ai/adapters/llm/bitgpu-inference-backend.test.js +0 -464
- package/dist/browser-ai/adapters/llm/webllm-inference-backend.test.js +0 -646
- package/dist/browser-ai/adapters/stt/browser-speech.test.js +0 -113
- package/dist/browser-ai/adapters/stt/dictation-source.test.js +0 -52
- package/dist/browser-ai/svelte/components/__tests__/ModelStatusControl.test.js +0 -172
- package/dist/components/board/__tests__/Board.test.js +0 -498
- package/dist/components/board/__tests__/BoardSsrHarness.svelte +0 -30
- package/dist/components/board/__tests__/BoardSsrHarness.svelte.d.ts +0 -19
- package/dist/components/board/__tests__/BoardSsrHarness.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/AddressInput.behavior.test.js +0 -216
- package/dist/components/forms/__tests__/CheckboxInput.test.js +0 -92
- package/dist/components/forms/__tests__/DateRangeInput.behavior.test.js +0 -135
- package/dist/components/forms/__tests__/DateTimeInput.behavior.test.js +0 -113
- package/dist/components/forms/__tests__/FileUpload.error-alert.test.js +0 -37
- package/dist/components/forms/__tests__/FileUpload.native-form.test.js +0 -249
- package/dist/components/forms/__tests__/FileUpload.test.js +0 -90
- package/dist/components/forms/__tests__/FileUploadReset.fixture.svelte +0 -24
- package/dist/components/forms/__tests__/FileUploadReset.fixture.svelte.d.ts +0 -10
- package/dist/components/forms/__tests__/FileUploadReset.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/Form.behavior.test.js +0 -137
- package/dist/components/forms/__tests__/Form.extraction.test.js +0 -68
- package/dist/components/forms/__tests__/Form.stt-error.test.js +0 -57
- package/dist/components/forms/__tests__/Form.test.js +0 -86
- package/dist/components/forms/__tests__/Form.ui-controls.test.js +0 -119
- package/dist/components/forms/__tests__/Form.webmcp.test.js +0 -2336
- package/dist/components/forms/__tests__/FormMicButton.test.js +0 -92
- package/dist/components/forms/__tests__/FormScope.test.js +0 -39
- package/dist/components/forms/__tests__/MeasurementInput.behavior.test.js +0 -129
- package/dist/components/forms/__tests__/MoneyInput.behavior.test.js +0 -124
- package/dist/components/forms/__tests__/NumberInput.behavior.test.js +0 -151
- package/dist/components/forms/__tests__/PhoneInput.behavior.test.js +0 -96
- package/dist/components/forms/__tests__/SearchInput.test.js +0 -79
- package/dist/components/forms/__tests__/SelectInput.behavior.test.js +0 -132
- package/dist/components/forms/__tests__/TextInput.behavior.test.js +0 -131
- package/dist/components/forms/__tests__/TextareaInput.behavior.test.js +0 -96
- package/dist/components/forms/__tests__/async-invalid-field.fixture.svelte +0 -30
- package/dist/components/forms/__tests__/async-invalid-field.fixture.svelte.d.ts +0 -7
- package/dist/components/forms/__tests__/async-invalid-field.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/async-validation-form.fixture.svelte +0 -19
- package/dist/components/forms/__tests__/async-validation-form.fixture.svelte.d.ts +0 -9
- package/dist/components/forms/__tests__/async-validation-form.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/async-validation-snapshot-form.fixture.svelte +0 -21
- package/dist/components/forms/__tests__/async-validation-snapshot-form.fixture.svelte.d.ts +0 -8
- package/dist/components/forms/__tests__/async-validation-snapshot-form.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/composite-inputs-a11y.test.js +0 -69
- package/dist/components/forms/__tests__/compound-registration-wrapper.fixture.svelte +0 -27
- package/dist/components/forms/__tests__/compound-registration-wrapper.fixture.svelte.d.ts +0 -9
- package/dist/components/forms/__tests__/compound-registration-wrapper.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/custom-registration-field.fixture.svelte +0 -48
- package/dist/components/forms/__tests__/custom-registration-field.fixture.svelte.d.ts +0 -10
- package/dist/components/forms/__tests__/custom-registration-field.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/form-extraction-values.fixture.svelte +0 -26
- package/dist/components/forms/__tests__/form-extraction-values.fixture.svelte.d.ts +0 -13
- package/dist/components/forms/__tests__/form-extraction-values.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/form-registration-lifecycle.fixture.svelte +0 -52
- package/dist/components/forms/__tests__/form-registration-lifecycle.fixture.svelte.d.ts +0 -16
- package/dist/components/forms/__tests__/form-registration-lifecycle.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/form-scope.fixture.svelte +0 -30
- package/dist/components/forms/__tests__/form-scope.fixture.svelte.d.ts +0 -10
- package/dist/components/forms/__tests__/form-scope.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/form-with-fields.fixture.svelte +0 -158
- package/dist/components/forms/__tests__/form-with-fields.fixture.svelte.d.ts +0 -51
- package/dist/components/forms/__tests__/form-with-fields.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/form-with-policy-field.fixture.svelte +0 -24
- package/dist/components/forms/__tests__/form-with-policy-field.fixture.svelte.d.ts +0 -11
- package/dist/components/forms/__tests__/form-with-policy-field.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/form-with-structured-fields.fixture.svelte +0 -105
- package/dist/components/forms/__tests__/form-with-structured-fields.fixture.svelte.d.ts +0 -42
- package/dist/components/forms/__tests__/form-with-structured-fields.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/form-with-ui-controls.fixture.svelte +0 -84
- package/dist/components/forms/__tests__/form-with-ui-controls.fixture.svelte.d.ts +0 -14
- package/dist/components/forms/__tests__/form-with-ui-controls.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/legacy-form-context.fixture.svelte +0 -44
- package/dist/components/forms/__tests__/legacy-form-context.fixture.svelte.d.ts +0 -9
- package/dist/components/forms/__tests__/legacy-form-context.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/mic-keyboard-a11y.test.js +0 -74
- package/dist/components/forms/__tests__/policy-field.fixture.svelte +0 -35
- package/dist/components/forms/__tests__/policy-field.fixture.svelte.d.ts +0 -8
- package/dist/components/forms/__tests__/policy-field.fixture.svelte.d.ts.map +0 -1
- package/dist/components/forms/__tests__/rich-inputs-a11y.test.js +0 -87
- package/dist/components/settings/__tests__/SettingsCatalog.test.js +0 -69
- package/dist/components/settings/__tests__/catalog.test.js +0 -46
- package/dist/components/workspace/__tests__/AdminShell.responsive.test.js +0 -597
- package/dist/components/workspace/__tests__/AdminShell.test.js +0 -572
- package/dist/components/workspace/__tests__/RoleShell.test.js +0 -772
- package/dist/components/workspace/__tests__/TenantNav.test.js +0 -208
- package/dist/components/workspace/__tests__/WorkspaceAccountMenu.test.js +0 -79
- package/dist/components/workspace/__tests__/WorkspaceShell.test.js +0 -630
- package/dist/components/workspace/__tests__/admin-shell-header-overflow.test.js +0 -25
- package/dist/components/workspace/__tests__/admin-shell-hotkeys.test.js +0 -34
- package/dist/components/workspace/__tests__/admin-shell-mobile.test.js +0 -217
- package/dist/components/workspace/__tests__/admin-shell-mutation-effect-harness.svelte +0 -52
- package/dist/components/workspace/__tests__/admin-shell-mutation-effect-harness.svelte.d.ts +0 -23
- package/dist/components/workspace/__tests__/admin-shell-mutation-effect-harness.svelte.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/admin-shell-page-contracts.test.js +0 -30
- package/dist/components/workspace/__tests__/admin-shell-responsive-state.test.js +0 -184
- package/dist/components/workspace/__tests__/admin-shell-settings.test.js +0 -25
- package/dist/components/workspace/__tests__/admin-shell-state.test.js +0 -286
- package/dist/components/workspace/__tests__/admin-shell-theme-hooks.test.js +0 -36
- package/dist/components/workspace/__tests__/breadcrumbs-helpers.test.js +0 -141
- package/dist/components/workspace/__tests__/context-forwarding-harness.svelte +0 -45
- package/dist/components/workspace/__tests__/context-forwarding-harness.svelte.d.ts +0 -21
- package/dist/components/workspace/__tests__/context-forwarding-harness.svelte.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/define-tools-dock.test.js +0 -1188
- package/dist/components/workspace/__tests__/harness.svelte +0 -25
- package/dist/components/workspace/__tests__/harness.svelte.d.ts +0 -14
- package/dist/components/workspace/__tests__/harness.svelte.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/index.test.js +0 -28
- package/dist/components/workspace/__tests__/legacy-index.test.js +0 -9
- package/dist/components/workspace/__tests__/manifest-nav-helpers.test.js +0 -24
- package/dist/components/workspace/__tests__/manifest-nav.test.js +0 -599
- package/dist/components/workspace/__tests__/nav-helpers.test.js +0 -95
- package/dist/components/workspace/__tests__/render-harness.svelte +0 -66
- package/dist/components/workspace/__tests__/render-harness.svelte.d.ts +0 -32
- package/dist/components/workspace/__tests__/render-harness.svelte.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/render-tools-dock.test.js +0 -260
- package/dist/components/workspace/__tests__/role-shell-bind-harness.svelte +0 -58
- package/dist/components/workspace/__tests__/role-shell-bind-harness.svelte.d.ts +0 -16
- package/dist/components/workspace/__tests__/role-shell-bind-harness.svelte.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/role-shell-switch-harness.svelte +0 -41
- package/dist/components/workspace/__tests__/role-shell-switch-harness.svelte.d.ts +0 -13
- package/dist/components/workspace/__tests__/role-shell-switch-harness.svelte.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/shell-chrome-components.test.js +0 -108
- package/dist/components/workspace/__tests__/system-feed.test.js +0 -327
- package/dist/components/workspace/__tests__/test-icon.svelte +0 -17
- package/dist/components/workspace/__tests__/test-icon.svelte.d.ts +0 -19
- package/dist/components/workspace/__tests__/test-icon.svelte.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/typed-tool-fixture/TypedTool.svelte +0 -38
- package/dist/components/workspace/__tests__/typed-tool-fixture/TypedTool.svelte.d.ts +0 -22
- package/dist/components/workspace/__tests__/typed-tool-fixture/TypedTool.svelte.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/typed-tool-fixture/register-typed-tool.d.ts +0 -66
- package/dist/components/workspace/__tests__/typed-tool-fixture/register-typed-tool.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/typed-tool-fixture/register-typed-tool.js +0 -115
- package/dist/components/workspace/__tests__/typed-tool-fixture/typed-tool-types.d.ts +0 -15
- package/dist/components/workspace/__tests__/typed-tool-fixture/typed-tool-types.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/typed-tool-fixture/typed-tool-types.js +0 -7
- package/dist/components/workspace/__tests__/typed-tool-fixture.test.js +0 -115
- package/dist/components/workspace/__tests__/use-harness-orphan.svelte +0 -9
- package/dist/components/workspace/__tests__/use-harness-orphan.svelte.d.ts +0 -19
- package/dist/components/workspace/__tests__/use-harness-orphan.svelte.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/use-harness.svelte +0 -23
- package/dist/components/workspace/__tests__/use-harness.svelte.d.ts +0 -8
- package/dist/components/workspace/__tests__/use-harness.svelte.d.ts.map +0 -1
- package/dist/components/workspace/__tests__/use-tools-dock.test.js +0 -33
- package/dist/components/workspace/__tests__/workspace-shell-bind-harness.svelte +0 -43
- package/dist/components/workspace/__tests__/workspace-shell-bind-harness.svelte.d.ts +0 -11
- package/dist/components/workspace/__tests__/workspace-shell-bind-harness.svelte.d.ts.map +0 -1
- package/dist/components/workspace/server/__tests__/compose-availability.test.js +0 -383
- package/dist/components/workspace/server/__tests__/typed-context-fixture.d.ts +0 -78
- package/dist/components/workspace/server/__tests__/typed-context-fixture.d.ts.map +0 -1
- package/dist/components/workspace/server/__tests__/typed-context-fixture.js +0 -104
- package/dist/hooks/__tests__/stt-consumer.fixture.svelte +0 -25
- package/dist/hooks/__tests__/stt-consumer.fixture.svelte.d.ts +0 -15
- package/dist/hooks/__tests__/stt-consumer.fixture.svelte.d.ts.map +0 -1
- package/dist/hooks/__tests__/stt-ownership-harness.svelte +0 -42
- package/dist/hooks/__tests__/stt-ownership-harness.svelte.d.ts +0 -20
- package/dist/hooks/__tests__/stt-ownership-harness.svelte.d.ts.map +0 -1
- package/dist/hooks/__tests__/useSTT-ownership.test.js +0 -102
- package/dist/i18n/__tests__/server.spec.js +0 -57
- package/dist/internal/logger.test.js +0 -54
- package/dist/provider-mode.test.js +0 -86
- package/dist/provider-webmcp.test.js +0 -244
- package/dist/state/__tests__/app-state-ai-lifecycle.test.js +0 -240
- package/dist/state/__tests__/warm-clients.test.js +0 -40
- package/dist/web/__tests__/activity-feed-harness.svelte +0 -32
- package/dist/web/__tests__/activity-feed-harness.svelte.d.ts +0 -18
- package/dist/web/__tests__/activity-feed-harness.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/activity-feed.integration.svelte.test.js +0 -190
- package/dist/web/__tests__/activity-feed.svelte.test.js +0 -235
- package/dist/web/__tests__/assistant-dock.integration.svelte.test.js +0 -204
- package/dist/web/__tests__/data-surface-conformance.integration.svelte.test.js +0 -1392
- package/dist/web/__tests__/harness.svelte +0 -25
- package/dist/web/__tests__/harness.svelte.d.ts +0 -15
- package/dist/web/__tests__/harness.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/list-data-surface.fixture.svelte +0 -59
- package/dist/web/__tests__/list-data-surface.fixture.svelte.d.ts +0 -14
- package/dist/web/__tests__/list-data-surface.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/list-data-surface.svelte.test.js +0 -106
- package/dist/web/__tests__/list-data-surface.test.js +0 -651
- package/dist/web/__tests__/list-sort-surface.fixture.svelte +0 -41
- package/dist/web/__tests__/list-sort-surface.fixture.svelte.d.ts +0 -15
- package/dist/web/__tests__/list-sort-surface.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/list-sort-surface.svelte.test.js +0 -59
- package/dist/web/__tests__/live-collection.svelte.test.js +0 -185
- package/dist/web/__tests__/provider-ui-registry.fixture.svelte +0 -43
- package/dist/web/__tests__/provider-ui-registry.fixture.svelte.d.ts +0 -13
- package/dist/web/__tests__/provider-ui-registry.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/provider-ui-registry.test.js +0 -235
- package/dist/web/__tests__/remote-query-harness.svelte +0 -27
- package/dist/web/__tests__/remote-query-harness.svelte.d.ts +0 -11
- package/dist/web/__tests__/remote-query-harness.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/remote-query.svelte.test.js +0 -101
- package/dist/web/__tests__/surfaces.child.fixture.svelte +0 -69
- package/dist/web/__tests__/surfaces.child.fixture.svelte.d.ts +0 -16
- package/dist/web/__tests__/surfaces.child.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/surfaces.fixture.svelte +0 -26
- package/dist/web/__tests__/surfaces.fixture.svelte.d.ts +0 -18
- package/dist/web/__tests__/surfaces.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/surfaces.svelte.test.js +0 -140
- package/dist/web/__tests__/update-available-harness.svelte +0 -46
- package/dist/web/__tests__/update-available-harness.svelte.d.ts +0 -22
- package/dist/web/__tests__/update-available-harness.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/update-available.svelte.test.js +0 -137
- package/dist/web/__tests__/view-intent-provider.fixture.svelte +0 -28
- package/dist/web/__tests__/view-intent-provider.fixture.svelte.d.ts +0 -13
- package/dist/web/__tests__/view-intent-provider.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/view-intent.fixture.svelte +0 -33
- package/dist/web/__tests__/view-intent.fixture.svelte.d.ts +0 -15
- package/dist/web/__tests__/view-intent.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/view-intent.intents.d.ts +0 -14
- package/dist/web/__tests__/view-intent.intents.d.ts.map +0 -1
- package/dist/web/__tests__/view-intent.intents.js +0 -38
- package/dist/web/__tests__/view-intent.svelte.test.js +0 -244
- package/dist/web/__tests__/webmcp-composed.child.fixture.svelte +0 -73
- package/dist/web/__tests__/webmcp-composed.child.fixture.svelte.d.ts +0 -8
- package/dist/web/__tests__/webmcp-composed.child.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/webmcp-composed.fixture.svelte +0 -52
- package/dist/web/__tests__/webmcp-composed.fixture.svelte.d.ts +0 -12
- package/dist/web/__tests__/webmcp-composed.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/webmcp-composed.integration.svelte.test.js +0 -251
- package/dist/web/__tests__/webmcp-effects-reactivity.child.fixture.svelte +0 -16
- package/dist/web/__tests__/webmcp-effects-reactivity.child.fixture.svelte.d.ts +0 -19
- package/dist/web/__tests__/webmcp-effects-reactivity.child.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/webmcp-effects-reactivity.fixture.svelte +0 -11
- package/dist/web/__tests__/webmcp-effects-reactivity.fixture.svelte.d.ts +0 -8
- package/dist/web/__tests__/webmcp-effects-reactivity.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/webmcp-harness-reactive-samename.svelte +0 -20
- package/dist/web/__tests__/webmcp-harness-reactive-samename.svelte.d.ts +0 -7
- package/dist/web/__tests__/webmcp-harness-reactive-samename.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/webmcp-harness-unannotated.svelte +0 -14
- package/dist/web/__tests__/webmcp-harness-unannotated.svelte.d.ts +0 -19
- package/dist/web/__tests__/webmcp-harness-unannotated.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/webmcp-harness.svelte +0 -18
- package/dist/web/__tests__/webmcp-harness.svelte.d.ts +0 -7
- package/dist/web/__tests__/webmcp-harness.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/webmcp-ssr.fixture.svelte +0 -13
- package/dist/web/__tests__/webmcp-ssr.fixture.svelte.d.ts +0 -19
- package/dist/web/__tests__/webmcp-ssr.fixture.svelte.d.ts.map +0 -1
- package/dist/web/__tests__/webmcp-ui.test.js +0 -723
- package/dist/web/__tests__/webmcp.test.js +0 -234
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { createSmrtCollection, } from '@happyvertical/smrt-web';
|
|
2
|
-
import { flushSync, mount, unmount } from 'svelte';
|
|
3
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
-
import Harness from './remote-query-harness.svelte';
|
|
5
|
-
const definition = {
|
|
6
|
-
name: 'remote-query-svelte-products',
|
|
7
|
-
className: 'Product',
|
|
8
|
-
endpoint: '/products',
|
|
9
|
-
idField: 'id',
|
|
10
|
-
actions: ['list'],
|
|
11
|
-
fields: { name: { type: 'text' } },
|
|
12
|
-
};
|
|
13
|
-
const request = {
|
|
14
|
-
version: 1,
|
|
15
|
-
requestId: 'svelte-request',
|
|
16
|
-
mode: 'rows',
|
|
17
|
-
page: { kind: 'offset', offset: 0, limit: 10 },
|
|
18
|
-
};
|
|
19
|
-
function envelope(received, name) {
|
|
20
|
-
return {
|
|
21
|
-
version: 1,
|
|
22
|
-
requestId: received.requestId,
|
|
23
|
-
queryFingerprint: 'dq1_svelte_products',
|
|
24
|
-
identityField: 'id',
|
|
25
|
-
rows: [{ id: name, name }],
|
|
26
|
-
page: { kind: 'offset', offset: 0, limit: 10, hasMore: false },
|
|
27
|
-
total: { kind: 'exact', value: 1 },
|
|
28
|
-
freshness: { state: 'fresh' },
|
|
29
|
-
warnings: [],
|
|
30
|
-
truncated: false,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function mountView(collection, transport) {
|
|
34
|
-
const target = document.createElement('div');
|
|
35
|
-
document.body.appendChild(target);
|
|
36
|
-
let view = undefined;
|
|
37
|
-
const component = mount(Harness, {
|
|
38
|
-
target,
|
|
39
|
-
props: {
|
|
40
|
-
collection: collection,
|
|
41
|
-
transport,
|
|
42
|
-
onReady: (next) => {
|
|
43
|
-
view = next;
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
target,
|
|
49
|
-
view,
|
|
50
|
-
teardown: () => {
|
|
51
|
-
unmount(component);
|
|
52
|
-
target.remove();
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
describe('remoteQuery', () => {
|
|
57
|
-
it('renders request and rows reactively through the Svelte binding', async () => {
|
|
58
|
-
const collection = createSmrtCollection(definition, {
|
|
59
|
-
fetchers: { list: async () => [], create: async () => ({}) },
|
|
60
|
-
});
|
|
61
|
-
const mounted = mountView(collection, {
|
|
62
|
-
query: async (received) => envelope(received, 'Ada'),
|
|
63
|
-
});
|
|
64
|
-
await mounted.view.execute(request);
|
|
65
|
-
flushSync();
|
|
66
|
-
expect(mounted.target.textContent).toContain('svelte-request:Ada');
|
|
67
|
-
expect(mounted.view.result?.rows).toEqual([{ id: 'Ada', name: 'Ada' }]);
|
|
68
|
-
mounted.teardown();
|
|
69
|
-
await collection.cleanup();
|
|
70
|
-
});
|
|
71
|
-
it('disposes an in-flight refresh and live subscription when unmounted', async () => {
|
|
72
|
-
let calls = 0;
|
|
73
|
-
let unsubscribed = false;
|
|
74
|
-
const collection = createSmrtCollection(definition, {
|
|
75
|
-
fetchers: { list: async () => [], create: async () => ({}) },
|
|
76
|
-
});
|
|
77
|
-
const mounted = mountView(collection, {
|
|
78
|
-
query: async (received, options) => {
|
|
79
|
-
calls += 1;
|
|
80
|
-
if (calls === 1)
|
|
81
|
-
return envelope(received, 'initial');
|
|
82
|
-
return await new Promise((_resolve, reject) => {
|
|
83
|
-
options?.signal?.addEventListener('abort', () => reject(options.signal?.reason), { once: true });
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
subscribe: () => ({
|
|
87
|
-
unsubscribe: () => {
|
|
88
|
-
unsubscribed = true;
|
|
89
|
-
},
|
|
90
|
-
}),
|
|
91
|
-
});
|
|
92
|
-
await mounted.view.execute(request);
|
|
93
|
-
mounted.view.subscribeLive();
|
|
94
|
-
const refresh = mounted.view.refresh();
|
|
95
|
-
await vi.waitFor(() => expect(calls).toBe(2));
|
|
96
|
-
mounted.teardown();
|
|
97
|
-
await expect(refresh).rejects.toMatchObject({ name: 'AbortError' });
|
|
98
|
-
expect(unsubscribed).toBe(true);
|
|
99
|
-
await collection.cleanup();
|
|
100
|
-
});
|
|
101
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { useLinkSurface } from '../link-surface.svelte.js';
|
|
3
|
-
import { useListSurface } from '../list-surface.svelte.js';
|
|
4
|
-
import { useStepSurface } from '../step-surface.svelte.js';
|
|
5
|
-
import { tryUseWebMcpUi } from '../webmcp-ui-context.js';
|
|
6
|
-
|
|
7
|
-
let {
|
|
8
|
-
rows,
|
|
9
|
-
step = $bindable('town'),
|
|
10
|
-
navigate,
|
|
11
|
-
onContext,
|
|
12
|
-
create,
|
|
13
|
-
}: {
|
|
14
|
-
rows: Array<{ id: string; title: string; status: string; token: string }>;
|
|
15
|
-
step?: string;
|
|
16
|
-
navigate: (href: string) => void;
|
|
17
|
-
onContext?: (enabled: boolean) => void;
|
|
18
|
-
create: () => void;
|
|
19
|
-
} = $props();
|
|
20
|
-
|
|
21
|
-
onContext?.(tryUseWebMcpUi() !== null);
|
|
22
|
-
|
|
23
|
-
useListSurface(() => ({
|
|
24
|
-
surfaceId: 'articles-ui',
|
|
25
|
-
label: 'Articles',
|
|
26
|
-
description: 'Articles on this page',
|
|
27
|
-
columns: [
|
|
28
|
-
{ id: 'id', label: 'ID', rowKey: true },
|
|
29
|
-
{ id: 'title', label: 'Title', searchable: true },
|
|
30
|
-
{ id: 'status', label: 'Status', status: true },
|
|
31
|
-
],
|
|
32
|
-
rows,
|
|
33
|
-
maxRows: 2,
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
useLinkSurface(() => ({
|
|
37
|
-
surfaceId: 'site-sections-ui',
|
|
38
|
-
label: 'Site sections',
|
|
39
|
-
description: 'Pages in this site',
|
|
40
|
-
links: [
|
|
41
|
-
{ id: 'events', label: 'Events', href: '/s/events' },
|
|
42
|
-
{ id: 'articles', label: 'Articles', href: '/s/articles' },
|
|
43
|
-
],
|
|
44
|
-
navigate,
|
|
45
|
-
state: { active: 'articles' },
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
useStepSurface(() => ({
|
|
49
|
-
surfaceId: 'new-site-steps',
|
|
50
|
-
label: 'New site',
|
|
51
|
-
description: 'Start a new town site',
|
|
52
|
-
steps: [
|
|
53
|
-
{ id: 'town', label: 'Your town', complete: step !== 'town' },
|
|
54
|
-
{ id: 'features', label: 'Features' },
|
|
55
|
-
],
|
|
56
|
-
current: step,
|
|
57
|
-
next: () => {
|
|
58
|
-
step = 'features';
|
|
59
|
-
},
|
|
60
|
-
nextWrites: step === 'features',
|
|
61
|
-
showNext: () => document.getElementById('create')?.focus(),
|
|
62
|
-
back: () => {
|
|
63
|
-
step = 'town';
|
|
64
|
-
},
|
|
65
|
-
}));
|
|
66
|
-
</script>
|
|
67
|
-
|
|
68
|
-
<p data-testid="step">{step}</p>
|
|
69
|
-
<button id="create" type="button" onclick={create}>Create site</button>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
type $$ComponentProps = {
|
|
2
|
-
rows: Array<{
|
|
3
|
-
id: string;
|
|
4
|
-
title: string;
|
|
5
|
-
status: string;
|
|
6
|
-
token: string;
|
|
7
|
-
}>;
|
|
8
|
-
step?: string;
|
|
9
|
-
navigate: (href: string) => void;
|
|
10
|
-
onContext?: (enabled: boolean) => void;
|
|
11
|
-
create: () => void;
|
|
12
|
-
};
|
|
13
|
-
declare const Surfaces: import("svelte").Component<$$ComponentProps, {}, "step">;
|
|
14
|
-
type Surfaces = ReturnType<typeof Surfaces>;
|
|
15
|
-
export default Surfaces;
|
|
16
|
-
//# sourceMappingURL=surfaces.child.fixture.svelte.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"surfaces.child.fixture.svelte.d.ts","sourceRoot":"","sources":["../../../src/web/__tests__/surfaces.child.fixture.svelte.ts"],"names":[],"mappings":"AAQC,KAAK,gBAAgB,GAAI;IACxB,IAAI,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAmEF,QAAA,MAAM,QAAQ,0DAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { DataSurfaceRegistry } from '@happyvertical/smrt-ui/data';
|
|
3
|
-
import Provider from '../../Provider.svelte';
|
|
4
|
-
import Child from './surfaces.child.fixture.svelte';
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
dataSurfaceRegistry,
|
|
8
|
-
withProvider = true,
|
|
9
|
-
...childProps
|
|
10
|
-
}: {
|
|
11
|
-
dataSurfaceRegistry: DataSurfaceRegistry;
|
|
12
|
-
withProvider?: boolean;
|
|
13
|
-
rows: Array<{ id: string; title: string; status: string; token: string }>;
|
|
14
|
-
navigate: (href: string) => void;
|
|
15
|
-
onContext?: (enabled: boolean) => void;
|
|
16
|
-
create: () => void;
|
|
17
|
-
} = $props();
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
{#if withProvider}
|
|
21
|
-
<Provider webmcp={{ ui: { dataSurfaceRegistry } }}>
|
|
22
|
-
<Child {...childProps} />
|
|
23
|
-
</Provider>
|
|
24
|
-
{:else}
|
|
25
|
-
<Child {...childProps} />
|
|
26
|
-
{/if}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { DataSurfaceRegistry } from '@happyvertical/smrt-ui/data';
|
|
2
|
-
type $$ComponentProps = {
|
|
3
|
-
dataSurfaceRegistry: DataSurfaceRegistry;
|
|
4
|
-
withProvider?: boolean;
|
|
5
|
-
rows: Array<{
|
|
6
|
-
id: string;
|
|
7
|
-
title: string;
|
|
8
|
-
status: string;
|
|
9
|
-
token: string;
|
|
10
|
-
}>;
|
|
11
|
-
navigate: (href: string) => void;
|
|
12
|
-
onContext?: (enabled: boolean) => void;
|
|
13
|
-
create: () => void;
|
|
14
|
-
};
|
|
15
|
-
declare const Surfaces: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
16
|
-
type Surfaces = ReturnType<typeof Surfaces>;
|
|
17
|
-
export default Surfaces;
|
|
18
|
-
//# sourceMappingURL=surfaces.fixture.svelte.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"surfaces.fixture.svelte.d.ts","sourceRoot":"","sources":["../../../src/web/__tests__/surfaces.fixture.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAItE,KAAK,gBAAgB,GAAI;IACxB,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1E,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAuBF,QAAA,MAAM,QAAQ,sDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { createDataSurfaceRegistry } from '@happyvertical/smrt-ui/data';
|
|
2
|
-
import { render, screen } from '@testing-library/svelte';
|
|
3
|
-
import { tick } from 'svelte';
|
|
4
|
-
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
-
import Fixture from './surfaces.fixture.svelte';
|
|
6
|
-
const rows = [
|
|
7
|
-
{
|
|
8
|
-
id: 'a1',
|
|
9
|
-
title: 'Council approves budget',
|
|
10
|
-
status: 'published',
|
|
11
|
-
token: 's3cret',
|
|
12
|
-
},
|
|
13
|
-
{ id: 'a2', title: 'Café opens downtown', status: 'draft', token: 's3cret' },
|
|
14
|
-
{
|
|
15
|
-
id: 'a3',
|
|
16
|
-
title: 'Council meeting moved',
|
|
17
|
-
status: 'review',
|
|
18
|
-
token: 's3cret',
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
let sequence = 0;
|
|
22
|
-
function command(identity, controlId, expectedRevision, payload) {
|
|
23
|
-
sequence += 1;
|
|
24
|
-
return {
|
|
25
|
-
version: 1,
|
|
26
|
-
commandId: `cmd-${sequence}`,
|
|
27
|
-
identity,
|
|
28
|
-
expectedRevision,
|
|
29
|
-
controlId,
|
|
30
|
-
...(payload === undefined ? {} : { payload: payload }),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
afterEach(() => {
|
|
34
|
-
delete document.modelContext;
|
|
35
|
-
});
|
|
36
|
-
describe('surface hooks on the Provider registry', () => {
|
|
37
|
-
it('tryUseWebMcpUi is null without a Provider and the hooks register nothing', () => {
|
|
38
|
-
const registry = createDataSurfaceRegistry();
|
|
39
|
-
const onContext = vi.fn();
|
|
40
|
-
render(Fixture, {
|
|
41
|
-
props: {
|
|
42
|
-
dataSurfaceRegistry: registry,
|
|
43
|
-
withProvider: false,
|
|
44
|
-
rows,
|
|
45
|
-
navigate: vi.fn(),
|
|
46
|
-
onContext,
|
|
47
|
-
create: vi.fn(),
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
expect(onContext).toHaveBeenCalledWith(false);
|
|
51
|
-
expect(registry.list()).toEqual([]);
|
|
52
|
-
});
|
|
53
|
-
it('useListSurface publishes projected rows and finds rows by title across all rows', async () => {
|
|
54
|
-
const registry = createDataSurfaceRegistry();
|
|
55
|
-
const onContext = vi.fn();
|
|
56
|
-
const view = render(Fixture, {
|
|
57
|
-
props: {
|
|
58
|
-
dataSurfaceRegistry: registry,
|
|
59
|
-
rows,
|
|
60
|
-
navigate: vi.fn(),
|
|
61
|
-
onContext,
|
|
62
|
-
create: vi.fn(),
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
await tick();
|
|
66
|
-
expect(onContext).toHaveBeenCalledWith(true);
|
|
67
|
-
const identity = { surfaceId: 'articles-ui', kind: 'list' };
|
|
68
|
-
const before = registry.inspect(identity);
|
|
69
|
-
expect(before?.state.rows).toEqual([
|
|
70
|
-
{ id: 'a1', title: 'Council approves budget', status: 'published' },
|
|
71
|
-
{ id: 'a2', title: 'Café opens downtown', status: 'draft' },
|
|
72
|
-
]);
|
|
73
|
-
expect(before?.state.rowsTruncated).toBe(true);
|
|
74
|
-
expect(JSON.stringify(before?.state)).not.toContain('s3cret');
|
|
75
|
-
expect(before?.descriptor.query.searchableColumnIds).toEqual(['title']);
|
|
76
|
-
const found = await registry.execute(command(identity, 'find', before?.revision ?? 0, { text: 'MEETING' }));
|
|
77
|
-
expect(found.ok).toBe(true);
|
|
78
|
-
const after = registry.inspect(identity);
|
|
79
|
-
expect(after?.state.rows).toEqual([
|
|
80
|
-
{ id: 'a3', title: 'Council meeting moved', status: 'review' },
|
|
81
|
-
]);
|
|
82
|
-
expect(after?.state.find).toEqual({ text: 'MEETING', matches: 1 });
|
|
83
|
-
const accent = await registry.execute(command(identity, 'find', after?.revision ?? 0, 'cafe'));
|
|
84
|
-
expect(accent.ok).toBe(true);
|
|
85
|
-
expect(registry.inspect(identity)?.state.rows).toEqual([
|
|
86
|
-
{ id: 'a2', title: 'Café opens downtown', status: 'draft' },
|
|
87
|
-
]);
|
|
88
|
-
const cleared = await registry.execute(command(identity, 'find', registry.inspect(identity)?.revision ?? 0, {
|
|
89
|
-
text: '',
|
|
90
|
-
}));
|
|
91
|
-
expect(cleared.ok).toBe(true);
|
|
92
|
-
expect(registry.inspect(identity)?.state.find).toBeUndefined();
|
|
93
|
-
// Table commands stay refused: the page's own controls own its state.
|
|
94
|
-
const refused = await registry.execute(command(identity, 'set-search', registry.inspect(identity)?.revision ?? 0, {
|
|
95
|
-
search: 'x',
|
|
96
|
-
}));
|
|
97
|
-
expect(refused.ok).toBe(false);
|
|
98
|
-
view.unmount();
|
|
99
|
-
expect(registry.list()).toEqual([]);
|
|
100
|
-
});
|
|
101
|
-
it('useLinkSurface navigates to a published link', async () => {
|
|
102
|
-
const registry = createDataSurfaceRegistry();
|
|
103
|
-
const navigate = vi.fn();
|
|
104
|
-
render(Fixture, {
|
|
105
|
-
props: { dataSurfaceRegistry: registry, rows, navigate, create: vi.fn() },
|
|
106
|
-
});
|
|
107
|
-
await tick();
|
|
108
|
-
const identity = { surfaceId: 'site-sections-ui', kind: 'list' };
|
|
109
|
-
const snapshot = registry.inspect(identity);
|
|
110
|
-
expect(snapshot?.state.active).toBe('articles');
|
|
111
|
-
const result = await registry.execute(command(identity, 'open', snapshot?.revision ?? 0, { target: 'events' }));
|
|
112
|
-
expect(result.ok).toBe(true);
|
|
113
|
-
expect(navigate).toHaveBeenCalledWith('/s/events');
|
|
114
|
-
});
|
|
115
|
-
it('useStepSurface moves a wizard forward and leaves the writing step to the person', async () => {
|
|
116
|
-
const registry = createDataSurfaceRegistry();
|
|
117
|
-
const create = vi.fn();
|
|
118
|
-
render(Fixture, {
|
|
119
|
-
props: { dataSurfaceRegistry: registry, rows, navigate: vi.fn(), create },
|
|
120
|
-
});
|
|
121
|
-
await tick();
|
|
122
|
-
const identity = { surfaceId: 'new-site-steps', kind: 'custom' };
|
|
123
|
-
const first = registry.inspect(identity);
|
|
124
|
-
expect(first?.state.current).toBe('town');
|
|
125
|
-
expect((await registry.execute(command(identity, 'next', first?.revision ?? 0)))
|
|
126
|
-
.ok).toBe(true);
|
|
127
|
-
await tick();
|
|
128
|
-
expect(screen.getByTestId('step')).toHaveTextContent('features');
|
|
129
|
-
const second = registry.inspect(identity);
|
|
130
|
-
expect(second?.state).toMatchObject({
|
|
131
|
-
current: 'features',
|
|
132
|
-
nextWrites: true,
|
|
133
|
-
});
|
|
134
|
-
expect((await registry.execute(command(identity, 'next', second?.revision ?? 0)))
|
|
135
|
-
.ok).toBe(true);
|
|
136
|
-
expect(create).not.toHaveBeenCalled();
|
|
137
|
-
expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Create site' }));
|
|
138
|
-
expect(registry.inspect(identity)?.state.awaitingPerson).toBe(true);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* Test harness — invokes useUpdateAvailable() inside a component init scope so
|
|
4
|
-
* its `$effect`s (the state subscription + the `updated` watcher) wire up
|
|
5
|
-
* correctly, then hands the reactive view back to the test via `onReady`.
|
|
6
|
-
*
|
|
7
|
-
* The bundle-signal source (`updated`) is a genuinely REACTIVE `$state` owned by
|
|
8
|
-
* this harness, mutated by the test through the `setUpdated` control handed back
|
|
9
|
-
* via `onReady`. This mirrors production, where the caller passes
|
|
10
|
-
* `() => updated.current` over SvelteKit's reactive `updated` store — a plain
|
|
11
|
-
* closure variable would not be tracked by the rune's `$effect`.
|
|
12
|
-
*/
|
|
13
|
-
import type { UpdateState } from '@happyvertical/smrt-web';
|
|
14
|
-
import {
|
|
15
|
-
type UpdateAvailableView,
|
|
16
|
-
useUpdateAvailable,
|
|
17
|
-
} from '../update-available.svelte.js';
|
|
18
|
-
|
|
19
|
-
interface Props {
|
|
20
|
-
state: UpdateState;
|
|
21
|
-
initialUpdated?: boolean;
|
|
22
|
-
onReady: (
|
|
23
|
-
view: UpdateAvailableView,
|
|
24
|
-
setUpdated: (v: boolean) => void,
|
|
25
|
-
) => void;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const props: Props = $props();
|
|
29
|
-
|
|
30
|
-
// A reactive bundle-updated source the test drives via setUpdated. Seeds from
|
|
31
|
-
// the prop once at init (intentional snapshot).
|
|
32
|
-
// svelte-ignore state_referenced_locally
|
|
33
|
-
let updated = $state(props.initialUpdated ?? false);
|
|
34
|
-
|
|
35
|
-
// The harness intentionally snapshots the props during setup.
|
|
36
|
-
// svelte-ignore state_referenced_locally
|
|
37
|
-
const view = useUpdateAvailable({
|
|
38
|
-
state: props.state,
|
|
39
|
-
updated: () => updated,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// svelte-ignore state_referenced_locally
|
|
43
|
-
props.onReady(view, (v: boolean) => {
|
|
44
|
-
updated = v;
|
|
45
|
-
});
|
|
46
|
-
</script>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test harness — invokes useUpdateAvailable() inside a component init scope so
|
|
3
|
-
* its `$effect`s (the state subscription + the `updated` watcher) wire up
|
|
4
|
-
* correctly, then hands the reactive view back to the test via `onReady`.
|
|
5
|
-
*
|
|
6
|
-
* The bundle-signal source (`updated`) is a genuinely REACTIVE `$state` owned by
|
|
7
|
-
* this harness, mutated by the test through the `setUpdated` control handed back
|
|
8
|
-
* via `onReady`. This mirrors production, where the caller passes
|
|
9
|
-
* `() => updated.current` over SvelteKit's reactive `updated` store — a plain
|
|
10
|
-
* closure variable would not be tracked by the rune's `$effect`.
|
|
11
|
-
*/
|
|
12
|
-
import type { UpdateState } from '@happyvertical/smrt-web';
|
|
13
|
-
import { type UpdateAvailableView } from '../update-available.svelte.js';
|
|
14
|
-
interface Props {
|
|
15
|
-
state: UpdateState;
|
|
16
|
-
initialUpdated?: boolean;
|
|
17
|
-
onReady: (view: UpdateAvailableView, setUpdated: (v: boolean) => void) => void;
|
|
18
|
-
}
|
|
19
|
-
declare const UpdateAvailableHarness: import("svelte").Component<Props, {}, "">;
|
|
20
|
-
type UpdateAvailableHarness = ReturnType<typeof UpdateAvailableHarness>;
|
|
21
|
-
export default UpdateAvailableHarness;
|
|
22
|
-
//# sourceMappingURL=update-available-harness.svelte.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-available-harness.svelte.d.ts","sourceRoot":"","sources":["../../../src/web/__tests__/update-available-harness.svelte.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,+BAA+B,CAAC;AAGvC,UAAU,KAAK;IACb,KAAK,EAAE,WAAW,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,CACP,IAAI,EAAE,mBAAmB,EACzB,UAAU,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,KAC7B,IAAI,CAAC;CACX;AA6BD,QAAA,MAAM,sBAAsB,2CAAwC,CAAC;AACrE,KAAK,sBAAsB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACxE,eAAe,sBAAsB,CAAC"}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Behavior tests for the Svelte 5 `useUpdateAvailable` binding (#1764).
|
|
3
|
-
*
|
|
4
|
-
* The binding wires SvelteKit's `updated` boolean (the bundle signal) into
|
|
5
|
-
* smrt-web's framework-free `UpdateState`, and surfaces both signals reactively.
|
|
6
|
-
* Here the `UpdateState` is a small in-memory stub (a real one would open
|
|
7
|
-
* IndexedDB; the RUNE's reactivity — subscription sync + `updated` watcher — is
|
|
8
|
-
* what these tests pin), and the binding runs inside a host component so its
|
|
9
|
-
* `$effect`s have a genuine component-init scope, matching this package's other
|
|
10
|
-
* runes-composable tests.
|
|
11
|
-
*
|
|
12
|
-
* NOTE: Svelte-package tests may not run under the local Darwin/vite8 toolchain
|
|
13
|
-
* (CI is the gate). The binding is additionally covered by typecheck.
|
|
14
|
-
*/
|
|
15
|
-
import { flushSync, mount, unmount } from 'svelte';
|
|
16
|
-
import { afterEach, describe, expect, it } from 'vitest';
|
|
17
|
-
import Harness from './update-available-harness.svelte';
|
|
18
|
-
/**
|
|
19
|
-
* A minimal in-memory UpdateState: drives `bundle`/`contract` and fans out to
|
|
20
|
-
* subscribers, exactly like the real primitive but with no IndexedDB. Lets a
|
|
21
|
-
* test flip the contract signal and push the bundle signal deterministically.
|
|
22
|
-
*/
|
|
23
|
-
function makeStubState() {
|
|
24
|
-
let bundle = false;
|
|
25
|
-
let contract = false;
|
|
26
|
-
const subs = new Set();
|
|
27
|
-
const snapshot = () => ({
|
|
28
|
-
bundle,
|
|
29
|
-
contract,
|
|
30
|
-
updateAvailable: bundle || contract,
|
|
31
|
-
});
|
|
32
|
-
const notify = () => {
|
|
33
|
-
for (const cb of [...subs])
|
|
34
|
-
cb(snapshot());
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
get: snapshot,
|
|
38
|
-
subscribe(cb) {
|
|
39
|
-
subs.add(cb);
|
|
40
|
-
cb(snapshot());
|
|
41
|
-
return () => {
|
|
42
|
-
subs.delete(cb);
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
notifyBundleUpdated() {
|
|
46
|
-
if (bundle)
|
|
47
|
-
return;
|
|
48
|
-
bundle = true;
|
|
49
|
-
notify();
|
|
50
|
-
},
|
|
51
|
-
notifyContractUpdated() {
|
|
52
|
-
if (contract)
|
|
53
|
-
return;
|
|
54
|
-
contract = true;
|
|
55
|
-
notify();
|
|
56
|
-
},
|
|
57
|
-
ready: Promise.resolve(),
|
|
58
|
-
dispose() {
|
|
59
|
-
subs.clear();
|
|
60
|
-
},
|
|
61
|
-
fireContract() {
|
|
62
|
-
if (contract)
|
|
63
|
-
return;
|
|
64
|
-
contract = true;
|
|
65
|
-
notify();
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const mounted = [];
|
|
70
|
-
function render(state, initialUpdated = false) {
|
|
71
|
-
let view;
|
|
72
|
-
let setUpdated;
|
|
73
|
-
const target = document.createElement('div');
|
|
74
|
-
const component = mount(Harness, {
|
|
75
|
-
target,
|
|
76
|
-
props: {
|
|
77
|
-
state,
|
|
78
|
-
initialUpdated,
|
|
79
|
-
onReady: (v, set) => {
|
|
80
|
-
view = v;
|
|
81
|
-
setUpdated = set;
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
mounted.push(component);
|
|
86
|
-
flushSync();
|
|
87
|
-
return { view, setUpdated };
|
|
88
|
-
}
|
|
89
|
-
afterEach(() => {
|
|
90
|
-
for (const c of mounted) {
|
|
91
|
-
void unmount(c);
|
|
92
|
-
}
|
|
93
|
-
mounted.length = 0;
|
|
94
|
-
});
|
|
95
|
-
describe('useUpdateAvailable (#1764)', () => {
|
|
96
|
-
it('starts with no update available and reflects the initial state', () => {
|
|
97
|
-
const state = makeStubState();
|
|
98
|
-
const { view } = render(state);
|
|
99
|
-
expect(view.bundle).toBe(false);
|
|
100
|
-
expect(view.contract).toBe(false);
|
|
101
|
-
expect(view.updateAvailable).toBe(false);
|
|
102
|
-
});
|
|
103
|
-
it('reacts to the CONTRACT signal fired by the primitive', () => {
|
|
104
|
-
const state = makeStubState();
|
|
105
|
-
const { view } = render(state);
|
|
106
|
-
state.fireContract();
|
|
107
|
-
flushSync();
|
|
108
|
-
expect(view.contract).toBe(true);
|
|
109
|
-
expect(view.updateAvailable).toBe(true);
|
|
110
|
-
expect(view.bundle).toBe(false);
|
|
111
|
-
});
|
|
112
|
-
it('pushes the BUNDLE signal when SvelteKit `updated` flips true', () => {
|
|
113
|
-
const state = makeStubState();
|
|
114
|
-
// `setUpdated` mutates a REACTIVE $state in the harness (mirrors SvelteKit's
|
|
115
|
-
// reactive `updated` store) — a plain closure variable would not be tracked
|
|
116
|
-
// by the rune's $effect, so the bundle signal would never fire.
|
|
117
|
-
const { view, setUpdated } = render(state);
|
|
118
|
-
expect(view.updateAvailable).toBe(false);
|
|
119
|
-
// Simulate SvelteKit detecting a new deployment.
|
|
120
|
-
setUpdated(true);
|
|
121
|
-
flushSync();
|
|
122
|
-
expect(view.bundle).toBe(true);
|
|
123
|
-
expect(view.updateAvailable).toBe(true);
|
|
124
|
-
});
|
|
125
|
-
it('updateAvailable is the union: either signal alone makes it true', () => {
|
|
126
|
-
const stateA = makeStubState();
|
|
127
|
-
const a = render(stateA);
|
|
128
|
-
stateA.fireContract();
|
|
129
|
-
flushSync();
|
|
130
|
-
expect(a.view.updateAvailable).toBe(true);
|
|
131
|
-
const stateB = makeStubState();
|
|
132
|
-
const b = render(stateB);
|
|
133
|
-
b.setUpdated(true);
|
|
134
|
-
flushSync();
|
|
135
|
-
expect(b.view.updateAvailable).toBe(true);
|
|
136
|
-
});
|
|
137
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { ControlInteractionRegistry } from '@happyvertical/smrt-ui/forms';
|
|
3
|
-
import type { ViewIntent } from '@happyvertical/smrt-web';
|
|
4
|
-
import Provider from '../../Provider.svelte';
|
|
5
|
-
import type { ViewIntentIdentity } from '../view-intent.svelte.js';
|
|
6
|
-
import ViewIntentFixture from './view-intent.fixture.svelte';
|
|
7
|
-
|
|
8
|
-
let {
|
|
9
|
-
intent,
|
|
10
|
-
identity,
|
|
11
|
-
providerRegistry,
|
|
12
|
-
effects,
|
|
13
|
-
}: {
|
|
14
|
-
intent: ViewIntent;
|
|
15
|
-
identity: ViewIntentIdentity;
|
|
16
|
-
providerRegistry: ControlInteractionRegistry;
|
|
17
|
-
effects?: readonly ('read' | 'write' | 'destructive')[];
|
|
18
|
-
} = $props();
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<Provider
|
|
22
|
-
webmcp={{
|
|
23
|
-
...(effects ? { effects } : {}),
|
|
24
|
-
ui: { controlRegistry: providerRegistry },
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
<ViewIntentFixture {intent} {identity} />
|
|
28
|
-
</Provider>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ControlInteractionRegistry } from '@happyvertical/smrt-ui/forms';
|
|
2
|
-
import type { ViewIntent } from '@happyvertical/smrt-web';
|
|
3
|
-
import type { ViewIntentIdentity } from '../view-intent.svelte.js';
|
|
4
|
-
type $$ComponentProps = {
|
|
5
|
-
intent: ViewIntent;
|
|
6
|
-
identity: ViewIntentIdentity;
|
|
7
|
-
providerRegistry: ControlInteractionRegistry;
|
|
8
|
-
effects?: readonly ('read' | 'write' | 'destructive')[];
|
|
9
|
-
};
|
|
10
|
-
declare const ViewIntentProvider: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
11
|
-
type ViewIntentProvider = ReturnType<typeof ViewIntentProvider>;
|
|
12
|
-
export default ViewIntentProvider;
|
|
13
|
-
//# sourceMappingURL=view-intent-provider.fixture.svelte.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view-intent-provider.fixture.svelte.d.ts","sourceRoot":"","sources":["../../../src/web/__tests__/view-intent-provider.fixture.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,KAAK,gBAAgB,GAAI;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,gBAAgB,EAAE,0BAA0B,CAAC;IAC7C,OAAO,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC,EAAE,CAAC;CACzD,CAAC;AAyBF,QAAA,MAAM,kBAAkB,sDAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { DataSurfaceRegistry } from '@happyvertical/smrt-ui/data';
|
|
3
|
-
import type { ControlInteractionRegistry } from '@happyvertical/smrt-ui/forms';
|
|
4
|
-
import type { ViewIntent } from '@happyvertical/smrt-web';
|
|
5
|
-
import type {
|
|
6
|
-
UseViewIntentOptions,
|
|
7
|
-
ViewIntentIdentity,
|
|
8
|
-
} from '../view-intent.svelte.js';
|
|
9
|
-
import { useViewIntent } from '../view-intent.svelte.js';
|
|
10
|
-
|
|
11
|
-
let {
|
|
12
|
-
intent,
|
|
13
|
-
identity,
|
|
14
|
-
controlRegistry,
|
|
15
|
-
dataSurfaceRegistry,
|
|
16
|
-
effects,
|
|
17
|
-
}: {
|
|
18
|
-
intent: ViewIntent;
|
|
19
|
-
identity: ViewIntentIdentity;
|
|
20
|
-
controlRegistry?: ControlInteractionRegistry;
|
|
21
|
-
dataSurfaceRegistry?: DataSurfaceRegistry;
|
|
22
|
-
effects?: UseViewIntentOptions['effects'];
|
|
23
|
-
} = $props();
|
|
24
|
-
|
|
25
|
-
useViewIntent(intent, {
|
|
26
|
-
identity,
|
|
27
|
-
...(controlRegistry ? { controlRegistry } : {}),
|
|
28
|
-
...(dataSurfaceRegistry ? { dataSurfaceRegistry } : {}),
|
|
29
|
-
...(effects ? { effects } : {}),
|
|
30
|
-
});
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
<span>{intent.id}</span>
|