xmlui 0.10.12 → 0.10.14
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-CDOoBf2R.mjs → index-779mp2Bm.mjs} +1508 -1287
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-BAV9RKui.mjs → initMock-CAXdczCj.mjs} +1 -1
- package/dist/lib/scss/components-core/theming/_themes.scss +1 -1
- package/dist/lib/xmlui.d.ts +17 -2
- package/dist/lib/xmlui.mjs +33 -32
- package/dist/metadata/{collectedComponentMetadata-Dp8BqWQO.mjs → collectedComponentMetadata-7DFXlw-J.mjs} +14957 -14751
- package/dist/metadata/{initMock-BvEO8W8r.mjs → initMock-AFWEftc6.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 +1 -1
- 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.spec.js +268 -0
- 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.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/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.js +3 -3
- package/dist/scripts/src/components/ColorPicker/ColorPicker.spec.js +283 -0
- package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +16 -5
- package/dist/scripts/src/components/Column/doc-resources/list-component-data.js +53 -0
- package/dist/scripts/src/components/ComponentProvider.js +6 -6
- 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 +1 -1
- 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/FileInput/FileInputNative.js +14 -10
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.spec.js +296 -0
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZoneNative.js +1 -1
- 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.js +6 -0
- package/dist/scripts/src/components/Form/Form.spec.js +1257 -0
- package/dist/scripts/src/components/Form/FormNative.js +13 -3
- package/dist/scripts/src/components/FormItem/FormItem.spec.js +723 -0
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +2 -2
- package/dist/scripts/src/components/FormSection/FormSection.js +6 -31
- package/dist/scripts/src/components/Fragment/Fragment.js +5 -1
- 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.js +0 -12
- 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.js +1 -1
- package/dist/scripts/src/components/ModalDialog/ModalDialog.spec.js +162 -0
- package/dist/scripts/src/components/ModalDialog/ModalDialogNative.js +1 -1
- package/dist/scripts/src/components/NavGroup/NavGroup.spec.js +153 -0
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +2 -2
- 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 +1231 -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/RadioGroup/RadioGroupNative.js +17 -1
- 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/Slider/Slider.js +2 -0
- package/dist/scripts/src/components/Slider/Slider.spec.js +574 -0
- package/dist/scripts/src/components/Slider/SliderNative.js +62 -25
- 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 +8 -5
- package/dist/scripts/src/components/Table/Table.spec.js +555 -0
- package/dist/scripts/src/components/Table/TableNative.js +1 -1
- package/dist/scripts/src/components/Table/doc-resources/list-component-data.js +53 -0
- 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.js +0 -13
- 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/TextArea/TextAreaNative.js +8 -1
- package/dist/scripts/src/components/TextBox/TextBox.spec.js +643 -0
- package/dist/scripts/src/components/Theme/NotificationToast.js +4 -1
- package/dist/scripts/src/components/Theme/Theme.spec.js +124 -0
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +1122 -0
- 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/CompoundComponent.js +5 -5
- package/dist/scripts/src/components-core/RestApiProxy.js +89 -11
- package/dist/scripts/src/components-core/devtools/InspectorDialogVisibilityContext.js +8 -0
- package/dist/scripts/src/components-core/renderers.js +31 -0
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +1 -1
- package/dist/scripts/src/components-core/rendering/Container.js +19 -8
- package/dist/scripts/src/components-core/rendering/reducer.js +1 -1
- 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/parse-layout-props.js +98 -0
- package/dist/scripts/src/components-core/theming/themes/root.js +13 -20
- 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 +2 -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 +1355 -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/TimeInputDriver.js +22 -0
- package/dist/scripts/src/testing/drivers/TimerDriver.js +64 -0
- package/dist/scripts/src/testing/fixtures.js +487 -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 +19 -2
- package/dist/standalone/xmlui-standalone.umd.js +36 -36
- package/package.json +1 -1
- package/dist/scripts/src/components/RadioGroup/RadioItem.js +0 -28
|
@@ -0,0 +1,454 @@
|
|
|
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 component_test_helpers_1 = require("../../testing/component-test-helpers");
|
|
13
|
+
const fixtures_1 = require("../../testing/fixtures");
|
|
14
|
+
const abstractions_1 = require("../../components/abstractions");
|
|
15
|
+
const abstractions_2 = require("../abstractions");
|
|
16
|
+
const ButtonNative_1 = require("./ButtonNative");
|
|
17
|
+
// --- Smoke
|
|
18
|
+
fixtures_1.test.describe("smoke tests", { tag: "@smoke" }, () => {
|
|
19
|
+
(0, fixtures_1.test)("component renders", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
20
|
+
yield initTestBed(`<Button />`);
|
|
21
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toBeAttached();
|
|
22
|
+
}));
|
|
23
|
+
// --- label
|
|
24
|
+
(0, fixtures_1.test)("renders ASCII text in label", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
25
|
+
yield initTestBed(`<Button label="hello" />`);
|
|
26
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveText("hello");
|
|
27
|
+
}));
|
|
28
|
+
(0, fixtures_1.test)("renders Unicode text in label", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
29
|
+
yield initTestBed(`<Button label="😀" />`);
|
|
30
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveText("😀");
|
|
31
|
+
}));
|
|
32
|
+
// --- icon
|
|
33
|
+
(0, fixtures_1.test)("can render icon", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
34
|
+
yield initTestBed(`<Button icon="test" />`, {
|
|
35
|
+
resources: {
|
|
36
|
+
"icon.test": "resources/bell.svg",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).getIcons().first()).toBeVisible();
|
|
40
|
+
}));
|
|
41
|
+
// --- enabled
|
|
42
|
+
(0, fixtures_1.test)("has enabled state", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
43
|
+
yield initTestBed(`<Button enabled="true" />`);
|
|
44
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toBeEnabled();
|
|
45
|
+
}));
|
|
46
|
+
(0, fixtures_1.test)("has disabled state", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
47
|
+
yield initTestBed(`<Button enabled="false" />`);
|
|
48
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toBeDisabled();
|
|
49
|
+
}));
|
|
50
|
+
// --- click
|
|
51
|
+
(0, fixtures_1.test)("click event fires", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
52
|
+
const { testStateDriver } = yield initTestBed(`<Button onClick="testState = true" />`);
|
|
53
|
+
yield (yield createButtonDriver()).click();
|
|
54
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual(true);
|
|
55
|
+
}));
|
|
56
|
+
// --- variant & themeColor
|
|
57
|
+
// background color
|
|
58
|
+
const EXPECTED_BACKGROUND_COLOR = "rgb(255, 0, 0)";
|
|
59
|
+
abstractions_1.buttonThemeValues.forEach((themeColor) => {
|
|
60
|
+
(0, fixtures_1.test)(`"solid" background color: "${themeColor}"`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
61
|
+
yield initTestBed(`<Button variant="solid" themeColor="${themeColor}" />`, {
|
|
62
|
+
testThemeVars: {
|
|
63
|
+
[`backgroundColor-Button-${themeColor}-solid`]: EXPECTED_BACKGROUND_COLOR,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveCSS("background-color", EXPECTED_BACKGROUND_COLOR);
|
|
67
|
+
}));
|
|
68
|
+
});
|
|
69
|
+
// content/label color
|
|
70
|
+
const EXPECTED_CONTENT_COLOR = "rgb(255, 255, 255)";
|
|
71
|
+
abstractions_1.buttonVariantValues.forEach((variant) => {
|
|
72
|
+
abstractions_1.buttonThemeValues.forEach((themeColor) => {
|
|
73
|
+
(0, fixtures_1.test)(`"${variant}" content color: "${themeColor}"`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
74
|
+
yield initTestBed(`<Button variant="${variant}" themeColor="${themeColor}" />`, {
|
|
75
|
+
testThemeVars: {
|
|
76
|
+
[`textColor-Button-${themeColor}-${variant}`]: EXPECTED_CONTENT_COLOR,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveCSS("color", EXPECTED_CONTENT_COLOR);
|
|
80
|
+
}));
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
// border
|
|
84
|
+
const EXPECTED_BORDER_COLOR = "rgb(255, 0, 0)";
|
|
85
|
+
const EXPECTED_BORDER_WIDTH = "5px";
|
|
86
|
+
const EXPECTED_BORDER_STYLE = "dotted";
|
|
87
|
+
const EXPECTED_BORDER_RADIUS = "10px";
|
|
88
|
+
abstractions_1.buttonVariantValues
|
|
89
|
+
.filter((v) => v !== "ghost")
|
|
90
|
+
.forEach((variant) => {
|
|
91
|
+
abstractions_1.buttonThemeValues.forEach((themeColor) => {
|
|
92
|
+
(0, fixtures_1.test)(`border: "${themeColor}" "${variant}" variant`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
93
|
+
yield initTestBed(`<Button variant="${variant}" themeColor="${themeColor}" />`, {
|
|
94
|
+
testThemeVars: {
|
|
95
|
+
[`borderColor-Button-${themeColor}-${variant}`]: EXPECTED_BORDER_COLOR,
|
|
96
|
+
[`borderWidth-Button-${themeColor}-${variant}`]: EXPECTED_BORDER_WIDTH,
|
|
97
|
+
[`borderRadius-Button-${themeColor}-${variant}`]: EXPECTED_BORDER_RADIUS,
|
|
98
|
+
[`borderStyle-Button-${themeColor}-${variant}`]: EXPECTED_BORDER_STYLE,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
const driver = yield createButtonDriver();
|
|
102
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveCSS("border-color", EXPECTED_BORDER_COLOR);
|
|
103
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveCSS("border-width", EXPECTED_BORDER_WIDTH);
|
|
104
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveCSS("border-radius", EXPECTED_BORDER_RADIUS);
|
|
105
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveCSS("border-style", EXPECTED_BORDER_STYLE);
|
|
106
|
+
}));
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
abstractions_1.buttonThemeValues.forEach((themeColor) => {
|
|
110
|
+
(0, fixtures_1.test)(`border: "${themeColor}" "ghost" variant`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
111
|
+
yield initTestBed(`<Button variant="ghost" themeColor="${themeColor}" />`, {
|
|
112
|
+
testThemeVars: {
|
|
113
|
+
[`borderWidth-Button-${themeColor}-ghost`]: EXPECTED_BORDER_WIDTH,
|
|
114
|
+
[`borderRadius-Button-${themeColor}-ghost`]: EXPECTED_BORDER_RADIUS,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
const driver = yield createButtonDriver();
|
|
118
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveCSS("border-width", EXPECTED_BORDER_WIDTH);
|
|
119
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveCSS("border-radius", EXPECTED_BORDER_RADIUS);
|
|
120
|
+
}));
|
|
121
|
+
});
|
|
122
|
+
// fonts
|
|
123
|
+
const EXPECTED_FONT_FAMILY = "Arial, sans-serif";
|
|
124
|
+
const EXPECTED_FONT_SIZE = "20px";
|
|
125
|
+
const EXPECTED_FONT_WEIGHT = "200";
|
|
126
|
+
abstractions_1.buttonVariantValues.forEach((variant) => {
|
|
127
|
+
abstractions_1.buttonThemeValues.forEach((themeColor) => {
|
|
128
|
+
(0, fixtures_1.test)(`font: "${themeColor}" "${variant}" variant`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
129
|
+
yield initTestBed(`<Button variant="${variant}" themeColor="${themeColor}" />`, {
|
|
130
|
+
testThemeVars: {
|
|
131
|
+
[`fontFamily-Button-${themeColor}-${variant}`]: EXPECTED_FONT_FAMILY,
|
|
132
|
+
[`fontSize-Button-${themeColor}-${variant}`]: EXPECTED_FONT_SIZE,
|
|
133
|
+
[`fontWeight-Button-${themeColor}-${variant}`]: EXPECTED_FONT_WEIGHT,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
const driver = yield createButtonDriver();
|
|
137
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveCSS("font-family", EXPECTED_FONT_FAMILY);
|
|
138
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveCSS("font-size", EXPECTED_FONT_SIZE);
|
|
139
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveCSS("font-weight", EXPECTED_FONT_WEIGHT);
|
|
140
|
+
}));
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
// --- Accessibility
|
|
144
|
+
(0, fixtures_1.test)("icon-only button has accessible name", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
145
|
+
yield initTestBed(`<Button icon="test" />`, {
|
|
146
|
+
resources: {
|
|
147
|
+
"icon.test": "resources/bell.svg",
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveText("test");
|
|
151
|
+
}));
|
|
152
|
+
(0, fixtures_1.test)("icon & label button uses label name only", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
153
|
+
yield initTestBed(`<Button icon="test" label="label" />`, {
|
|
154
|
+
resources: {
|
|
155
|
+
"icon.test": "resources/bell.svg",
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveText("label");
|
|
159
|
+
}));
|
|
160
|
+
(0, fixtures_1.test)("icon-only button uses contextualLabel", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
161
|
+
yield initTestBed(`<Button icon="test" contextualLabel="label" />`, {
|
|
162
|
+
resources: {
|
|
163
|
+
"icon.test": "resources/bell.svg",
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveText("label");
|
|
167
|
+
}));
|
|
168
|
+
(0, fixtures_1.test)("icon, label, contextualLabel button uses label", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
169
|
+
yield initTestBed(`<Button icon="test" label="label" contextualLabel="contextLabel" />`, {
|
|
170
|
+
resources: {
|
|
171
|
+
"icon.test": "resources/bell.svg",
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveText("label");
|
|
175
|
+
}));
|
|
176
|
+
});
|
|
177
|
+
// --- E2E
|
|
178
|
+
// --- label
|
|
179
|
+
// Label inputs resolved with converting them to a string
|
|
180
|
+
[
|
|
181
|
+
{ label: "null", input: null, toExpect: "null" },
|
|
182
|
+
{ label: "undefined", input: undefined, toExpect: "undefined" },
|
|
183
|
+
{ label: "empty object", input: {}, toExpect: "[object Object]" },
|
|
184
|
+
{ label: "object", input: { a: 1, b: "hi" }, toExpect: "[object Object]" },
|
|
185
|
+
{ label: "empty array", input: [], toExpect: undefined },
|
|
186
|
+
{ label: "array", input: [1, 2, 3], toExpect: "1,2,3" },
|
|
187
|
+
{ label: "arrow function returning string", input: "{() => ''}", toExpect: "[object Object]" },
|
|
188
|
+
{
|
|
189
|
+
label: "function returning string",
|
|
190
|
+
input: "{function () { return ''; }}",
|
|
191
|
+
toExpect: "[object Object]",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
label: "IIFE returning string",
|
|
195
|
+
input: "{(function () { return 'hello'; })()}",
|
|
196
|
+
toExpect: "hello",
|
|
197
|
+
},
|
|
198
|
+
].forEach((type) => {
|
|
199
|
+
(0, fixtures_1.test)(`if label is ${type.label} renders label as "${type.toExpect}"`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
200
|
+
yield initTestBed(`<Button label="${type.input}" />`);
|
|
201
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveExplicitLabel(type.toExpect);
|
|
202
|
+
}));
|
|
203
|
+
});
|
|
204
|
+
(0, fixtures_1.test)("text node as children are same as setting label", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
205
|
+
yield initTestBed(`<Button>hello</Button>`);
|
|
206
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveExplicitLabel("hello");
|
|
207
|
+
}));
|
|
208
|
+
(0, fixtures_1.test)("ignores label property if children present", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
209
|
+
yield initTestBed(`<Button label="hello">world</Button>`);
|
|
210
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveExplicitLabel("world");
|
|
211
|
+
}));
|
|
212
|
+
(0, fixtures_1.test)("renders XMLUI Text component as child", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, createTextDriver, }) {
|
|
213
|
+
yield initTestBed(`<Button label="hello"><Text testId="text">world</Text></Button>`);
|
|
214
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).not.toHaveExplicitLabel("hello");
|
|
215
|
+
yield (0, fixtures_1.expect)((yield createTextDriver("text")).component).toHaveText("world");
|
|
216
|
+
}));
|
|
217
|
+
(0, fixtures_1.test)("renders XMLUI Complex component as child", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, createCardDriver, }) {
|
|
218
|
+
yield initTestBed(`<Button label="hello"><Card testId="card" title="Button">Content</Card></Button>`);
|
|
219
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).not.toHaveExplicitLabel("hello");
|
|
220
|
+
yield (0, fixtures_1.expect)((yield createCardDriver("card")).component).toBeAttached();
|
|
221
|
+
}));
|
|
222
|
+
// --- icon
|
|
223
|
+
(0, fixtures_1.test)("renders icon and label", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
224
|
+
yield initTestBed(`<Button icon="test" label="hello" />`, {
|
|
225
|
+
resources: {
|
|
226
|
+
"icon.test": "resources/bell.svg",
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
const driver = yield createButtonDriver();
|
|
230
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveText("hello");
|
|
231
|
+
yield (0, fixtures_1.expect)(driver.getIcons().first()).toBeVisible();
|
|
232
|
+
}));
|
|
233
|
+
(0, fixtures_1.test)("renders icon if children present", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
234
|
+
yield initTestBed(`<Button icon="test">Hello World</Button>`, {
|
|
235
|
+
resources: {
|
|
236
|
+
"icon.test": "resources/bell.svg",
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).getIcons().first()).toBeVisible();
|
|
240
|
+
}));
|
|
241
|
+
[
|
|
242
|
+
{ label: "null", value: null },
|
|
243
|
+
{ label: "undefined", value: undefined },
|
|
244
|
+
{ label: "empty object", value: {} },
|
|
245
|
+
{ label: "object", value: { a: 1, b: "hi" } },
|
|
246
|
+
{ label: "empty array", value: [] },
|
|
247
|
+
{ label: "array", value: [] },
|
|
248
|
+
{ label: "function", value: () => { } },
|
|
249
|
+
].forEach((type) => {
|
|
250
|
+
(0, fixtures_1.test)(`does not render icon if icon is of type ${type.label}`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
251
|
+
yield initTestBed(`<Button icon="${type.value}" />`);
|
|
252
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).getIcons().first()).not.toBeAttached();
|
|
253
|
+
}));
|
|
254
|
+
});
|
|
255
|
+
(0, fixtures_1.test)("renders if icon is not found and label is present", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
256
|
+
yield initTestBed(`<Button icon="_" label="hello" />`);
|
|
257
|
+
const driver = yield createButtonDriver();
|
|
258
|
+
yield (0, fixtures_1.expect)(driver.getIcons().first()).not.toBeAttached();
|
|
259
|
+
yield (0, fixtures_1.expect)(driver.component).toHaveText("hello");
|
|
260
|
+
}));
|
|
261
|
+
// --- iconPosition
|
|
262
|
+
const iconPositionCases = [
|
|
263
|
+
{ position: "left", value: "start" },
|
|
264
|
+
{ position: "right", value: "end" },
|
|
265
|
+
];
|
|
266
|
+
// This is a helper function to calculate the icon position
|
|
267
|
+
function iconPositionCalculation(buttonDriver, iconDriver) {
|
|
268
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
269
|
+
const buttonBounds = yield (0, component_test_helpers_1.getBounds)(buttonDriver);
|
|
270
|
+
const buttonPadding = yield (0, component_test_helpers_1.getPaddings)(buttonDriver);
|
|
271
|
+
const buttonBorders = yield (0, component_test_helpers_1.getBorders)(buttonDriver);
|
|
272
|
+
const { left: iconLeft, right: iconRight } = yield (0, component_test_helpers_1.getBounds)(iconDriver);
|
|
273
|
+
const buttonContentLeft = buttonBounds.left + buttonBorders.left.width.value + buttonPadding.left.value;
|
|
274
|
+
const buttonContentRight = buttonBounds.right - buttonBorders.right.width.value - buttonPadding.right.value;
|
|
275
|
+
return { buttonContentLeft, buttonContentRight, iconLeft, iconRight };
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
iconPositionCases.forEach(({ value }) => {
|
|
279
|
+
(0, fixtures_1.test)(`iconPosition=${value} leaves icon in middle`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, createIconDriver, }) {
|
|
280
|
+
yield initTestBed(`<Button icon="test" iconPosition="${value}" />`, {
|
|
281
|
+
resources: {
|
|
282
|
+
"icon.test": "resources/bell.svg",
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
const buttonDriver = yield createButtonDriver();
|
|
286
|
+
const iconDriver = yield createIconDriver(buttonDriver.getIcons().first());
|
|
287
|
+
const { buttonContentLeft, buttonContentRight, iconLeft, iconRight } = yield iconPositionCalculation(buttonDriver, iconDriver);
|
|
288
|
+
(0, fixtures_1.expect)(buttonContentLeft).toBeCloseTo(iconLeft, 5);
|
|
289
|
+
(0, fixtures_1.expect)(buttonContentRight).toBeCloseTo(iconRight, 5);
|
|
290
|
+
}));
|
|
291
|
+
});
|
|
292
|
+
// With label
|
|
293
|
+
iconPositionCases.forEach(({ position, value }) => {
|
|
294
|
+
(0, fixtures_1.test)(`iconPosition=${value} places icon on the ${position} of label`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, createIconDriver, }) {
|
|
295
|
+
yield initTestBed(`<Button icon="test" label="hello" iconPosition="${value}" />`, {
|
|
296
|
+
resources: {
|
|
297
|
+
"icon.test": "resources/bell.svg",
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
const buttonDriver = yield createButtonDriver();
|
|
301
|
+
const iconDriver = yield createIconDriver(buttonDriver.getIcons().first());
|
|
302
|
+
const { buttonContentLeft, buttonContentRight, iconLeft, iconRight } = yield iconPositionCalculation(buttonDriver, iconDriver);
|
|
303
|
+
// Depending on orientation, the icon's leftmost and rightmost points fall shorter
|
|
304
|
+
// compared to the button's leftmost and rightmost points because of the label
|
|
305
|
+
if (value === "start") {
|
|
306
|
+
(0, fixtures_1.expect)(buttonContentLeft).toBeCloseTo(iconLeft, 5);
|
|
307
|
+
(0, fixtures_1.expect)(buttonContentRight).toBeGreaterThan(iconRight + 1);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
(0, fixtures_1.expect)(buttonContentLeft).toBeLessThan(iconLeft - 1);
|
|
311
|
+
(0, fixtures_1.expect)(buttonContentRight).toBeCloseTo(iconRight, 5);
|
|
312
|
+
}
|
|
313
|
+
}));
|
|
314
|
+
});
|
|
315
|
+
// With children
|
|
316
|
+
iconPositionCases.forEach(({ position, value }) => {
|
|
317
|
+
(0, fixtures_1.test)(`iconPosition=${value} places icon on ${position} of children`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, createIconDriver, }) {
|
|
318
|
+
yield initTestBed(`<Button icon="test" iconPosition="${value}">
|
|
319
|
+
<Card title="Test">This is some content</Card>
|
|
320
|
+
</Button>`, {
|
|
321
|
+
resources: {
|
|
322
|
+
"icon.test": "resources/bell.svg",
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
const buttonDriver = yield createButtonDriver();
|
|
326
|
+
const iconDriver = yield createIconDriver(buttonDriver.getIcons().first());
|
|
327
|
+
const { buttonContentLeft, buttonContentRight, iconLeft, iconRight } = yield iconPositionCalculation(buttonDriver, iconDriver);
|
|
328
|
+
// Depending on orientation, the icon's leftmost and rightmost points fall shorter
|
|
329
|
+
// compared to the button's leftmost and rightmost points because of the children
|
|
330
|
+
if (value === "start") {
|
|
331
|
+
(0, fixtures_1.expect)(buttonContentLeft).toBeCloseTo(iconLeft, 5);
|
|
332
|
+
(0, fixtures_1.expect)(buttonContentRight).toBeGreaterThan(iconRight + 1);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
(0, fixtures_1.expect)(buttonContentLeft).toBeLessThan(iconLeft - 1);
|
|
336
|
+
(0, fixtures_1.expect)(buttonContentRight).toBeCloseTo(iconRight, 5);
|
|
337
|
+
}
|
|
338
|
+
}));
|
|
339
|
+
});
|
|
340
|
+
// --- contentPosition
|
|
341
|
+
abstractions_1.alignmentOptionValues.forEach((pos) => {
|
|
342
|
+
(0, fixtures_1.test)(`label and icon is positioned to the ${pos}`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
343
|
+
yield initTestBed(`<Button width="100%" icon="test" label="hello" contentPosition="${pos}" />`, {
|
|
344
|
+
resources: {
|
|
345
|
+
"icon.test": "resources/bell.svg",
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveCSS("justify-content", pos);
|
|
349
|
+
}));
|
|
350
|
+
});
|
|
351
|
+
// --- type
|
|
352
|
+
abstractions_1.buttonTypeValues.forEach((type) => {
|
|
353
|
+
(0, fixtures_1.test)(`type="${type}" is reflected in html`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
354
|
+
yield initTestBed(`<Button type="${type}" />`);
|
|
355
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toHaveAttribute("type", type);
|
|
356
|
+
}));
|
|
357
|
+
});
|
|
358
|
+
// --- autoFocus
|
|
359
|
+
(0, fixtures_1.test)("focuses component if autoFocus is set", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
360
|
+
yield initTestBed(`<Button autoFocus="{true}" />`);
|
|
361
|
+
yield (0, fixtures_1.expect)((yield createButtonDriver()).component).toBeFocused();
|
|
362
|
+
}));
|
|
363
|
+
// --- size
|
|
364
|
+
// Relative testing is acceptable for now - basis of the test is the default size
|
|
365
|
+
(0, fixtures_1.test)("relative size test", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page }) {
|
|
366
|
+
const components = abstractions_2.sizeValues
|
|
367
|
+
.map((size) => {
|
|
368
|
+
return `<Button testId="${size}" size="${size}" />`;
|
|
369
|
+
})
|
|
370
|
+
.join("\n");
|
|
371
|
+
yield initTestBed(`<Fragment>${components}</Fragment>`);
|
|
372
|
+
const { width: widthXs, height: heightXs } = yield (0, component_test_helpers_1.getBounds)(page.getByTestId("xs"));
|
|
373
|
+
const { width: widthSm, height: heightSm } = yield (0, component_test_helpers_1.getBounds)(page.getByTestId("sm"));
|
|
374
|
+
const { width: widthMd, height: heightMd } = yield (0, component_test_helpers_1.getBounds)(page.getByTestId("md"));
|
|
375
|
+
const { width: widthLg, height: heightLg } = yield (0, component_test_helpers_1.getBounds)(page.getByTestId("lg"));
|
|
376
|
+
(0, fixtures_1.expect)(widthXs).toBeLessThanOrEqual(widthSm);
|
|
377
|
+
(0, fixtures_1.expect)(widthSm).toBeLessThanOrEqual(widthMd);
|
|
378
|
+
(0, fixtures_1.expect)(widthMd).toBeLessThanOrEqual(widthLg);
|
|
379
|
+
(0, fixtures_1.expect)(heightXs).toBeLessThanOrEqual(heightSm);
|
|
380
|
+
(0, fixtures_1.expect)(heightSm).toBeLessThanOrEqual(heightMd);
|
|
381
|
+
(0, fixtures_1.expect)(heightMd).toBeLessThanOrEqual(heightLg);
|
|
382
|
+
}));
|
|
383
|
+
(0, fixtures_1.test)(`invalid size falls back to default ${ButtonNative_1.defaultProps.size}`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, }) {
|
|
384
|
+
yield initTestBed(`
|
|
385
|
+
<Fragment>
|
|
386
|
+
<Button testId="reference" size="${ButtonNative_1.defaultProps.size}" />
|
|
387
|
+
<Button testId="invalid" size="invalid"/>
|
|
388
|
+
</Fragment>
|
|
389
|
+
`);
|
|
390
|
+
const reference = page.getByTestId("reference");
|
|
391
|
+
const invalid = page.getByTestId("invalid");
|
|
392
|
+
const { width: widthRef, height: heightRef } = yield (0, component_test_helpers_1.getBounds)(reference);
|
|
393
|
+
const { width: widthInvalid, height: heightInvalid } = yield (0, component_test_helpers_1.getBounds)(invalid);
|
|
394
|
+
yield (0, fixtures_1.expect)(invalid).toBeVisible();
|
|
395
|
+
(0, fixtures_1.expect)(widthInvalid).toBe(widthRef);
|
|
396
|
+
(0, fixtures_1.expect)(heightInvalid).toBe(heightRef);
|
|
397
|
+
}));
|
|
398
|
+
(0, fixtures_1.test)(`no size prop defaults to ${ButtonNative_1.defaultProps.size}`, (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, page, }) {
|
|
399
|
+
yield initTestBed(`<Fragment>
|
|
400
|
+
<Button testId="reference" size="${ButtonNative_1.defaultProps.size}" />
|
|
401
|
+
<Button testId="default" />
|
|
402
|
+
</Fragment>`);
|
|
403
|
+
const reference = page.getByTestId("reference");
|
|
404
|
+
const defaultButton = page.getByTestId("default");
|
|
405
|
+
const { width: widthRef, height: heightRef } = yield (0, component_test_helpers_1.getBounds)(reference);
|
|
406
|
+
const { width: widthDefault, height: heightDefault } = yield (0, component_test_helpers_1.getBounds)(defaultButton);
|
|
407
|
+
yield (0, fixtures_1.expect)(defaultButton).toBeVisible();
|
|
408
|
+
(0, fixtures_1.expect)(widthDefault).toBe(widthRef);
|
|
409
|
+
(0, fixtures_1.expect)(heightDefault).toBe(heightRef);
|
|
410
|
+
}));
|
|
411
|
+
(0, fixtures_1.test)("testState initializes to default value", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed }) {
|
|
412
|
+
const getState = (yield initTestBed(`<Fragment />`)).testStateDriver.testState;
|
|
413
|
+
yield fixtures_1.expect.poll(getState).toEqual(null);
|
|
414
|
+
}));
|
|
415
|
+
// --- gotFocus
|
|
416
|
+
(0, fixtures_1.test)("is focused & gotFocus event fires", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
417
|
+
const { testStateDriver } = yield initTestBed(`<Button onGotFocus="testState = true" />`);
|
|
418
|
+
const driver = yield createButtonDriver();
|
|
419
|
+
yield driver.focus();
|
|
420
|
+
yield (0, fixtures_1.expect)(driver.component).toBeFocused();
|
|
421
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual(true);
|
|
422
|
+
}));
|
|
423
|
+
(0, fixtures_1.test)("gotFocus event does not fire if disabled", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
424
|
+
const { testStateDriver } = yield initTestBed(`<Button enabled="false" onGotFocus="testState = true" />`);
|
|
425
|
+
const driver = yield createButtonDriver();
|
|
426
|
+
yield driver.focus();
|
|
427
|
+
// testState remains unchanged
|
|
428
|
+
yield (0, fixtures_1.expect)(driver.component).not.toBeFocused();
|
|
429
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual(null);
|
|
430
|
+
}));
|
|
431
|
+
// --- lostFocus
|
|
432
|
+
(0, fixtures_1.test)("lostFocus event fires & is not focused", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
433
|
+
const { testStateDriver } = yield initTestBed(`<Button onLostFocus="testState = true" />`);
|
|
434
|
+
const driver = yield createButtonDriver();
|
|
435
|
+
yield driver.focus();
|
|
436
|
+
yield driver.blur();
|
|
437
|
+
yield (0, fixtures_1.expect)(driver.component).not.toBeFocused();
|
|
438
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual(true);
|
|
439
|
+
}));
|
|
440
|
+
(0, fixtures_1.test)("cannot emit lostFocus event if not focused before", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver, }) {
|
|
441
|
+
const { testStateDriver } = yield initTestBed(`<Button onLostFocus="testState = true" />`);
|
|
442
|
+
const driver = yield createButtonDriver();
|
|
443
|
+
yield driver.blur();
|
|
444
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual(null);
|
|
445
|
+
}));
|
|
446
|
+
(0, fixtures_1.test)("lostFocus event does not fire if disabled", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createButtonDriver }) {
|
|
447
|
+
const { testStateDriver } = yield initTestBed(`<Button enabled="false" onLostFocus="testState = true" />`);
|
|
448
|
+
const driver = yield createButtonDriver();
|
|
449
|
+
yield driver.focus();
|
|
450
|
+
yield driver.blur();
|
|
451
|
+
// testState remains unchanged
|
|
452
|
+
yield (0, fixtures_1.expect)(driver.component).not.toBeFocused();
|
|
453
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual(null);
|
|
454
|
+
}));
|
|
@@ -0,0 +1,150 @@
|
|
|
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 component_test_helpers_1 = require("../../testing/component-test-helpers");
|
|
13
|
+
const fixtures_1 = require("../../testing/fixtures");
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// BASIC FUNCTIONALITY TESTS
|
|
16
|
+
// =============================================================================
|
|
17
|
+
fixtures_1.test.describe("Basic Functionality", () => {
|
|
18
|
+
(0, fixtures_1.test)("Card renders", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createCardDriver }) {
|
|
19
|
+
yield initTestBed(`<Card />`);
|
|
20
|
+
const driver = yield createCardDriver();
|
|
21
|
+
yield (0, fixtures_1.expect)(driver.component).toBeVisible();
|
|
22
|
+
}));
|
|
23
|
+
(0, fixtures_1.test)("Card renders with title", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createCardDriver }) {
|
|
24
|
+
yield initTestBed(`<Card title="Test Title" />`);
|
|
25
|
+
const title = (yield createCardDriver()).component.getByRole("heading");
|
|
26
|
+
yield (0, fixtures_1.expect)(title).toBeVisible();
|
|
27
|
+
yield (0, fixtures_1.expect)(title).toHaveText("Test Title");
|
|
28
|
+
}));
|
|
29
|
+
(0, fixtures_1.test)("Card renders with subtitle", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createCardDriver }) {
|
|
30
|
+
yield initTestBed(`<Card subtitle="Test Subtitle" />`);
|
|
31
|
+
const subtitle = (yield createCardDriver()).component.locator("div").first();
|
|
32
|
+
yield (0, fixtures_1.expect)(subtitle).toBeVisible();
|
|
33
|
+
yield (0, fixtures_1.expect)(subtitle).toHaveText("Test Subtitle");
|
|
34
|
+
}));
|
|
35
|
+
(0, fixtures_1.test)("Card renders with both title and subtitle", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createCardDriver }) {
|
|
36
|
+
yield initTestBed(`
|
|
37
|
+
<Card title="Test Title" subtitle="Test Subtitle">
|
|
38
|
+
<Text value="Card content" />
|
|
39
|
+
</Card>
|
|
40
|
+
`);
|
|
41
|
+
const driver = yield createCardDriver();
|
|
42
|
+
const title = driver.component.getByRole("heading");
|
|
43
|
+
const subtitle = driver.component.getByText("Test Subtitle");
|
|
44
|
+
yield (0, fixtures_1.expect)(title).toHaveText("Test Title");
|
|
45
|
+
yield (0, fixtures_1.expect)(subtitle).toBeVisible();
|
|
46
|
+
}));
|
|
47
|
+
(0, fixtures_1.test)("displays avatar when avatarUrl is provided", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createCardDriver }) {
|
|
48
|
+
yield initTestBed(`<Card avatarUrl="/resources/flower-640x480.jpg" />`);
|
|
49
|
+
const avatar = (yield createCardDriver()).avatar;
|
|
50
|
+
yield (0, fixtures_1.expect)(avatar).toBeVisible();
|
|
51
|
+
yield (0, fixtures_1.expect)(avatar).toHaveAttribute("src", "/resources/flower-640x480.jpg");
|
|
52
|
+
}));
|
|
53
|
+
(0, fixtures_1.test)("clicking linkTo title navigates", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed, createCardDriver }) {
|
|
54
|
+
yield initTestBed(`<Card title="Clickable Title" linkTo="/test-link" />`);
|
|
55
|
+
const titleLink = (yield createCardDriver()).component.getByRole("link", {
|
|
56
|
+
name: "Clickable Title",
|
|
57
|
+
});
|
|
58
|
+
yield titleLink.click();
|
|
59
|
+
yield (0, fixtures_1.expect)(page).toHaveURL(/\/test-link$/);
|
|
60
|
+
}));
|
|
61
|
+
(0, fixtures_1.test)("showAvatar=false hides avatar even when avatarUrl is provided", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createCardDriver, }) {
|
|
62
|
+
yield initTestBed(`
|
|
63
|
+
<Card avatarUrl="https://i.pravatar.cc/100" showAvatar="false" title="Test Title" />
|
|
64
|
+
`);
|
|
65
|
+
const driver = yield createCardDriver();
|
|
66
|
+
yield (0, fixtures_1.expect)(driver.avatar).not.toBeVisible();
|
|
67
|
+
yield (0, fixtures_1.expect)(driver.component.getByText("Test Title")).toBeVisible();
|
|
68
|
+
}));
|
|
69
|
+
(0, fixtures_1.test)("showAvatar displays initials with single word title", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createCardDriver, }) {
|
|
70
|
+
yield initTestBed(`<Card showAvatar="true" title="John" />`);
|
|
71
|
+
yield (0, fixtures_1.expect)((yield createCardDriver()).component.getByText("J", { exact: true })).toBeVisible();
|
|
72
|
+
}));
|
|
73
|
+
(0, fixtures_1.test)("showAvatar=true with empty title displays no initials", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createCardDriver, }) {
|
|
74
|
+
yield initTestBed(`<Card showAvatar="true" />`);
|
|
75
|
+
const avatar = (yield createCardDriver()).avatar;
|
|
76
|
+
yield (0, fixtures_1.expect)(avatar).toHaveText(/^$/);
|
|
77
|
+
}));
|
|
78
|
+
(0, fixtures_1.test)("linkTo without title does not create link", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createCardDriver }) {
|
|
79
|
+
yield initTestBed(`
|
|
80
|
+
<Card linkTo="/test-link">
|
|
81
|
+
<Text value="Content" />
|
|
82
|
+
</Card>
|
|
83
|
+
`);
|
|
84
|
+
const driver = yield createCardDriver();
|
|
85
|
+
yield (0, fixtures_1.expect)(driver.component.getByRole("link")).not.toBeVisible();
|
|
86
|
+
yield (0, fixtures_1.expect)(driver.component.getByText("Content")).toBeVisible();
|
|
87
|
+
}));
|
|
88
|
+
(0, fixtures_1.test)("orientation horizontal displays children in row", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createTextDriver, }) {
|
|
89
|
+
yield initTestBed(`
|
|
90
|
+
<Card orientation="horizontal">
|
|
91
|
+
<Text testId="text-1" value="Child 1" />
|
|
92
|
+
<Text testId="text-2" value="Child 2" />
|
|
93
|
+
</Card>
|
|
94
|
+
`);
|
|
95
|
+
const text1Driver = yield createTextDriver("text-1");
|
|
96
|
+
const text2Driver = yield createTextDriver("text-2");
|
|
97
|
+
const { right: text1Right } = yield (0, component_test_helpers_1.getBounds)(text1Driver);
|
|
98
|
+
const { right: text2Left } = yield (0, component_test_helpers_1.getBounds)(text2Driver);
|
|
99
|
+
(0, fixtures_1.expect)(text1Right).toBeLessThan(text2Left);
|
|
100
|
+
}));
|
|
101
|
+
(0, fixtures_1.test)("orientation vertical displays children in column", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createTextDriver, }) {
|
|
102
|
+
yield initTestBed(`
|
|
103
|
+
<Card orientation="vertical">
|
|
104
|
+
<Text testId="text-1" value="Child 1" />
|
|
105
|
+
<Text testId="text-2" value="Child 2" />
|
|
106
|
+
</Card>
|
|
107
|
+
`);
|
|
108
|
+
const text1Driver = yield createTextDriver("text-1");
|
|
109
|
+
const text2Driver = yield createTextDriver("text-2");
|
|
110
|
+
const { bottom: text1Bottom } = yield (0, component_test_helpers_1.getBounds)(text1Driver);
|
|
111
|
+
const { top: text2Top } = yield (0, component_test_helpers_1.getBounds)(text2Driver);
|
|
112
|
+
(0, fixtures_1.expect)(text1Bottom).toBeLessThan(text2Top);
|
|
113
|
+
}));
|
|
114
|
+
});
|
|
115
|
+
// =============================================================================
|
|
116
|
+
// EVENT HANDLING TESTS
|
|
117
|
+
// =============================================================================
|
|
118
|
+
fixtures_1.test.describe("Event Handling", () => {
|
|
119
|
+
(0, fixtures_1.test)("click event is triggered when Card is clicked", (_a) => __awaiter(void 0, [_a], void 0, function* ({ initTestBed, createCardDriver, }) {
|
|
120
|
+
const { testStateDriver } = yield initTestBed(`<Card onClick="testState = true" />`);
|
|
121
|
+
yield (yield createCardDriver()).click();
|
|
122
|
+
yield fixtures_1.expect.poll(testStateDriver.testState).toEqual(true);
|
|
123
|
+
}));
|
|
124
|
+
(0, fixtures_1.test)("Card click does not interfere with link click", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed, createCardDriver, createTextDriver, }) {
|
|
125
|
+
yield initTestBed(`
|
|
126
|
+
<Card title="Title" linkTo="/test-link" onClick="testState = true">
|
|
127
|
+
<Text testId="text-1" when="{testState}" value="visible" />
|
|
128
|
+
</Card>
|
|
129
|
+
`);
|
|
130
|
+
const cardDriver = yield createCardDriver();
|
|
131
|
+
const textDriver = yield createTextDriver("text-1");
|
|
132
|
+
yield cardDriver.click();
|
|
133
|
+
yield (0, fixtures_1.expect)(textDriver.component).toHaveText("visible");
|
|
134
|
+
yield (0, fixtures_1.expect)(page).not.toHaveURL(/\/test-link$/);
|
|
135
|
+
}));
|
|
136
|
+
(0, fixtures_1.test)("Link click does not interfere with Card click", (_a) => __awaiter(void 0, [_a], void 0, function* ({ page, initTestBed, createCardDriver, createTextDriver, }) {
|
|
137
|
+
const { testStateDriver } = yield initTestBed(`
|
|
138
|
+
<Card title="Title" linkTo="/test-link" onClick="testState = true">
|
|
139
|
+
<Text testId="text-1" when="{testState}" value="visible" />
|
|
140
|
+
</Card>
|
|
141
|
+
`);
|
|
142
|
+
const textDriver = yield createTextDriver("text-1");
|
|
143
|
+
const title = (yield createCardDriver()).component.getByRole("heading");
|
|
144
|
+
yield (0, fixtures_1.expect)(textDriver.component).not.toBeVisible();
|
|
145
|
+
yield title.click();
|
|
146
|
+
yield page.waitForTimeout(200);
|
|
147
|
+
yield (0, fixtures_1.expect)(page).toHaveURL(/\/test-link$/);
|
|
148
|
+
yield (0, fixtures_1.expect)(textDriver.component).toBeVisible();
|
|
149
|
+
}));
|
|
150
|
+
});
|