@ebertjendustries/cstestwrapper 1.0.16 → 1.0.18

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 CHANGED
@@ -1,6 +1,6 @@
1
- import * as RealRestClient from '@ebertjendustries/cswrapper';
1
+ import * as _ebertjendustries_cswrapper 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, CopyToClipboardWrapper } 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';
@@ -143,6 +143,7 @@ declare class ButtonTesting extends AbstractComponentTesting<ButtonWrapper, Fiel
143
143
  awaitLoading(): Promise<void>;
144
144
  awaitNotLoading(): Promise<void>;
145
145
  clickAndWaitForLoadingDone(): Promise<void>;
146
+ expectLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
146
147
  }
147
148
 
148
149
  declare class ButtonDropdownTesting extends AbstractComponentTesting<ButtonDropdownWrapper, FieldSpec> {
@@ -291,6 +292,7 @@ declare class TextareaTesting extends AbstractInputTesting<TextareaWrapper, HTML
291
292
  setStringValue(value: string): void;
292
293
  expectValue(value: number | string | undefined): void;
293
294
  protected getNativeHTMLInput(): HTMLTextAreaElement;
295
+ expectFormLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
294
296
  }
295
297
 
296
298
  declare class TabsTesting extends AbstractComponentTesting<TabsWrapper, FieldSpec> {
@@ -310,6 +312,7 @@ declare class TextContentTesting extends AbstractComponentTesting<TextContentWra
310
312
  protected view: AbstractViewTesting<any>;
311
313
  constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
312
314
  expectContent(content: string | RegExp): void;
315
+ expectHTMLContent(content: string): void;
313
316
  }
314
317
 
315
318
  declare class PaginationTesting extends AbstractComponentTesting<PaginationWrapper, FieldSpec> {
@@ -336,6 +339,14 @@ declare class IconTesting extends AbstractComponentTesting<IconWrapper, FieldSpe
336
339
  constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
337
340
  }
338
341
 
342
+ declare class CopyToClipboardTesting extends AbstractComponentTesting<CopyToClipboardWrapper, FieldSpec> {
343
+ protected view: AbstractViewTesting<any>;
344
+ constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
345
+ expectEnabled(): void;
346
+ copyText(text: string | RegExp): Promise<void>;
347
+ expectLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
348
+ }
349
+
339
350
  /**
340
351
  * Convenience factory to create each CS component testing class. It injects the parent view directly.
341
352
  */
@@ -357,6 +368,7 @@ declare class TestingFactory {
357
368
  header(fieldSpec: FieldSpec): HeaderTesting;
358
369
  box(fieldSpec: FieldSpec): BoxTesting;
359
370
  collectionPreferences(fieldSpec: FieldSpec, pageSizes: number[]): CollectionPreferencesTesting;
371
+ copyToClipboard(fieldSpec: FieldSpec): CopyToClipboardTesting;
360
372
  link(fieldSpec: FieldSpec): LinkTesting;
361
373
  toggle(fieldSpec: FieldSpec): ToggleTesting;
362
374
  flashbar(fieldSpec: FieldSpec): FlashbarTesting;
@@ -412,6 +424,8 @@ declare abstract class AbstractComponentTesting<WrapperType extends ElementWrapp
412
424
  static expectEnabled(element: HTMLElement, msg: string): void;
413
425
  static expectDisabled(element: HTMLElement, msg: string): void;
414
426
  protected static doFindElement<WrapperType extends ElementWrapper$1 | ComponentWrapper>(dataTestId: string, findFunction: (selector: string) => WrapperType | null): WrapperType | null;
427
+ protected getLocalisedField(variables?: any, alternateNs?: LocalisationNamespace): _ebertjendustries_cswrapper.LocalisedElements;
428
+ expectFormFieldLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
415
429
  expectFormFieldLabelDisplayed(): void;
416
430
  expectFormFieldLabelNotDisplayed(): void;
417
431
  getElement(): HTMLElement;
@@ -499,13 +513,6 @@ declare class CSVTextPromptModalViewTesting extends AbstractViewTesting<CSVTextP
499
513
  expectVisibleAfterOpsThenDismiss(operations: (() => void)[], navigatingAway?: boolean): Promise<void>;
500
514
  }
501
515
 
