@ebertjendustries/cstestwrapper 1.0.15 → 1.0.17
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/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +46 -16
- package/dist/index.mjs +35 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as RealRestClient from '@ebertjendustries/cswrapper';
|
|
2
2
|
import { LocalisationNamespace, Localiser, FieldSpec, EnumFactory, ViewSpec, IViewElementSpec, LocalisationVariableType, CSVNoItemsViewElements, CSVPriceInputViewElements, IPrice, CSVSearchFilterViewElements, CSVTextPromptModalViewElements, PropertyChangeFunction } from '@ebertjendustries/cswrapper';
|
|
3
|
-
import { MultiselectWrapper, SelectWrapper, InputWrapper, DatePickerWrapper, TableWrapper, WizardWrapper, ButtonWrapper, ButtonDropdownWrapper, ModalWrapper, CheckboxWrapper, HeaderWrapper, BoxWrapper, CollectionPreferencesWrapper, LinkWrapper, ToggleWrapper, FlashbarWrapper, SegmentedControlWrapper, AlertWrapper, StatusIndicatorWrapper, CardsWrapper, TextareaWrapper, TabsWrapper, TextFilterWrapper, TextContentWrapper, PaginationWrapper, FormWrapper, ProgressBarWrapper, IconWrapper, ElementWrapper as ElementWrapper$1, FormFieldWrapper } from '@cloudscape-design/components/test-utils/dom';
|
|
3
|
+
import { MultiselectWrapper, SelectWrapper, InputWrapper, DatePickerWrapper, TableWrapper, WizardWrapper, ButtonWrapper, ButtonDropdownWrapper, ModalWrapper, CheckboxWrapper, HeaderWrapper, BoxWrapper, CollectionPreferencesWrapper, LinkWrapper, ToggleWrapper, FlashbarWrapper, SegmentedControlWrapper, AlertWrapper, StatusIndicatorWrapper, CardsWrapper, TextareaWrapper, TabsWrapper, TextFilterWrapper, TextContentWrapper, PaginationWrapper, FormWrapper, ProgressBarWrapper, IconWrapper, CopyToClipboardWrapper, ElementWrapper as ElementWrapper$1, FormFieldWrapper } from '@cloudscape-design/components/test-utils/dom';
|
|
4
4
|
import { ElementWrapper, ComponentWrapper } from '@cloudscape-design/test-utils-core/dom';
|
|
5
5
|
import DropdownHostComponentWrapper from '@cloudscape-design/components/test-utils/dom/internal/dropdown-host';
|
|
6
6
|
import * as vitest from 'vitest';
|
|
@@ -336,6 +336,13 @@ declare class IconTesting extends AbstractComponentTesting<IconWrapper, FieldSpe
|
|
|
336
336
|
constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
+
declare class CopyToClipboardTesting extends AbstractComponentTesting<CopyToClipboardWrapper, FieldSpec> {
|
|
340
|
+
protected view: AbstractViewTesting<any>;
|
|
341
|
+
constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
|
|
342
|
+
expectEnabled(): void;
|
|
343
|
+
copyText(text: string | RegExp): Promise<void>;
|
|
344
|
+
}
|
|
345
|
+
|
|
339
346
|
/**
|
|
340
347
|
* Convenience factory to create each CS component testing class. It injects the parent view directly.
|
|
341
348
|
*/
|
|
@@ -357,6 +364,7 @@ declare class TestingFactory {
|
|
|
357
364
|
header(fieldSpec: FieldSpec): HeaderTesting;
|
|
358
365
|
box(fieldSpec: FieldSpec): BoxTesting;
|
|
359
366
|
collectionPreferences(fieldSpec: FieldSpec, pageSizes: number[]): CollectionPreferencesTesting;
|
|
367
|
+
copyToClipboard(fieldSpec: FieldSpec): CopyToClipboardTesting;
|
|
360
368
|
link(fieldSpec: FieldSpec): LinkTesting;
|
|
361
369
|
toggle(fieldSpec: FieldSpec): ToggleTesting;
|
|
362
370
|
flashbar(fieldSpec: FieldSpec): FlashbarTesting;
|
|
@@ -571,4 +579,4 @@ declare class ViewTestWrapperProps<T> {
|
|
|
571
579
|
}
|
|
572
580
|
declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): react_jsx_runtime.JSX.Element;
|
|
573
581
|
|
|
574
|
-
export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, MockServerBuilder, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
|
|
582
|
+
export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, CopyToClipboardTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, MockServerBuilder, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as RealRestClient from '@ebertjendustries/cswrapper';
|
|
2
2
|
import { LocalisationNamespace, Localiser, FieldSpec, EnumFactory, ViewSpec, IViewElementSpec, LocalisationVariableType, CSVNoItemsViewElements, CSVPriceInputViewElements, IPrice, CSVSearchFilterViewElements, CSVTextPromptModalViewElements, PropertyChangeFunction } from '@ebertjendustries/cswrapper';
|
|
3
|
-
import { MultiselectWrapper, SelectWrapper, InputWrapper, DatePickerWrapper, TableWrapper, WizardWrapper, ButtonWrapper, ButtonDropdownWrapper, ModalWrapper, CheckboxWrapper, HeaderWrapper, BoxWrapper, CollectionPreferencesWrapper, LinkWrapper, ToggleWrapper, FlashbarWrapper, SegmentedControlWrapper, AlertWrapper, StatusIndicatorWrapper, CardsWrapper, TextareaWrapper, TabsWrapper, TextFilterWrapper, TextContentWrapper, PaginationWrapper, FormWrapper, ProgressBarWrapper, IconWrapper, ElementWrapper as ElementWrapper$1, FormFieldWrapper } from '@cloudscape-design/components/test-utils/dom';
|
|
3
|
+
import { MultiselectWrapper, SelectWrapper, InputWrapper, DatePickerWrapper, TableWrapper, WizardWrapper, ButtonWrapper, ButtonDropdownWrapper, ModalWrapper, CheckboxWrapper, HeaderWrapper, BoxWrapper, CollectionPreferencesWrapper, LinkWrapper, ToggleWrapper, FlashbarWrapper, SegmentedControlWrapper, AlertWrapper, StatusIndicatorWrapper, CardsWrapper, TextareaWrapper, TabsWrapper, TextFilterWrapper, TextContentWrapper, PaginationWrapper, FormWrapper, ProgressBarWrapper, IconWrapper, CopyToClipboardWrapper, ElementWrapper as ElementWrapper$1, FormFieldWrapper } from '@cloudscape-design/components/test-utils/dom';
|
|
4
4
|
import { ElementWrapper, ComponentWrapper } from '@cloudscape-design/test-utils-core/dom';
|
|
5
5
|
import DropdownHostComponentWrapper from '@cloudscape-design/components/test-utils/dom/internal/dropdown-host';
|
|
6
6
|
import * as vitest from 'vitest';
|
|
@@ -336,6 +336,13 @@ declare class IconTesting extends AbstractComponentTesting<IconWrapper, FieldSpe
|
|
|
336
336
|
constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
+
declare class CopyToClipboardTesting extends AbstractComponentTesting<CopyToClipboardWrapper, FieldSpec> {
|
|
340
|
+
protected view: AbstractViewTesting<any>;
|
|
341
|
+
constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
|
|
342
|
+
expectEnabled(): void;
|
|
343
|
+
copyText(text: string | RegExp): Promise<void>;
|
|
344
|
+
}
|
|
345
|
+
|
|
339
346
|
/**
|
|
340
347
|
* Convenience factory to create each CS component testing class. It injects the parent view directly.
|
|
341
348
|
*/
|
|
@@ -357,6 +364,7 @@ declare class TestingFactory {
|
|
|
357
364
|
header(fieldSpec: FieldSpec): HeaderTesting;
|
|
358
365
|
box(fieldSpec: FieldSpec): BoxTesting;
|
|
359
366
|
collectionPreferences(fieldSpec: FieldSpec, pageSizes: number[]): CollectionPreferencesTesting;
|
|
367
|
+
copyToClipboard(fieldSpec: FieldSpec): CopyToClipboardTesting;
|
|
360
368
|
link(fieldSpec: FieldSpec): LinkTesting;
|
|
361
369
|
toggle(fieldSpec: FieldSpec): ToggleTesting;
|
|
362
370
|
flashbar(fieldSpec: FieldSpec): FlashbarTesting;
|
|
@@ -571,4 +579,4 @@ declare class ViewTestWrapperProps<T> {
|
|
|
571
579
|
}
|
|
572
580
|
declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): react_jsx_runtime.JSX.Element;
|
|
573
581
|
|
|
574
|
-
export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, MockServerBuilder, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
|
|
582
|
+
export { AbstractComponentTesting, AbstractInputTesting, AbstractSelectTesting, AbstractViewTesting, AlertTesting, BoxTesting, ButtonDropdownTesting, ButtonTesting, CSVNoItemsViewTesting, CSVPriceInputViewTesting, CSVSearchFilterViewTesting, CSVTextPromptModalViewTesting, CardsTesting, CheckboxTesting, CollectionPreferencesSetting, CollectionPreferencesTesting, CopyToClipboardTesting, DatePickerTesting, FlashbarTesting, FormTesting, HeaderTesting, IconTesting, LinkTesting, MockBrowserAPIs, MockRestClient, MockServerBuilder, ModalTesting, MultiselectTesting, NumberInputTesting, PaginationTesting, ProgressBarTesting, RatingTesting, SegmentedControlTesting, SelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ __export(index_exports, {
|
|
|
46
46
|
CheckboxTesting: () => CheckboxTesting,
|
|
47
47
|
CollectionPreferencesSetting: () => CollectionPreferencesSetting,
|
|
48
48
|
CollectionPreferencesTesting: () => CollectionPreferencesTesting,
|
|
49
|
+
CopyToClipboardTesting: () => CopyToClipboardTesting,
|
|
49
50
|
DatePickerTesting: () => DatePickerTesting,
|
|
50
51
|
FlashbarTesting: () => FlashbarTesting,
|
|
51
52
|
FormTesting: () => FormTesting,
|
|
@@ -976,8 +977,8 @@ var FlashbarTesting = class extends AbstractComponentTesting {
|
|
|
976
977
|
await (0, import_react20.waitFor)(() => (0, import_vitest14.expect)(this.getElementWrapper().findItems().length).toBeGreaterThan(0));
|
|
977
978
|
const wrappers = this.getElementWrapper().findItems();
|
|
978
979
|
for (let index = 0; index < wrappers.length; index++) {
|
|
979
|
-
const
|
|
980
|
-
await (0, import_react20.waitFor)(() => (0, import_vitest14.expect)(
|
|
980
|
+
const wrapper30 = wrappers[index];
|
|
981
|
+
await (0, import_react20.waitFor)(() => (0, import_vitest14.expect)(wrapper30.findContent()).not.toBeNull());
|
|
981
982
|
}
|
|
982
983
|
}
|
|
983
984
|
expectMessagePresentCount(text, count, headerMessage) {
|
|
@@ -1285,6 +1286,31 @@ var IconTesting = class extends AbstractComponentTesting {
|
|
|
1285
1286
|
}
|
|
1286
1287
|
};
|
|
1287
1288
|
|
|
1289
|
+
// src/components/CopyToClipboardTesting.ts
|
|
1290
|
+
var import_dom30 = __toESM(require("@cloudscape-design/components/test-utils/dom"));
|
|
1291
|
+
var import_user_event2 = __toESM(require("@testing-library/user-event"));
|
|
1292
|
+
var import_dom31 = require("@testing-library/dom");
|
|
1293
|
+
var import_vitest24 = require("vitest");
|
|
1294
|
+
var CopyToClipboardTesting = class extends AbstractComponentTesting {
|
|
1295
|
+
constructor(fieldSpec, view) {
|
|
1296
|
+
super(fieldSpec, view, (selector) => (0, import_dom30.default)().findCopyToClipboard(selector));
|
|
1297
|
+
this.view = view;
|
|
1298
|
+
}
|
|
1299
|
+
expectEnabled() {
|
|
1300
|
+
AbstractComponentTesting.expectEnabled(this.getElementWrapper().findCopyButton().getElement(), this.msgForExpect());
|
|
1301
|
+
}
|
|
1302
|
+
async copyText(text) {
|
|
1303
|
+
const user = import_user_event2.default.setup();
|
|
1304
|
+
await (0, import_dom31.waitFor)(() => user.click(this.getElementWrapper().findCopyButton().getElement()));
|
|
1305
|
+
if (text !== "") {
|
|
1306
|
+
await (0, import_dom31.waitFor)(async () => {
|
|
1307
|
+
const copiedText = await window.navigator.clipboard.readText();
|
|
1308
|
+
(0, import_vitest24.expect)(copiedText).toEqual(text);
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1288
1314
|
// src/components/TestingFactory.ts
|
|
1289
1315
|
var TestingFactory = class {
|
|
1290
1316
|
constructor(parentView) {
|
|
@@ -1335,6 +1361,9 @@ var TestingFactory = class {
|
|
|
1335
1361
|
collectionPreferences(fieldSpec, pageSizes) {
|
|
1336
1362
|
return new CollectionPreferencesTesting(fieldSpec, this.parentView, pageSizes);
|
|
1337
1363
|
}
|
|
1364
|
+
copyToClipboard(fieldSpec) {
|
|
1365
|
+
return new CopyToClipboardTesting(fieldSpec, this.parentView);
|
|
1366
|
+
}
|
|
1338
1367
|
link(fieldSpec) {
|
|
1339
1368
|
return new LinkTesting(fieldSpec, this.parentView);
|
|
1340
1369
|
}
|
|
@@ -1385,8 +1414,8 @@ var TestingFactory = class {
|
|
|
1385
1414
|
// src/views/AbstractViewTesting.tsx
|
|
1386
1415
|
var import_react29 = require("@testing-library/react");
|
|
1387
1416
|
var import_fs = require("fs");
|
|
1388
|
-
var
|
|
1389
|
-
var
|
|
1417
|
+
var import_user_event3 = __toESM(require("@testing-library/user-event"));
|
|
1418
|
+
var import_vitest25 = require("vitest");
|
|
1390
1419
|
var AbstractViewTesting = class {
|
|
1391
1420
|
constructor(namespace, viewSpec, testLocalisation) {
|
|
1392
1421
|
this.namespace = namespace;
|
|
@@ -1416,7 +1445,7 @@ var AbstractViewTesting = class {
|
|
|
1416
1445
|
await this.factory.form(viewSpec).awaitPresent();
|
|
1417
1446
|
}
|
|
1418
1447
|
expectViewNotPresent(viewSpec) {
|
|
1419
|
-
(0,
|
|
1448
|
+
(0, import_vitest25.expect)(import_react29.screen.queryByTestId(viewSpec.getDataTestId())).not.toBeInTheDocument();
|
|
1420
1449
|
}
|
|
1421
1450
|
translate(key, variables, alternateNs) {
|
|
1422
1451
|
return this.getLocaliser().localiseKey(key, variables, alternateNs);
|
|
@@ -1425,7 +1454,7 @@ var AbstractViewTesting = class {
|
|
|
1425
1454
|
* To test triggering the default action, e.g. form submit, by pressing enter.
|
|
1426
1455
|
*/
|
|
1427
1456
|
async pressEnter(element) {
|
|
1428
|
-
await
|
|
1457
|
+
await import_user_event3.default.type(element, "{enter}");
|
|
1429
1458
|
}
|
|
1430
1459
|
};
|
|
1431
1460
|
|
|
@@ -1592,18 +1621,18 @@ var CSVTextPromptModalViewTesting = class extends AbstractViewTesting {
|
|
|
1592
1621
|
};
|
|
1593
1622
|
|
|
1594
1623
|
// src/mocks/MockBrowserAPIs.ts
|
|
1595
|
-
var
|
|
1624
|
+
var import_vitest26 = require("vitest");
|
|
1596
1625
|
var realDateNow = global.Date.now;
|
|
1597
1626
|
var MockBrowserAPIs = class {
|
|
1598
1627
|
static mockConfirmAlways(confirm) {
|
|
1599
|
-
return window.confirm =
|
|
1628
|
+
return window.confirm = import_vitest26.vi.fn().mockImplementation(() => confirm);
|
|
1600
1629
|
}
|
|
1601
1630
|
static mockScroll() {
|
|
1602
|
-
return window.scrollTo =
|
|
1631
|
+
return window.scrollTo = import_vitest26.vi.fn();
|
|
1603
1632
|
}
|
|
1604
1633
|
static mockDateNow(epochMillisToReturn) {
|
|
1605
1634
|
realDateNow = Date.now.bind(global.Date);
|
|
1606
|
-
const dateNowStub =
|
|
1635
|
+
const dateNowStub = import_vitest26.vi.fn(() => epochMillisToReturn);
|
|
1607
1636
|
global.Date.now = dateNowStub;
|
|
1608
1637
|
return dateNowStub;
|
|
1609
1638
|
}
|
|
@@ -1613,7 +1642,7 @@ var MockBrowserAPIs = class {
|
|
|
1613
1642
|
};
|
|
1614
1643
|
|
|
1615
1644
|
// src/mocks/MockRestClient.ts
|
|
1616
|
-
var
|
|
1645
|
+
var import_vitest27 = require("vitest");
|
|
1617
1646
|
var import_console = require("console");
|
|
1618
1647
|
var import_cswrapper12 = require("@ebertjendustries/cswrapper");
|
|
1619
1648
|
var import_cswrapper13 = require("@ebertjendustries/cswrapper");
|
|
@@ -1664,7 +1693,7 @@ var MockResponseStore = class {
|
|
|
1664
1693
|
};
|
|
1665
1694
|
function setupRestClientMock(controllerSpec) {
|
|
1666
1695
|
const mockRestClient = new MockRestClient(controllerSpec.key);
|
|
1667
|
-
const mock =
|
|
1696
|
+
const mock = import_vitest27.vi.spyOn(RealRestClient, "createRestClient");
|
|
1668
1697
|
LOGGER.info(`Setting up mock rest client with key ${controllerSpec.key}.`);
|
|
1669
1698
|
mock.mockImplementation(() => {
|
|
1670
1699
|
return mockRestClient;
|
|
@@ -1673,10 +1702,10 @@ function setupRestClientMock(controllerSpec) {
|
|
|
1673
1702
|
}
|
|
1674
1703
|
var MockRestClient = class {
|
|
1675
1704
|
constructor(name) {
|
|
1676
|
-
this.get =
|
|
1677
|
-
this.put =
|
|
1678
|
-
this.post =
|
|
1679
|
-
this.del =
|
|
1705
|
+
this.get = import_vitest27.vi.fn();
|
|
1706
|
+
this.put = import_vitest27.vi.fn();
|
|
1707
|
+
this.post = import_vitest27.vi.fn();
|
|
1708
|
+
this.del = import_vitest27.vi.fn();
|
|
1680
1709
|
this.uuid = "<" + crypto.randomUUID().split("-")[4] + ">";
|
|
1681
1710
|
LOGGER.info(`Instantiating mock rest client with name ${name} and UUID ${this.uuid}.`);
|
|
1682
1711
|
this.getResponseValues = new MockResponseStore(this.uuid);
|
|
@@ -1909,6 +1938,7 @@ function ViewTestWrapper(props) {
|
|
|
1909
1938
|
CheckboxTesting,
|
|
1910
1939
|
CollectionPreferencesSetting,
|
|
1911
1940
|
CollectionPreferencesTesting,
|
|
1941
|
+
CopyToClipboardTesting,
|
|
1912
1942
|
DatePickerTesting,
|
|
1913
1943
|
FlashbarTesting,
|
|
1914
1944
|
FormTesting,
|
package/dist/index.mjs
CHANGED
|
@@ -895,8 +895,8 @@ var FlashbarTesting = class extends AbstractComponentTesting {
|
|
|
895
895
|
await waitFor7(() => expect14(this.getElementWrapper().findItems().length).toBeGreaterThan(0));
|
|
896
896
|
const wrappers = this.getElementWrapper().findItems();
|
|
897
897
|
for (let index = 0; index < wrappers.length; index++) {
|
|
898
|
-
const
|
|
899
|
-
await waitFor7(() => expect14(
|
|
898
|
+
const wrapper30 = wrappers[index];
|
|
899
|
+
await waitFor7(() => expect14(wrapper30.findContent()).not.toBeNull());
|
|
900
900
|
}
|
|
901
901
|
}
|
|
902
902
|
expectMessagePresentCount(text, count, headerMessage) {
|
|
@@ -1204,6 +1204,31 @@ var IconTesting = class extends AbstractComponentTesting {
|
|
|
1204
1204
|
}
|
|
1205
1205
|
};
|
|
1206
1206
|
|
|
1207
|
+
// src/components/CopyToClipboardTesting.ts
|
|
1208
|
+
import wrapper29 from "@cloudscape-design/components/test-utils/dom";
|
|
1209
|
+
import userEvent2 from "@testing-library/user-event";
|
|
1210
|
+
import { waitFor as waitFor11 } from "@testing-library/dom";
|
|
1211
|
+
import { expect as expect24 } from "vitest";
|
|
1212
|
+
var CopyToClipboardTesting = class extends AbstractComponentTesting {
|
|
1213
|
+
constructor(fieldSpec, view) {
|
|
1214
|
+
super(fieldSpec, view, (selector) => wrapper29().findCopyToClipboard(selector));
|
|
1215
|
+
this.view = view;
|
|
1216
|
+
}
|
|
1217
|
+
expectEnabled() {
|
|
1218
|
+
AbstractComponentTesting.expectEnabled(this.getElementWrapper().findCopyButton().getElement(), this.msgForExpect());
|
|
1219
|
+
}
|
|
1220
|
+
async copyText(text) {
|
|
1221
|
+
const user = userEvent2.setup();
|
|
1222
|
+
await waitFor11(() => user.click(this.getElementWrapper().findCopyButton().getElement()));
|
|
1223
|
+
if (text !== "") {
|
|
1224
|
+
await waitFor11(async () => {
|
|
1225
|
+
const copiedText = await window.navigator.clipboard.readText();
|
|
1226
|
+
expect24(copiedText).toEqual(text);
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1207
1232
|
// src/components/TestingFactory.ts
|
|
1208
1233
|
var TestingFactory = class {
|
|
1209
1234
|
constructor(parentView) {
|
|
@@ -1254,6 +1279,9 @@ var TestingFactory = class {
|
|
|
1254
1279
|
collectionPreferences(fieldSpec, pageSizes) {
|
|
1255
1280
|
return new CollectionPreferencesTesting(fieldSpec, this.parentView, pageSizes);
|
|
1256
1281
|
}
|
|
1282
|
+
copyToClipboard(fieldSpec) {
|
|
1283
|
+
return new CopyToClipboardTesting(fieldSpec, this.parentView);
|
|
1284
|
+
}
|
|
1257
1285
|
link(fieldSpec) {
|
|
1258
1286
|
return new LinkTesting(fieldSpec, this.parentView);
|
|
1259
1287
|
}
|
|
@@ -1304,8 +1332,8 @@ var TestingFactory = class {
|
|
|
1304
1332
|
// src/views/AbstractViewTesting.tsx
|
|
1305
1333
|
import { prettyDOM, screen as screen3 } from "@testing-library/react";
|
|
1306
1334
|
import { writeFileSync } from "fs";
|
|
1307
|
-
import
|
|
1308
|
-
import { expect as
|
|
1335
|
+
import userEvent3 from "@testing-library/user-event";
|
|
1336
|
+
import { expect as expect25 } from "vitest";
|
|
1309
1337
|
var AbstractViewTesting = class {
|
|
1310
1338
|
constructor(namespace, viewSpec, testLocalisation) {
|
|
1311
1339
|
this.namespace = namespace;
|
|
@@ -1335,7 +1363,7 @@ var AbstractViewTesting = class {
|
|
|
1335
1363
|
await this.factory.form(viewSpec).awaitPresent();
|
|
1336
1364
|
}
|
|
1337
1365
|
expectViewNotPresent(viewSpec) {
|
|
1338
|
-
|
|
1366
|
+
expect25(screen3.queryByTestId(viewSpec.getDataTestId())).not.toBeInTheDocument();
|
|
1339
1367
|
}
|
|
1340
1368
|
translate(key, variables, alternateNs) {
|
|
1341
1369
|
return this.getLocaliser().localiseKey(key, variables, alternateNs);
|
|
@@ -1344,7 +1372,7 @@ var AbstractViewTesting = class {
|
|
|
1344
1372
|
* To test triggering the default action, e.g. form submit, by pressing enter.
|
|
1345
1373
|
*/
|
|
1346
1374
|
async pressEnter(element) {
|
|
1347
|
-
await
|
|
1375
|
+
await userEvent3.type(element, "{enter}");
|
|
1348
1376
|
}
|
|
1349
1377
|
};
|
|
1350
1378
|
|
|
@@ -1829,6 +1857,7 @@ export {
|
|
|
1829
1857
|
CheckboxTesting,
|
|
1830
1858
|
CollectionPreferencesSetting,
|
|
1831
1859
|
CollectionPreferencesTesting,
|
|
1860
|
+
CopyToClipboardTesting,
|
|
1832
1861
|
DatePickerTesting,
|
|
1833
1862
|
FlashbarTesting,
|
|
1834
1863
|
FormTesting,
|