xmlui 0.10.13 → 0.10.15
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/dist/lib/{index-Db5iQkFp.mjs → index-axjeT2uJ.mjs} +1626 -1080
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-B9LtmFJG.mjs → initMock-BoTWMs19.mjs} +1 -1
- package/dist/lib/language-server-web-worker.mjs +1 -1
- package/dist/lib/language-server.mjs +1 -1
- package/dist/lib/{metadata-utils-D90qqMGc.mjs → metadata-utils-CtY0QcvH.mjs} +2 -1
- package/dist/lib/{server-common-lmBDLpUh.mjs → server-common-Cine5nRR.mjs} +1 -1
- package/dist/lib/xmlui.d.ts +99 -6
- package/dist/lib/xmlui.mjs +78 -42
- package/dist/metadata/{collectedComponentMetadata-BN8eg9Gr.mjs → collectedComponentMetadata-CQywuPDB.mjs} +17448 -16984
- package/dist/metadata/{initMock-J7pN8owj.mjs → initMock-Bi5kF5Af.mjs} +1 -1
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +3 -3
- package/dist/scripts/bin/build-lib.js +21 -13
- package/dist/scripts/bin/viteConfig.js +3 -1
- package/dist/scripts/package.json +2 -3
- package/dist/scripts/src/abstractions/scripting/Token.js +2 -0
- package/dist/scripts/src/abstractions/scripting/TryScope.js +2 -0
- package/dist/scripts/src/abstractions/scripting/modules.js +2 -0
- package/dist/scripts/src/components/APICall/APICall.spec.js +910 -0
- package/dist/scripts/src/components/Accordion/Accordion.spec.js +969 -0
- package/dist/scripts/src/components/Animation/Animation.js +50 -0
- package/dist/scripts/src/components/App/App.spec.js +219 -0
- package/dist/scripts/src/components/AppHeader/AppHeader.spec.js +169 -0
- package/dist/scripts/src/components/AppState/AppState.js +32 -2
- package/dist/scripts/src/components/AppState/AppState.spec.js +268 -0
- package/dist/scripts/src/components/AppState/AppStateNative.js +27 -3
- package/dist/scripts/src/components/AutoComplete/AutoComplete.spec.js +383 -0
- package/dist/scripts/src/components/Avatar/Avatar.spec.js +1543 -0
- package/dist/scripts/src/components/Backdrop/Backdrop.spec.js +131 -0
- package/dist/scripts/src/components/Badge/Badge.spec.js +2214 -0
- package/dist/scripts/src/components/Bookmark/Bookmark.spec.js +230 -0
- package/dist/scripts/src/components/Breakout/Breakout.spec.js +56 -0
- package/dist/scripts/src/components/Button/Button-style.spec.js +274 -0
- package/dist/scripts/src/components/Button/Button.js +5 -1
- package/dist/scripts/src/components/Button/Button.spec.js +454 -0
- package/dist/scripts/src/components/Card/Card.spec.js +150 -0
- package/dist/scripts/src/components/Carousel/Carousel.spec.js +343 -0
- package/dist/scripts/src/components/Carousel/CarouselNative.js +2 -2
- package/dist/scripts/src/components/ChangeListener/ChangeListener.spec.js +169 -0
- package/dist/scripts/src/components/Charts/AreaChart/AreaChart.spec.js +999 -0
- package/dist/scripts/src/components/Charts/BarChart/BarChart.spec.js +597 -0
- package/dist/scripts/src/components/Charts/DonutChart/DonutChart.spec.js +608 -0
- package/dist/scripts/src/components/Charts/LabelList/LabelList.spec.js +539 -0
- package/dist/scripts/src/components/Charts/Legend/Legend.spec.js +558 -0
- package/dist/scripts/src/components/Charts/LineChart/LineChart.spec.js +450 -0
- package/dist/scripts/src/components/Charts/PieChart/PieChart.spec.js +584 -0
- package/dist/scripts/src/components/Charts/PieChart/PieChartNative.js +41 -2
- package/dist/scripts/src/components/Charts/RadarChart/RadarChart.spec.js +571 -0
- package/dist/scripts/src/components/Charts/Tooltip/TooltipContent.spec.js +449 -0
- package/dist/scripts/src/components/Checkbox/Checkbox.spec.js +964 -0
- package/dist/scripts/src/components/CodeBlock/CodeBlock.spec.js +196 -0
- package/dist/scripts/src/components/ColorPicker/ColorPicker.spec.js +283 -0
- package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +9 -26
- package/dist/scripts/src/components/Column/doc-resources/list-component-data.js +53 -0
- package/dist/scripts/src/components/ComponentProvider.js +6 -2
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.spec.js +338 -0
- package/dist/scripts/src/components/DateInput/DateInput.spec.js +918 -0
- package/dist/scripts/src/components/DatePicker/DatePicker.spec.js +362 -0
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +3 -3
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.spec.js +331 -0
- package/dist/scripts/src/components/DropdownMenu/DropdownMenuNative.js +7 -9
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.spec.js +29 -0
- package/dist/scripts/src/components/ExpandableItem/ExpandableItem.spec.js +435 -0
- package/dist/scripts/src/components/FileInput/FileInput.spec.js +249 -0
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.spec.js +296 -0
- package/dist/scripts/src/components/FlowLayout/FlowLayout.spec.js +518 -0
- package/dist/scripts/src/components/Footer/Footer.spec.js +991 -0
- package/dist/scripts/src/components/Form/Form.spec.js +1257 -0
- package/dist/scripts/src/components/FormItem/FormItem.spec.js +723 -0
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +3 -3
- package/dist/scripts/src/components/FormSection/FormSection.js +6 -31
- package/dist/scripts/src/components/Fragment/Fragment.spec.js +50 -0
- package/dist/scripts/src/components/Heading/H1.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H2.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H3.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H4.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H5.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H6.spec.js +66 -0
- package/dist/scripts/src/components/Heading/Heading.spec.js +897 -0
- package/dist/scripts/src/components/HtmlTags/HtmlTags.spec.js +69 -0
- package/dist/scripts/src/components/IFrame/IFrame.spec.js +527 -0
- package/dist/scripts/src/components/Icon/ArrowDropDown.js +11 -0
- package/dist/scripts/src/components/Icon/ArrowDropUp.js +11 -0
- package/dist/scripts/src/components/Icon/ArrowLeft.js +11 -0
- package/dist/scripts/src/components/Icon/ArrowRight.js +11 -0
- package/dist/scripts/src/components/Icon/ChevronDownIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronUpIcon.js +7 -0
- package/dist/scripts/src/components/Icon/Icon.spec.js +527 -0
- package/dist/scripts/src/components/Icon/SunIcon.js +10 -0
- package/dist/scripts/src/components/Image/Image.js +2 -1
- package/dist/scripts/src/components/Image/Image.spec.js +198 -0
- package/dist/scripts/src/components/Image/ImageNative.js +30 -2
- package/dist/scripts/src/components/Input/InputLabel.js +25 -0
- package/dist/scripts/src/components/Input/index.js +5 -0
- package/dist/scripts/src/components/Items/Items.spec.js +397 -0
- package/dist/scripts/src/components/Link/Link.spec.js +894 -0
- package/dist/scripts/src/components/List/List.spec.js +927 -0
- package/dist/scripts/src/components/List/doc-resources/list-component-data.js +53 -0
- package/dist/scripts/src/components/Markdown/Markdown.spec.js +188 -0
- package/dist/scripts/src/components/ModalDialog/ModalDialog.spec.js +162 -0
- package/dist/scripts/src/components/NavGroup/NavGroup.spec.js +212 -0
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +15 -7
- package/dist/scripts/src/components/NavLink/NavLink.spec.js +864 -0
- package/dist/scripts/src/components/NavPanel/NavPanel.spec.js +864 -0
- package/dist/scripts/src/components/NoResult/NoResult.spec.js +863 -0
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +1237 -0
- package/dist/scripts/src/components/Option/Option.spec.js +472 -0
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.spec.js +80 -0
- package/dist/scripts/src/components/Pagination/Pagination.spec.js +1003 -0
- package/dist/scripts/src/components/ProfileMenu/ProfileMenu.js +20 -0
- package/dist/scripts/src/components/ProgressBar/ProgressBar.spec.js +166 -0
- package/dist/scripts/src/components/Queue/Queue.spec.js +626 -0
- package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +479 -0
- package/dist/scripts/src/components/Redirect/Redirect.spec.js +527 -0
- package/dist/scripts/src/components/ResponsiveBar/ResponsiveBar.spec.js +76 -0
- package/dist/scripts/src/components/Select/Select.spec.js +527 -0
- package/dist/scripts/src/components/SelectionStore/SelectionStoreNative.js +3 -1
- package/dist/scripts/src/components/Slider/Slider.js +2 -0
- package/dist/scripts/src/components/Slider/Slider.spec.js +574 -0
- package/dist/scripts/src/components/Slider/SliderNative.js +63 -26
- package/dist/scripts/src/components/Slot/Slot.spec.js +368 -0
- package/dist/scripts/src/components/SpaceFiller/SpaceFiller.spec.js +184 -0
- package/dist/scripts/src/components/Spinner/Spinner.spec.js +161 -0
- package/dist/scripts/src/components/Splitter/HSplitter.spec.js +104 -0
- package/dist/scripts/src/components/Splitter/Splitter.spec.js +543 -0
- package/dist/scripts/src/components/Splitter/VSplitter.spec.js +104 -0
- package/dist/scripts/src/components/Stack/CHStack.spec.js +86 -0
- package/dist/scripts/src/components/Stack/CVStack.spec.js +86 -0
- package/dist/scripts/src/components/Stack/HStack.spec.js +67 -0
- package/dist/scripts/src/components/Stack/Stack.spec.js +654 -0
- package/dist/scripts/src/components/Stack/VStack.spec.js +67 -0
- package/dist/scripts/src/components/Switch/Switch.spec.js +829 -0
- package/dist/scripts/src/components/Table/Table.js +7 -1
- package/dist/scripts/src/components/Table/Table.spec.js +555 -0
- package/dist/scripts/src/components/Table/TableNative.js +4 -1
- package/dist/scripts/src/components/Table/doc-resources/list-component-data.js +53 -0
- package/dist/scripts/src/components/Table/useRowSelection.js +215 -1
- package/dist/scripts/src/components/TableOfContents/TableOfContents.spec.js +838 -0
- package/dist/scripts/src/components/Tabs/Tabs.spec.js +875 -0
- package/dist/scripts/src/components/Text/Text.spec.js +1075 -0
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +714 -0
- package/dist/scripts/src/components/TextBox/TextBox.js +1 -5
- package/dist/scripts/src/components/TextBox/TextBox.spec.js +687 -0
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +10 -15
- package/dist/scripts/src/components/Theme/Theme.spec.js +124 -0
- package/dist/scripts/src/components/Theme/ThemeNative.js +2 -6
- package/dist/scripts/src/components/TimeInput/TimeInput.js +1 -5
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +1122 -0
- package/dist/scripts/src/components/TimeInput/TimeInputNative.js +2 -9
- package/dist/scripts/src/components/Timer/Timer.spec.js +358 -0
- package/dist/scripts/src/components/ToneChangerButton/ToneChangerButton.spec.js +414 -0
- package/dist/scripts/src/components/ToneSwitch/ToneSwitch.spec.js +89 -0
- package/dist/scripts/src/components/Tooltip/Tooltip.spec.js +418 -0
- package/dist/scripts/src/components/chart-color-schemes.js +43 -0
- package/dist/scripts/src/components-core/ApiBoundComponent.js +38 -24
- package/dist/scripts/src/components-core/CompoundComponent.js +1 -1
- package/dist/scripts/src/components-core/RestApiProxy.js +84 -8
- package/dist/scripts/src/components-core/behaviors/BehaviorContext.js +54 -0
- package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +80 -0
- package/dist/scripts/src/components-core/descriptorHelper.js +1 -0
- package/dist/scripts/src/components-core/devtools/InspectorDialogVisibilityContext.js +8 -0
- package/dist/scripts/src/components-core/parts.js +4 -1
- package/dist/scripts/src/components-core/renderers.js +31 -0
- package/dist/scripts/src/components-core/rendering/AppRoot.js +2 -1
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +31 -46
- package/dist/scripts/src/components-core/rendering/nodeUtils.js +6 -0
- package/dist/scripts/src/components-core/script-runner/simplify-expression.js +386 -0
- package/dist/scripts/src/components-core/theming/component-layout-resolver.js +153 -0
- package/dist/scripts/src/components-core/theming/layout-resolver.js +2 -0
- package/dist/scripts/src/components-core/theming/parse-layout-props.js +98 -0
- package/dist/scripts/src/components-core/theming/themes/solid.js +16 -0
- package/dist/scripts/src/components-core/utils/audio-utils.js +83 -0
- package/dist/scripts/src/index-standalone.js +61 -0
- package/dist/scripts/src/index.js +39 -1
- package/dist/scripts/src/language-server/server-common.js +151 -0
- package/dist/scripts/src/language-server/server-web-worker.js +47 -0
- package/dist/scripts/src/language-server/server.js +42 -0
- package/dist/scripts/src/language-server/services/common/docs-generation.js +73 -0
- package/dist/scripts/src/language-server/services/common/lsp-utils.js +9 -0
- package/dist/scripts/src/language-server/services/common/syntax-node-utilities.js +135 -0
- package/dist/scripts/src/language-server/services/completion.js +270 -0
- package/dist/scripts/src/language-server/services/diagnostic.js +19 -0
- package/dist/scripts/src/language-server/services/format.js +430 -0
- package/dist/scripts/src/language-server/services/hover.js +164 -0
- package/dist/scripts/src/language-server/xmlui-metadata-generated.mjs +16266 -0
- package/dist/scripts/src/logging/xmlui.js +21 -0
- package/dist/scripts/src/parsers/common/utils.js +19 -0
- package/dist/scripts/src/syntax/monaco/grammar.monacoLanguage.js +286 -0
- package/dist/scripts/src/syntax/monaco/index.js +14 -0
- package/dist/scripts/src/syntax/monaco/xmlui-dark.js +25 -0
- package/dist/scripts/src/syntax/monaco/xmlui-light.js +25 -0
- package/dist/scripts/src/syntax/monaco/xmluiscript.monacoLanguage.js +310 -0
- package/dist/scripts/src/syntax/textMate/index.js +14 -0
- package/dist/scripts/src/syntax/textMate/xmlui-dark.json +631 -0
- package/dist/scripts/src/syntax/textMate/xmlui-light.json +565 -0
- package/dist/scripts/src/syntax/textMate/xmlui.json +564 -0
- package/dist/scripts/src/syntax/textMate/xmlui.tmLanguage.json +341 -0
- package/dist/scripts/src/testing/ComponentDrivers.js +1327 -0
- package/dist/scripts/src/testing/assertions.js +444 -0
- package/dist/scripts/src/testing/component-test-helpers.js +389 -0
- package/dist/scripts/src/testing/drivers/DateInputDriver.js +19 -0
- package/dist/scripts/src/testing/drivers/ModalDialogDriver.js +10 -0
- package/dist/scripts/src/testing/drivers/NumberBoxDriver.js +44 -0
- package/dist/scripts/src/testing/drivers/SliderDriver.js +20 -0
- package/dist/scripts/src/testing/drivers/TextBoxDriver.js +20 -0
- package/dist/scripts/src/testing/drivers/TimeInputDriver.js +22 -0
- package/dist/scripts/src/testing/drivers/TimerDriver.js +64 -0
- package/dist/scripts/src/testing/fixtures.js +513 -0
- package/dist/scripts/src/testing/infrastructure/TestBed.js +17 -0
- package/dist/scripts/src/testing/infrastructure/main.js +9 -0
- package/dist/scripts/src/testing/infrastructure/public/mockServiceWorker.js +266 -0
- package/dist/scripts/src/testing/themed-app-test-helpers.js +139 -0
- package/dist/standalone/xmlui-standalone.es.d.ts +172 -10
- package/dist/standalone/xmlui-standalone.umd.js +36 -36
- package/package.json +2 -3
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const fixtures_1 = require("../../testing/fixtures");
|
|
13
|
+
// =============================================================================
|
|
14
|
+
// BASIC FUNCTIONALITY TESTS
|
|
15
|
+
// =============================================================================
|
|
16
|
+
(0, fixtures_1.test)("initializes with default props", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
17
|
+
yield initTestBed(`
|
|
18
|
+
<Fragment>
|
|
19
|
+
<AppState id="appState" />
|
|
20
|
+
<Text testId="stateValue">|{JSON.stringify(appState.value)}|</Text>
|
|
21
|
+
</Fragment>
|
|
22
|
+
`);
|
|
23
|
+
// AppState should initialize with default bucket and display the correct value
|
|
24
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toBeVisible();
|
|
25
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toHaveText("||");
|
|
26
|
+
}));
|
|
27
|
+
(0, fixtures_1.test)("initializes with initial state value", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
28
|
+
yield initTestBed(`
|
|
29
|
+
<Fragment>
|
|
30
|
+
<AppState id="appState" initialValue="{{ mode: true }}"/>
|
|
31
|
+
<Text testId="stateValue">|{appState.value.mode}|</Text>
|
|
32
|
+
</Fragment>
|
|
33
|
+
`);
|
|
34
|
+
// AppState should initialize with default bucket and display the correct value
|
|
35
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toBeVisible();
|
|
36
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toHaveText("|true|");
|
|
37
|
+
}));
|
|
38
|
+
(0, fixtures_1.test)("initializes with provided bucket name and no initial value", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, }) {
|
|
39
|
+
yield initTestBed(`
|
|
40
|
+
<Fragment>
|
|
41
|
+
<AppState id="appState" bucket="settings" />
|
|
42
|
+
<Text testId="stateValue">|{JSON.stringify(appState.value)}|</Text>
|
|
43
|
+
</Fragment>
|
|
44
|
+
`);
|
|
45
|
+
// AppState should initialize with default bucket and display the correct value
|
|
46
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toBeVisible();
|
|
47
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toHaveText("||");
|
|
48
|
+
}));
|
|
49
|
+
(0, fixtures_1.test)("initializes with bucket name and initial state value", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
50
|
+
yield initTestBed(`
|
|
51
|
+
<Fragment>
|
|
52
|
+
<AppState id="appState" bucket="settings" initialValue="{{ mode: true }}"/>
|
|
53
|
+
<Text testId="stateValue">|{appState.value.mode}|</Text>
|
|
54
|
+
</Fragment>
|
|
55
|
+
`);
|
|
56
|
+
// AppState should initialize with default bucket and display the correct value
|
|
57
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toBeVisible();
|
|
58
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toHaveText("|true|");
|
|
59
|
+
}));
|
|
60
|
+
(0, fixtures_1.test)("updates state using the update API", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
61
|
+
yield initTestBed(`
|
|
62
|
+
<Fragment>
|
|
63
|
+
<AppState id="appState" initialValue="{{ counter: 0 }}" />
|
|
64
|
+
<Button testId="updateBtn" onClick="appState.update({ counter: appState.value.counter + 1 })">
|
|
65
|
+
Increment
|
|
66
|
+
</Button>
|
|
67
|
+
<Text testId="stateValue">{JSON.stringify(appState.value)}</Text>
|
|
68
|
+
</Fragment>
|
|
69
|
+
`);
|
|
70
|
+
// Check initial state
|
|
71
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toHaveText('{"counter":0}');
|
|
72
|
+
// Update state by clicking button
|
|
73
|
+
yield page.getByTestId("updateBtn").click();
|
|
74
|
+
// Check updated state
|
|
75
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toHaveText('{"counter":1}');
|
|
76
|
+
}));
|
|
77
|
+
(0, fixtures_1.test)("updates state using the update API (using backet name)", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
78
|
+
yield initTestBed(`
|
|
79
|
+
<Fragment>
|
|
80
|
+
<AppState id="appState" bucket="settings" initialValue="{{ counter: 0 }}" />
|
|
81
|
+
<Button testId="updateBtn" onClick="appState.update({ counter: appState.value.counter + 1 })">
|
|
82
|
+
Increment
|
|
83
|
+
</Button>
|
|
84
|
+
<Text testId="stateValue">{JSON.stringify(appState.value)}</Text>
|
|
85
|
+
</Fragment>
|
|
86
|
+
`);
|
|
87
|
+
// Check initial state
|
|
88
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toHaveText('{"counter":0}');
|
|
89
|
+
// Update state by clicking button
|
|
90
|
+
yield page.getByTestId("updateBtn").click();
|
|
91
|
+
// Check updated state
|
|
92
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toHaveText('{"counter":1}');
|
|
93
|
+
}));
|
|
94
|
+
// =============================================================================
|
|
95
|
+
// STATE SHARING TESTS
|
|
96
|
+
// =============================================================================
|
|
97
|
+
(0, fixtures_1.test)("shares state between multiple instances with the default bucket", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, }) {
|
|
98
|
+
yield initTestBed(`
|
|
99
|
+
<Fragment>
|
|
100
|
+
<AppState id="appState1" initialValue="{{ counter: 0 }}" />
|
|
101
|
+
<AppState id="appState2" />
|
|
102
|
+
<Button testId="updateBtn" onClick="appState1.update({ counter: appState1.value.counter + 1 })">
|
|
103
|
+
Increment
|
|
104
|
+
</Button>
|
|
105
|
+
<Text testId="stateValue1">{JSON.stringify(appState1.value)}</Text>
|
|
106
|
+
<Text testId="stateValue2">{JSON.stringify(appState2.value)}</Text>
|
|
107
|
+
</Fragment>
|
|
108
|
+
`);
|
|
109
|
+
// Check initial state in both instances
|
|
110
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue1")).toHaveText('{"counter":0}');
|
|
111
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue2")).toHaveText('{"counter":0}');
|
|
112
|
+
// Update state through first instance
|
|
113
|
+
yield page.getByTestId("updateBtn").click();
|
|
114
|
+
// Both instances should reflect the change
|
|
115
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue1")).toHaveText('{"counter":1}');
|
|
116
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue2")).toHaveText('{"counter":1}');
|
|
117
|
+
}));
|
|
118
|
+
(0, fixtures_1.test)("shares state between multiple instances with a specific bucket", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, }) {
|
|
119
|
+
yield initTestBed(`
|
|
120
|
+
<Fragment>
|
|
121
|
+
<AppState id="appState1" initialValue="{{ counter: 0 }}" bucket="bucket1" />
|
|
122
|
+
<AppState id="appState2" bucket="bucket1" />
|
|
123
|
+
<Button testId="updateBtn" onClick="appState1.update({ counter: appState1.value.counter + 1 })">
|
|
124
|
+
Increment
|
|
125
|
+
</Button>
|
|
126
|
+
<Text testId="stateValue1">{JSON.stringify(appState1.value)}</Text>
|
|
127
|
+
<Text testId="stateValue2">{JSON.stringify(appState2.value)}</Text>
|
|
128
|
+
</Fragment>
|
|
129
|
+
`);
|
|
130
|
+
// Check initial state in both instances
|
|
131
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue1")).toHaveText('{"counter":0}');
|
|
132
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue2")).toHaveText('{"counter":0}');
|
|
133
|
+
// Update state through first instance
|
|
134
|
+
yield page.getByTestId("updateBtn").click();
|
|
135
|
+
// Both instances should reflect the change
|
|
136
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue1")).toHaveText('{"counter":1}');
|
|
137
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue2")).toHaveText('{"counter":1}');
|
|
138
|
+
}));
|
|
139
|
+
(0, fixtures_1.test)("maintains separate states for different buckets", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
140
|
+
yield initTestBed(`
|
|
141
|
+
<Fragment>
|
|
142
|
+
<AppState id="appState1" initialValue="{{ counter: 0 }}" bucket="bucket1" />
|
|
143
|
+
<AppState id="appState2" initialValue="{{ counter: 0 }}" bucket="bucket2" />
|
|
144
|
+
<Button testId="updateBtn" onClick="appState1.update({ counter: appState1.value.counter + 1 })">
|
|
145
|
+
Increment
|
|
146
|
+
</Button>
|
|
147
|
+
<Text testId="stateValue1">{JSON.stringify(appState1.value)}</Text>
|
|
148
|
+
<Text testId="stateValue2">{JSON.stringify(appState2.value)}</Text>
|
|
149
|
+
</Fragment>
|
|
150
|
+
`);
|
|
151
|
+
// Check initial state in both instances
|
|
152
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue1")).toHaveText('{"counter":0}');
|
|
153
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue2")).toHaveText('{"counter":0}');
|
|
154
|
+
// Update state through first instance
|
|
155
|
+
yield page.getByTestId("updateBtn").click();
|
|
156
|
+
// Only the first instance should reflect the change
|
|
157
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue1")).toHaveText('{"counter":1}');
|
|
158
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue2")).toHaveText('{"counter":0}');
|
|
159
|
+
}));
|
|
160
|
+
// =============================================================================
|
|
161
|
+
// EDGE CASE TESTS
|
|
162
|
+
// =============================================================================
|
|
163
|
+
(0, fixtures_1.test)("handles undefined initialValue gracefully", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
164
|
+
yield initTestBed(`
|
|
165
|
+
<Fragment>
|
|
166
|
+
<AppState ref="appState" initialValue="{undefined}" />
|
|
167
|
+
<Text testId="stateValue">|{JSON.stringify(appState.value)}|</Text>
|
|
168
|
+
</Fragment>
|
|
169
|
+
`);
|
|
170
|
+
// Should not throw error with undefined initialValue
|
|
171
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toBeVisible();
|
|
172
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toHaveText("||");
|
|
173
|
+
}));
|
|
174
|
+
(0, fixtures_1.test)("handles complex nested state updates correctly", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
175
|
+
yield initTestBed(`
|
|
176
|
+
<Fragment>
|
|
177
|
+
<AppState
|
|
178
|
+
id="appState"
|
|
179
|
+
initialValue="{{ user: { name: 'John', profile: { age: 30, roles: ['admin'] } } }}"
|
|
180
|
+
/>
|
|
181
|
+
<Button testId="updateBtn"
|
|
182
|
+
onClick="appState.update({
|
|
183
|
+
user: { ...appState.value.user,
|
|
184
|
+
profile: { ...appState.value.user.profile, age: 31 } }
|
|
185
|
+
})">
|
|
186
|
+
Update Age
|
|
187
|
+
</Button>
|
|
188
|
+
<Text testId="stateValue">{JSON.stringify(appState.value)}</Text>
|
|
189
|
+
</Fragment>
|
|
190
|
+
`);
|
|
191
|
+
// Check initial state
|
|
192
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toContainText('"age":30');
|
|
193
|
+
// Update nested property
|
|
194
|
+
yield page.getByTestId("updateBtn").click();
|
|
195
|
+
// Check updated nested property
|
|
196
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toContainText('"age":31');
|
|
197
|
+
// Check other properties remain unchanged
|
|
198
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toContainText('"name":"John"');
|
|
199
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toContainText('"roles":["admin"]');
|
|
200
|
+
}));
|
|
201
|
+
// =============================================================================
|
|
202
|
+
// PERFORMANCE TESTS
|
|
203
|
+
// =============================================================================
|
|
204
|
+
(0, fixtures_1.test)("handles multiple rapid state updates efficiently", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
205
|
+
yield initTestBed(`
|
|
206
|
+
<Fragment var.clickCount="{0}">
|
|
207
|
+
<AppState id="appState" initialValue="{{ counter: 0 }}" />
|
|
208
|
+
<Button
|
|
209
|
+
testId="updateBtn"
|
|
210
|
+
onClick="appState.update({ counter: appState.value.counter + 1 }); clickCount = clickCount + 1;">
|
|
211
|
+
Increment
|
|
212
|
+
</Button>
|
|
213
|
+
<Text testId="stateValue">{JSON.stringify(appState.value)}</Text>
|
|
214
|
+
<Text testId="clickCount">{clickCount}</Text>
|
|
215
|
+
</Fragment>
|
|
216
|
+
`);
|
|
217
|
+
// Perform multiple rapid clicks
|
|
218
|
+
for (let i = 0; i < 5; i++) {
|
|
219
|
+
yield page.getByTestId("updateBtn").click();
|
|
220
|
+
}
|
|
221
|
+
// Verify click count
|
|
222
|
+
yield (0, fixtures_1.expect)(page.getByTestId("clickCount")).toHaveText("5");
|
|
223
|
+
// Verify state was updated correctly
|
|
224
|
+
yield (0, fixtures_1.expect)(page.getByTestId("stateValue")).toContainText('{"counter":5}');
|
|
225
|
+
}));
|
|
226
|
+
// =============================================================================
|
|
227
|
+
// INTEGRATION TESTS
|
|
228
|
+
// =============================================================================
|
|
229
|
+
(0, fixtures_1.test)("integrates with other components that consume app state", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, }) {
|
|
230
|
+
// TODO: review these Copilot-created tests
|
|
231
|
+
yield initTestBed(`
|
|
232
|
+
<Fragment>
|
|
233
|
+
<AppState id="appState" initialValue="{{ theme: 'light', fontSize: 14 }}" />
|
|
234
|
+
<Fragment var.currentTheme="initial">
|
|
235
|
+
<Button testId="themeBtn" onClick="currentTheme = appState.value.theme">
|
|
236
|
+
Get Theme
|
|
237
|
+
</Button>
|
|
238
|
+
<Text testId="themeValue">{currentTheme}</Text>
|
|
239
|
+
</Fragment>
|
|
240
|
+
</Fragment>
|
|
241
|
+
`);
|
|
242
|
+
// Get the theme value by clicking button
|
|
243
|
+
yield page.getByTestId("themeBtn").click();
|
|
244
|
+
// Check that the value was correctly retrieved from AppState
|
|
245
|
+
yield (0, fixtures_1.expect)(page.getByTestId("themeValue")).toHaveText("light");
|
|
246
|
+
}));
|
|
247
|
+
(0, fixtures_1.test)("works correctly when wrapped in conditional rendering", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, }) {
|
|
248
|
+
// TODO: review these Copilot-created tests
|
|
249
|
+
yield initTestBed(`
|
|
250
|
+
<Fragment var.showState="{false}">
|
|
251
|
+
<Fragment when="{showState}">
|
|
252
|
+
<Text>AppState is visible</Text>
|
|
253
|
+
<AppState id="appState" initialValue="{{ visible: true }}" />
|
|
254
|
+
</Fragment>
|
|
255
|
+
<Button testId="toggleBtn" onClick="showState = !showState">Toggle AppState</Button>
|
|
256
|
+
<Text testId="visibilityStatus">{appState.value.visible ? 'Visible' : 'Hidden'}</Text>
|
|
257
|
+
</Fragment>
|
|
258
|
+
`);
|
|
259
|
+
// Initially the AppState component should be rendered
|
|
260
|
+
yield (0, fixtures_1.expect)(page.getByTestId("visibilityStatus")).toHaveText("Hidden");
|
|
261
|
+
// Toggle the component's visibility
|
|
262
|
+
yield page.getByTestId("toggleBtn").click();
|
|
263
|
+
yield (0, fixtures_1.expect)(page.getByTestId("visibilityStatus")).toHaveText("Visible");
|
|
264
|
+
// Toggle it back: The AppState component is hidden, but the state is still remain
|
|
265
|
+
// there. It should work this way.
|
|
266
|
+
yield page.getByTestId("toggleBtn").click();
|
|
267
|
+
yield (0, fixtures_1.expect)(page.getByTestId("visibilityStatus")).toHaveText("Visible");
|
|
268
|
+
}));
|
|
@@ -7,7 +7,7 @@ const AppStateContext_1 = require("../../components/App/AppStateContext");
|
|
|
7
7
|
exports.defaultProps = {
|
|
8
8
|
bucket: "default",
|
|
9
9
|
};
|
|
10
|
-
function AppState({ bucket = exports.defaultProps.bucket, updateState, initialValue, registerComponentApi, }) {
|
|
10
|
+
function AppState({ bucket = exports.defaultProps.bucket, updateState, initialValue, registerComponentApi, onDidUpdate, }) {
|
|
11
11
|
const registerAppState = (0, AppStateContext_1.useAppStateContextPart)((value) => value.registerAppState);
|
|
12
12
|
const update = (0, AppStateContext_1.useAppStateContextPart)((value) => value.update);
|
|
13
13
|
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
@@ -18,11 +18,35 @@ function AppState({ bucket = exports.defaultProps.bucket, updateState, initialVa
|
|
|
18
18
|
const value = (0, AppStateContext_1.useAppStateContextPart)((value) => value.appState[bucket]);
|
|
19
19
|
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
20
20
|
updateState({ value });
|
|
21
|
-
|
|
21
|
+
// Fire the didUpdate event when value changes
|
|
22
|
+
if (onDidUpdate) {
|
|
23
|
+
onDidUpdate({ bucket, value, previousValue: undefined }); // Note: previousValue tracking could be added if needed
|
|
24
|
+
}
|
|
25
|
+
}, [updateState, value, onDidUpdate, bucket]);
|
|
22
26
|
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
23
27
|
registerComponentApi({
|
|
24
28
|
update: (patch) => update(bucket, patch),
|
|
29
|
+
appendToList: (key, id) => {
|
|
30
|
+
const currentState = value || {};
|
|
31
|
+
const currentArray = currentState[key] || [];
|
|
32
|
+
// Only add if the id doesn't already exist in the array
|
|
33
|
+
if (!currentArray.includes(id)) {
|
|
34
|
+
const newArray = [...currentArray, id];
|
|
35
|
+
update(bucket, { [key]: newArray });
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
removeFromList: (key, id) => {
|
|
39
|
+
const currentState = value || {};
|
|
40
|
+
const currentArray = currentState[key] || [];
|
|
41
|
+
const newArray = currentArray.filter((item) => item !== id);
|
|
42
|
+
update(bucket, { [key]: newArray });
|
|
43
|
+
},
|
|
44
|
+
listIncludes: (key, id) => {
|
|
45
|
+
const currentState = value || {};
|
|
46
|
+
const currentArray = currentState[key] || [];
|
|
47
|
+
return currentArray.includes(id);
|
|
48
|
+
},
|
|
25
49
|
});
|
|
26
|
-
}, [bucket, registerComponentApi, update]);
|
|
50
|
+
}, [bucket, registerComponentApi, update, value]);
|
|
27
51
|
return null;
|
|
28
52
|
}
|