502
- declare class CopyToClipboardTesting extends AbstractComponentTesting<CopyToClipboardWrapper, FieldSpec> {
503
- protected view: AbstractViewTesting<any>;
504
- constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
505
- expectEnabled(): void;
506
- copyText(text: string | RegExp): Promise<void>;
507
- }
508
-
509
516
  declare class MockBrowserAPIs {
510
517
  static mockConfirmAlways(confirm: boolean): Function;
511
518
  static mockScroll(): Function;
@@ -514,7 +521,7 @@ declare class MockBrowserAPIs {
514
521
  }
515
522
 
516
523
  declare function setupRestClientMock(controllerSpec: ViewSpec<any>): MockRestClient;
517
- declare class MockRestClient implements RealRestClient.IRestClient {
524
+ declare class MockRestClient implements _ebertjendustries_cswrapper.IRestClient {
518
525
  get: vitest.Mock<(...args: any[]) => any>;
519
526
  put: vitest.Mock<(...args: any[]) => any>;
520
527
  post: vitest.Mock<(...args: any[]) => any>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import * as RealRestClient from '@ebertjendustries/cswrapper';
1
+ import * as _ebertjendustries_cswrapper 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, CopyToClipboardWrapper } 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';
@@ -143,6 +143,7 @@ declare class ButtonTesting extends AbstractComponentTesting<ButtonWrapper, Fiel
143
143
  awaitLoading(): Promise<void>;
144
144
  awaitNotLoading(): Promise<void>;
145
145
  clickAndWaitForLoadingDone(): Promise<void>;
146
+ expectLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
146
147
  }
147
148
 
148
149
  declare class ButtonDropdownTesting extends AbstractComponentTesting<ButtonDropdownWrapper, FieldSpec> {
@@ -291,6 +292,7 @@ declare class TextareaTesting extends AbstractInputTesting<TextareaWrapper, HTML
291
292
  setStringValue(value: string): void;
292
293
  expectValue(value: number | string | undefined): void;
293
294
  protected getNativeHTMLInput(): HTMLTextAreaElement;
295
+ expectFormLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
294
296
  }
295
297
 
296
298
  declare class TabsTesting extends AbstractComponentTesting<TabsWrapper, FieldSpec> {
@@ -310,6 +312,7 @@ declare class TextContentTesting extends AbstractComponentTesting<TextContentWra
310
312
  protected view: AbstractViewTesting<any>;
311
313
  constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
312
314
  expectContent(content: string | RegExp): void;
315
+ expectHTMLContent(content: string): void;
313
316
  }
314
317
 
315
318
  declare class PaginationTesting extends AbstractComponentTesting<PaginationWrapper, FieldSpec> {
@@ -336,6 +339,14 @@ declare class IconTesting extends AbstractComponentTesting<IconWrapper, FieldSpe
336
339
  constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
337
340
  }
338
341
 
342
+ declare class CopyToClipboardTesting extends AbstractComponentTesting<CopyToClipboardWrapper, FieldSpec> {
343
+ protected view: AbstractViewTesting<any>;
344
+ constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
345
+ expectEnabled(): void;
346
+ copyText(text: string | RegExp): Promise<void>;
347
+ expectLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
348
+ }
349
+
339
350
  /**
340
351
  * Convenience factory to create each CS component testing class. It injects the parent view directly.
341
352
  */
@@ -357,6 +368,7 @@ declare class TestingFactory {
357
368
  header(fieldSpec: FieldSpec): HeaderTesting;
358
369
  box(fieldSpec: FieldSpec): BoxTesting;
359
370
  collectionPreferences(fieldSpec: FieldSpec, pageSizes: number[]): CollectionPreferencesTesting;
371
+ copyToClipboard(fieldSpec: FieldSpec): CopyToClipboardTesting;
360
372
  link(fieldSpec: FieldSpec): LinkTesting;
361
373
  toggle(fieldSpec: FieldSpec): ToggleTesting;
362
374
  flashbar(fieldSpec: FieldSpec): FlashbarTesting;
@@ -412,6 +424,8 @@ declare abstract class AbstractComponentTesting<WrapperType extends ElementWrapp
412
424
  static expectEnabled(element: HTMLElement, msg: string): void;
413
425
  static expectDisabled(element: HTMLElement, msg: string): void;
414
426
  protected static doFindElement<WrapperType extends ElementWrapper$1 | ComponentWrapper>(dataTestId: string, findFunction: (selector: string) => WrapperType | null): WrapperType | null;
427
+ protected getLocalisedField(variables?: any, alternateNs?: LocalisationNamespace): _ebertjendustries_cswrapper.LocalisedElements;
428
+ expectFormFieldLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
415
429
  expectFormFieldLabelDisplayed(): void;
416
430
  expectFormFieldLabelNotDisplayed(): void;
417
431
  getElement(): HTMLElement;
@@ -499,13 +513,6 @@ declare class CSVTextPromptModalViewTesting extends AbstractViewTesting<CSVTextP
499
513
  expectVisibleAfterOpsThenDismiss(operations: (() => void)[], navigatingAway?: boolean): Promise<void>;
500
514
  }
501
515
 
502
- declare class CopyToClipboardTesting extends AbstractComponentTesting<CopyToClipboardWrapper, FieldSpec> {
503
- protected view: AbstractViewTesting<any>;
504
- constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
505
- expectEnabled(): void;
506
- copyText(text: string | RegExp): Promise<void>;
507
- }
508
-
509
516
  declare class MockBrowserAPIs {
510
517
  static mockConfirmAlways(confirm: boolean): Function;
511
518
  static mockScroll(): Function;
@@ -514,7 +521,7 @@ declare class MockBrowserAPIs {
514
521
  }
515
522
 
516
523
  declare function setupRestClientMock(controllerSpec: ViewSpec<any>): MockRestClient;
517
- declare class MockRestClient implements RealRestClient.IRestClient {
524
+ declare class MockRestClient implements _ebertjendustries_cswrapper.IRestClient {
518
525
  get: vitest.Mock<(...args: any[]) => any>;
519
526
  put: vitest.Mock<(...args: any[]) => any>;
520
527
  post: vitest.Mock<(...args: any[]) => any>;
package/dist/index.js CHANGED
@@ -116,6 +116,12 @@ var AbstractComponentTesting = class _AbstractComponentTesting {
116
116
  static doFindElement(dataTestId, findFunction) {
117
117
  return findFunction(`[data-testid*=${dataTestId}]`);
118
118
  }
119
+ getLocalisedField(variables, alternateNs) {
120
+ return this.view.getLocaliser().localiseField(this.elementSpec.getLocalisationKey(), variables, alternateNs);
121
+ }
122
+ expectFormFieldLocalisation(variables, alternateNs) {
123
+ (0, import_vitest.expect)(this.getFormFieldWrapper().findLabel().getElement()).toHaveTextContent(this.getLocalisedField(variables, alternateNs).formField.label);
124
+ }
119
125
  expectFormFieldLabelDisplayed() {
120
126
  (0, import_vitest.expect)(this.getFormFieldWrapper().findLabel()).not.toBeNull();
121
127
  }
@@ -662,6 +668,9 @@ var ButtonTesting = class extends AbstractComponentTesting {
662
668
  await this.awaitLoading();
663
669
  await this.awaitNotLoading();
664
670
  }
671
+ expectLocalisation(variables, alternateNs) {
672
+ this.expectContent(this.getLocalisedField(variables, alternateNs).children);
673
+ }
665
674
  };
666
675
 
667
676
  // src/components/ButtonDropdownTesting.ts
@@ -841,8 +850,7 @@ var BoxTesting = class extends AbstractComponentTesting {
841
850
  (0, import_vitest12.expect)(this.getElementWrapper().getElement()).toHaveTextContent(content);
842
851
  }
843
852
  expectLocalisation(variables, alternateNs) {
844
- const localisedElements = this.view.getLocaliser().localiseField(this.elementSpec.getLocalisationKey(), variables, alternateNs);
845
- this.expectContent(localisedElements.children.trim());
853
+ this.expectContent(this.getLocalisedField(variables, alternateNs).children.trim());
846
854
  }
847
855
  };
848
856
 
@@ -1062,8 +1070,7 @@ var AlertTesting = class extends AbstractComponentTesting {
1062
1070
  (0, import_vitest16.expect)(this.getElementWrapper().findContent().getElement()).toHaveTextContent(content);
1063
1071
  }
1064
1072
  expectLocalisation(variables, alternateNs) {
1065
- const localisedElements = this.view.getLocaliser().localiseField(this.elementSpec.getLocalisationKey(), variables, alternateNs);
1066
- this.expectContent(localisedElements.children);
1073
+ this.expectContent(this.getLocalisedField(variables, alternateNs).children);
1067
1074
  }
1068
1075
  };
1069
1076
 
@@ -1161,6 +1168,10 @@ var TextareaTesting = class extends AbstractInputTesting {
1161
1168
  getNativeHTMLInput() {
1162
1169
  return this.getElementWrapper().findNativeTextarea().getElement();
1163
1170
  }
1171
+ expectFormLocalisation(variables, alternateNs) {
1172
+ this.expectFormFieldLocalisation(variables, alternateNs);
1173
+ (0, import_vitest19.expect)(this.getNativeHTMLInput().placeholder).toEqual(this.getLocalisedField(variables, alternateNs).placeholder);
1174
+ }
1164
1175
  };
1165
1176
 
1166
1177
  // src/components/TabsTesting.ts
@@ -1213,6 +1224,9 @@ var TextContentTesting = class extends AbstractComponentTesting {
1213
1224
  expectContent(content) {
1214
1225
  (0, import_vitest21.expect)(this.getElementWrapper().getElement()).toHaveTextContent(content);
1215
1226
  }
1227
+ expectHTMLContent(content) {
1228
+ (0, import_vitest21.expect)(this.getElementWrapper().getElement().outerHTML.includes(content)).toBeTruthy();
1229
+ }
1216
1230
  };
1217
1231
 
1218
1232
  // src/components/PaginationTesting.ts
@@ -1286,6 +1300,34 @@ var IconTesting = class extends AbstractComponentTesting {
1286
1300
  }
1287
1301
  };
1288
1302
 
1303
+ // src/components/CopyToClipboardTesting.ts
1304
+ var import_dom30 = __toESM(require("@cloudscape-design/components/test-utils/dom"));
1305
+ var import_user_event2 = __toESM(require("@testing-library/user-event"));
1306
+ var import_dom31 = require("@testing-library/dom");
1307
+ var import_vitest24 = require("vitest");
1308
+ var CopyToClipboardTesting = class extends AbstractComponentTesting {
1309
+ constructor(fieldSpec, view) {
1310
+ super(fieldSpec, view, (selector) => (0, import_dom30.default)().findCopyToClipboard(selector));
1311
+ this.view = view;
1312
+ }
1313
+ expectEnabled() {
1314
+ AbstractComponentTesting.expectEnabled(this.getElementWrapper().findCopyButton().getElement(), this.msgForExpect());
1315
+ }
1316
+ async copyText(text) {
1317
+ const user = import_user_event2.default.setup();
1318
+ await (0, import_dom31.waitFor)(() => user.click(this.getElementWrapper().findCopyButton().getElement()));
1319
+ if (text !== "") {
1320
+ await (0, import_dom31.waitFor)(async () => {
1321
+ const copiedText = await window.navigator.clipboard.readText();
1322
+ (0, import_vitest24.expect)(copiedText).toEqual(text);
1323
+ });
1324
+ }
1325
+ }
1326
+ expectLocalisation(variables, alternateNs) {
1327
+ (0, import_vitest24.expect)(this.getElementWrapper().findCopyButton().getElement(), this.msgForExpect()).toHaveTextContent(this.getLocalisedField(variables, alternateNs).copyButtonText);
1328
+ }
1329
+ };
1330
+
1289
1331
  // src/components/TestingFactory.ts
1290
1332
  var TestingFactory = class {
1291
1333
  constructor(parentView) {
@@ -1336,6 +1378,9 @@ var TestingFactory = class {
1336
1378
  collectionPreferences(fieldSpec, pageSizes) {
1337
1379
  return new CollectionPreferencesTesting(fieldSpec, this.parentView, pageSizes);
1338
1380
  }
1381
+ copyToClipboard(fieldSpec) {
1382
+ return new CopyToClipboardTesting(fieldSpec, this.parentView);
1383
+ }
1339
1384
  link(fieldSpec) {
1340
1385
  return new LinkTesting(fieldSpec, this.parentView);
1341
1386
  }
@@ -1386,8 +1431,8 @@ var TestingFactory = class {
1386
1431
  // src/views/AbstractViewTesting.tsx
1387
1432
  var import_react29 = require("@testing-library/react");
1388
1433
  var import_fs = require("fs");
1389
- var import_user_event2 = __toESM(require("@testing-library/user-event"));
1390
- var import_vitest24 = require("vitest");
1434
+ var import_user_event3 = __toESM(require("@testing-library/user-event"));
1435
+ var import_vitest25 = require("vitest");
1391
1436
  var AbstractViewTesting = class {
1392
1437
  constructor(namespace, viewSpec, testLocalisation) {
1393
1438
  this.namespace = namespace;
@@ -1417,7 +1462,7 @@ var AbstractViewTesting = class {
1417
1462
  await this.factory.form(viewSpec).awaitPresent();
1418
1463
  }
1419
1464
  expectViewNotPresent(viewSpec) {
1420
- (0, import_vitest24.expect)(import_react29.screen.queryByTestId(viewSpec.getDataTestId())).not.toBeInTheDocument();
1465
+ (0, import_vitest25.expect)(import_react29.screen.queryByTestId(viewSpec.getDataTestId())).not.toBeInTheDocument();
1421
1466
  }
1422
1467
  translate(key, variables, alternateNs) {
1423
1468
  return this.getLocaliser().localiseKey(key, variables, alternateNs);
@@ -1426,7 +1471,7 @@ var AbstractViewTesting = class {
1426
1471
  * To test triggering the default action, e.g. form submit, by pressing enter.
1427
1472
  */
1428
1473
  async pressEnter(element) {
1429
- await import_user_event2.default.type(element, "{enter}");
1474
+ await import_user_event3.default.type(element, "{enter}");
1430
1475
  }
1431
1476
  };
1432
1477
 
@@ -1592,31 +1637,6 @@ var CSVTextPromptModalViewTesting = class extends AbstractViewTesting {
1592
1637
  }
1593
1638
  };
1594
1639
 
1595
- // src/components/CopyToClipboardTesting.ts
1596
- var import_dom30 = __toESM(require("@cloudscape-design/components/test-utils/dom"));
1597
- var import_user_event3 = __toESM(require("@testing-library/user-event"));
1598
- var import_dom31 = require("@testing-library/dom");
1599
- var import_vitest25 = require("vitest");
1600
- var CopyToClipboardTesting = class extends AbstractComponentTesting {
1601
- constructor(fieldSpec, view) {
1602
- super(fieldSpec, view, (selector) => (0, import_dom30.default)().findCopyToClipboard(selector));
1603
- this.view = view;
1604
- }
1605
- expectEnabled() {
1606
- AbstractComponentTesting.expectEnabled(this.getElementWrapper().findCopyButton().getElement(), this.msgForExpect());
1607
- }
1608
- async copyText(text) {
1609
- const user = import_user_event3.default.setup();
1610
- await (0, import_dom31.waitFor)(() => user.click(this.getElementWrapper().findCopyButton().getElement()));
1611
- if (text !== "") {
1612
- await (0, import_dom31.waitFor)(async () => {
1613
- const copiedText = await window.navigator.clipboard.readText();
1614
- (0, import_vitest25.expect)(copiedText).toEqual(text);
1615
- });
1616
- }
1617
- }
1618
- };
1619
-
1620
1640
  // src/mocks/MockBrowserAPIs.ts
1621
1641
  var import_vitest26 = require("vitest");
1622
1642
  var realDateNow = global.Date.now;
package/dist/index.mjs CHANGED
@@ -34,6 +34,12 @@ var AbstractComponentTesting = class _AbstractComponentTesting {
34
34
  static doFindElement(dataTestId, findFunction) {
35
35
  return findFunction(`[data-testid*=${dataTestId}]`);
36
36
  }
37
+ getLocalisedField(variables, alternateNs) {
38
+ return this.view.getLocaliser().localiseField(this.elementSpec.getLocalisationKey(), variables, alternateNs);
39
+ }
40
+ expectFormFieldLocalisation(variables, alternateNs) {
41
+ expect(this.getFormFieldWrapper().findLabel().getElement()).toHaveTextContent(this.getLocalisedField(variables, alternateNs).formField.label);
42
+ }
37
43
  expectFormFieldLabelDisplayed() {
38
44
  expect(this.getFormFieldWrapper().findLabel()).not.toBeNull();
39
45
  }
@@ -580,6 +586,9 @@ var ButtonTesting = class extends AbstractComponentTesting {
580
586
  await this.awaitLoading();
581
587
  await this.awaitNotLoading();
582
588
  }
589
+ expectLocalisation(variables, alternateNs) {
590
+ this.expectContent(this.getLocalisedField(variables, alternateNs).children);
591
+ }
583
592
  };
584
593
 
585
594
  // src/components/ButtonDropdownTesting.ts
@@ -759,8 +768,7 @@ var BoxTesting = class extends AbstractComponentTesting {
759
768
  expect12(this.getElementWrapper().getElement()).toHaveTextContent(content);
760
769
  }
761
770
  expectLocalisation(variables, alternateNs) {
762
- const localisedElements = this.view.getLocaliser().localiseField(this.elementSpec.getLocalisationKey(), variables, alternateNs);
763
- this.expectContent(localisedElements.children.trim());
771
+ this.expectContent(this.getLocalisedField(variables, alternateNs).children.trim());
764
772
  }
765
773
  };
766
774
 
@@ -980,8 +988,7 @@ var AlertTesting = class extends AbstractComponentTesting {
980
988
  expect16(this.getElementWrapper().findContent().getElement()).toHaveTextContent(content);
981
989
  }
982
990
  expectLocalisation(variables, alternateNs) {
983
- const localisedElements = this.view.getLocaliser().localiseField(this.elementSpec.getLocalisationKey(), variables, alternateNs);
984
- this.expectContent(localisedElements.children);
991
+ this.expectContent(this.getLocalisedField(variables, alternateNs).children);
985
992
  }
986
993
  };
987
994
 
@@ -1079,6 +1086,10 @@ var TextareaTesting = class extends AbstractInputTesting {
1079
1086
  getNativeHTMLInput() {
1080
1087
  return this.getElementWrapper().findNativeTextarea().getElement();
1081
1088
  }
1089
+ expectFormLocalisation(variables, alternateNs) {
1090
+ this.expectFormFieldLocalisation(variables, alternateNs);
1091
+ expect19(this.getNativeHTMLInput().placeholder).toEqual(this.getLocalisedField(variables, alternateNs).placeholder);
1092
+ }
1082
1093
  };
1083
1094
 
1084
1095
  // src/components/TabsTesting.ts
@@ -1131,6 +1142,9 @@ var TextContentTesting = class extends AbstractComponentTesting {
1131
1142
  expectContent(content) {
1132
1143
  expect21(this.getElementWrapper().getElement()).toHaveTextContent(content);
1133
1144
  }
1145
+ expectHTMLContent(content) {
1146
+ expect21(this.getElementWrapper().getElement().outerHTML.includes(content)).toBeTruthy();
1147
+ }
1134
1148
  };
1135
1149
 
1136
1150
  // src/components/PaginationTesting.ts
@@ -1204,6 +1218,34 @@ var IconTesting = class extends AbstractComponentTesting {
1204
1218
  }
1205
1219
  };
1206
1220
 
1221
+ // src/components/CopyToClipboardTesting.ts
1222
+ import wrapper29 from "@cloudscape-design/components/test-utils/dom";
1223
+ import userEvent2 from "@testing-library/user-event";
1224
+ import { waitFor as waitFor11 } from "@testing-library/dom";
1225
+ import { expect as expect24 } from "vitest";
1226
+ var CopyToClipboardTesting = class extends AbstractComponentTesting {
1227
+ constructor(fieldSpec, view) {
1228
+ super(fieldSpec, view, (selector) => wrapper29().findCopyToClipboard(selector));
1229
+ this.view = view;
1230
+ }
1231
+ expectEnabled() {
1232
+ AbstractComponentTesting.expectEnabled(this.getElementWrapper().findCopyButton().getElement(), this.msgForExpect());
1233
+ }
1234
+ async copyText(text) {
1235
+ const user = userEvent2.setup();
1236
+ await waitFor11(() => user.click(this.getElementWrapper().findCopyButton().getElement()));
1237
+ if (text !== "") {
1238
+ await waitFor11(async () => {
1239
+ const copiedText = await window.navigator.clipboard.readText();
1240
+ expect24(copiedText).toEqual(text);
1241
+ });
1242
+ }
1243
+ }
1244
+ expectLocalisation(variables, alternateNs) {
1245
+ expect24(this.getElementWrapper().findCopyButton().getElement(), this.msgForExpect()).toHaveTextContent(this.getLocalisedField(variables, alternateNs).copyButtonText);
1246
+ }
1247
+ };
1248
+
1207
1249
  // src/components/TestingFactory.ts
1208
1250
  var TestingFactory = class {
1209
1251
  constructor(parentView) {
@@ -1254,6 +1296,9 @@ var TestingFactory = class {
1254
1296
  collectionPreferences(fieldSpec, pageSizes) {
1255
1297
  return new CollectionPreferencesTesting(fieldSpec, this.parentView, pageSizes);
1256
1298
  }
1299
+ copyToClipboard(fieldSpec) {
1300
+ return new CopyToClipboardTesting(fieldSpec, this.parentView);
1301
+ }
1257
1302
  link(fieldSpec) {
1258
1303
  return new LinkTesting(fieldSpec, this.parentView);
1259
1304
  }
@@ -1304,8 +1349,8 @@ var TestingFactory = class {
1304
1349
  // src/views/AbstractViewTesting.tsx
1305
1350
  import { prettyDOM, screen as screen3 } from "@testing-library/react";
1306
1351
  import { writeFileSync } from "fs";
1307
- import userEvent2 from "@testing-library/user-event";
1308
- import { expect as expect24 } from "vitest";
1352
+ import userEvent3 from "@testing-library/user-event";
1353
+ import { expect as expect25 } from "vitest";
1309
1354
  var AbstractViewTesting = class {
1310
1355
  constructor(namespace, viewSpec, testLocalisation) {
1311
1356
  this.namespace = namespace;
@@ -1335,7 +1380,7 @@ var AbstractViewTesting = class {
1335
1380
  await this.factory.form(viewSpec).awaitPresent();
1336
1381
  }
1337
1382
  expectViewNotPresent(viewSpec) {
1338
- expect24(screen3.queryByTestId(viewSpec.getDataTestId())).not.toBeInTheDocument();
1383
+ expect25(screen3.queryByTestId(viewSpec.getDataTestId())).not.toBeInTheDocument();
1339
1384
  }
1340
1385
  translate(key, variables, alternateNs) {
1341
1386
  return this.getLocaliser().localiseKey(key, variables, alternateNs);
@@ -1344,7 +1389,7 @@ var AbstractViewTesting = class {
1344
1389
  * To test triggering the default action, e.g. form submit, by pressing enter.
1345
1390
  */
1346
1391
  async pressEnter(element) {
1347
- await userEvent2.type(element, "{enter}");
1392
+ await userEvent3.type(element, "{enter}");
1348
1393
  }
1349
1394
  };
1350
1395
 
@@ -1512,31 +1557,6 @@ var CSVTextPromptModalViewTesting = class extends AbstractViewTesting {
1512
1557
  }
1513
1558
  };
1514
1559
 
1515
- // src/components/CopyToClipboardTesting.ts
1516
- import wrapper29 from "@cloudscape-design/components/test-utils/dom";
1517
- import userEvent3 from "@testing-library/user-event";
1518
- import { waitFor as waitFor11 } from "@testing-library/dom";
1519
- import { expect as expect25 } from "vitest";
1520
- var CopyToClipboardTesting = class extends AbstractComponentTesting {
1521
- constructor(fieldSpec, view) {
1522
- super(fieldSpec, view, (selector) => wrapper29().findCopyToClipboard(selector));
1523
- this.view = view;
1524
- }
1525
- expectEnabled() {
1526
- AbstractComponentTesting.expectEnabled(this.getElementWrapper().findCopyButton().getElement(), this.msgForExpect());
1527
- }
1528
- async copyText(text) {
1529
- const user = userEvent3.setup();
1530
- await waitFor11(() => user.click(this.getElementWrapper().findCopyButton().getElement()));
1531
- if (text !== "") {
1532
- await waitFor11(async () => {
1533
- const copiedText = await window.navigator.clipboard.readText();
1534
- expect25(copiedText).toEqual(text);
1535
- });
1536
- }
1537
- }
1538
- };
1539
-
1540
1560
  // src/mocks/MockBrowserAPIs.ts
1541
1561
  import { vi } from "vitest";
1542
1562
  var realDateNow = global.Date.now;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebertjendustries/cstestwrapper",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",