@ebertjendustries/cstestwrapper 1.0.27 → 1.0.30

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
@@ -4,7 +4,6 @@ import { MultiselectWrapper, SelectWrapper, InputWrapper, DatePickerWrapper, Tab
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';
7
- import * as react_jsx_runtime from 'react/jsx-runtime';
8
7
  import React from 'react';
9
8
 
10
9
  /**
@@ -30,8 +29,10 @@ declare class AbstractSelectTesting<SelectWrapperType extends DropdownHostCompon
30
29
  */
31
30
  expectEntries(entries: string[], selectedIndices: number[]): Promise<void>;
32
31
  expectEnumEntries<E extends Object>(enumFactory: EnumFactory<E>, selectedEnums: E[], except?: E[]): Promise<void>;
33
- selectOrDeselect(clickedIndices: number[]): Promise<void>;
34
- select(entries: string[]): Promise<void>;
32
+ selectOrDeselectByIndices(clickedIndices: number[]): Promise<void>;
33
+ selectOrDeselectEnum<E extends Object>(enumFactory: EnumFactory<E>, selectedEntry: E): Promise<void>;
34
+ multiselectEnums<E extends Object>(enumFactory: EnumFactory<E>, selectedEntries: E[]): Promise<void>;
35
+ multiselect(entries: string[]): Promise<void>;
35
36
  openDropdown(): Promise<SelectWrapperType>;
36
37
  closeDropdown(selectWrapper: DropdownHostComponentWrapper): Promise<void>;
37
38
  awaitHasSelectedEntryCount(selectedEntryCount: number, totalEntryCount: number): Promise<void>;
@@ -193,9 +194,11 @@ declare class HeaderTesting extends AbstractComponentTesting<HeaderWrapper, Fiel
193
194
  constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
194
195
  expectCounterLocalisation(variables?: any): void;
195
196
  expectCounter(counterText: string | RegExp): void;
196
- expectContent(content: string | RegExp): void;
197
+ expectContent(content: string | RegExp, message?: string): void;
197
198
  expectNotContent(content: string | RegExp): void;
198
199
  expectLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
200
+ expectNotToBeDirty(): void;
201
+ expectToBeDirty(): void;
199
202
  }
200
203
 
201
204
  declare class BoxTesting extends AbstractComponentTesting<BoxWrapper, FieldSpec> {
@@ -551,6 +554,6 @@ declare class ViewTestWrapperProps<T> {
551
554
  initialValue: T;
552
555
  view: (value: T, onChange: PropertyChangeFunction) => React.ReactNode;
553
556
  }
554
- declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): react_jsx_runtime.JSX.Element;
557
+ declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): React.JSX.Element;
555
558
 
556
559
  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, 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
@@ -4,7 +4,6 @@ import { MultiselectWrapper, SelectWrapper, InputWrapper, DatePickerWrapper, Tab
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';
7
- import * as react_jsx_runtime from 'react/jsx-runtime';
8
7
  import React from 'react';
9
8
 
10
9
  /**
@@ -30,8 +29,10 @@ declare class AbstractSelectTesting<SelectWrapperType extends DropdownHostCompon
30
29
  */
31
30
  expectEntries(entries: string[], selectedIndices: number[]): Promise<void>;
32
31
  expectEnumEntries<E extends Object>(enumFactory: EnumFactory<E>, selectedEnums: E[], except?: E[]): Promise<void>;
33
- selectOrDeselect(clickedIndices: number[]): Promise<void>;
34
- select(entries: string[]): Promise<void>;
32
+ selectOrDeselectByIndices(clickedIndices: number[]): Promise<void>;
33
+ selectOrDeselectEnum<E extends Object>(enumFactory: EnumFactory<E>, selectedEntry: E): Promise<void>;
34
+ multiselectEnums<E extends Object>(enumFactory: EnumFactory<E>, selectedEntries: E[]): Promise<void>;
35
+ multiselect(entries: string[]): Promise<void>;
35
36
  openDropdown(): Promise<SelectWrapperType>;
36
37
  closeDropdown(selectWrapper: DropdownHostComponentWrapper): Promise<void>;
37
38
  awaitHasSelectedEntryCount(selectedEntryCount: number, totalEntryCount: number): Promise<void>;
@@ -193,9 +194,11 @@ declare class HeaderTesting extends AbstractComponentTesting<HeaderWrapper, Fiel
193
194
  constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>);
194
195
  expectCounterLocalisation(variables?: any): void;
195
196
  expectCounter(counterText: string | RegExp): void;
196
- expectContent(content: string | RegExp): void;
197
+ expectContent(content: string | RegExp, message?: string): void;
197
198
  expectNotContent(content: string | RegExp): void;
198
199
  expectLocalisation(variables?: any, alternateNs?: LocalisationNamespace): void;
200
+ expectNotToBeDirty(): void;
201
+ expectToBeDirty(): void;
199
202
  }
200
203
 
201
204
  declare class BoxTesting extends AbstractComponentTesting<BoxWrapper, FieldSpec> {
@@ -551,6 +554,6 @@ declare class ViewTestWrapperProps<T> {
551
554
  initialValue: T;
552
555
  view: (value: T, onChange: PropertyChangeFunction) => React.ReactNode;
553
556
  }
554
- declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): react_jsx_runtime.JSX.Element;
557
+ declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): React.JSX.Element;
555
558
 
556
559
  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, 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
@@ -288,7 +288,7 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
288
288
  const selectedOptionsText = selectedOptions.map((selectedOption) => selectedOption.findLabel().getElement().textContent);
289
289
  console.log(`CURRENTLY selected options = ${selectedOptionsText}, EXPECTED selected options = ${selectedEntries}`);
290
290
  const indexDiff = selectedEntries.length === totalEntryCount ? 1 : 0;
291
- (0, import_vitest3.expect)(selectedOptions, this.msgForExpect()).toHaveLength(selectedEntries.length + indexDiff);
291
+ (0, import_vitest3.expect)(selectedOptions, this.msgForExpect(void 0, "expectSelectedEntries - toHaveLength")).toHaveLength(selectedEntries.length + indexDiff);
292
292
  const selectedEntriesSet = /* @__PURE__ */ new Set();
293
293
  selectedEntries.forEach((entry) => selectedEntriesSet.add(entry));
294
294
  for (let index = indexDiff; index < selectedOptionsText.length; index++) {
@@ -297,7 +297,7 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
297
297
  if (!hasElement) {
298
298
  console.log(`Expected element at index ${index} to be selected: ${selectedOption}.`);
299
299
  }
300
- (0, import_vitest3.expect)(hasElement, this.msgForExpect(index)).toBeTruthy();
300
+ (0, import_vitest3.expect)(hasElement, this.msgForExpect(index, "expectSelectedEntries - hasElement toBeTruthy")).toBeTruthy();
301
301
  }
302
302
  await this.closeDropdown(selectWrapper);
303
303
  }
@@ -312,16 +312,16 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
312
312
  */
313
313
  async expectEntries(entries, selectedIndices) {
314
314
  selectedIndices = selectedIndices.sort((a, b) => a - b);
315
- (0, import_vitest3.expect)(await this.awaitElement(), this.msgForExpect()).toBeInTheDocument();
315
+ (0, import_vitest3.expect)(await this.awaitElement(), this.msgForExpect(void 0, "expectEntries - toBeInTheDocument")).toBeInTheDocument();
316
316
  const selectWrapper = await this.openDropdown();
317
317
  const options = this.getDropdown(selectWrapper).findOptions();
318
- (0, import_vitest3.expect)(options, this.msgForExpect()).toHaveLength(entries.length);
318
+ (0, import_vitest3.expect)(options, this.msgForExpect(void 0, "expectEntries - toHaveLength")).toHaveLength(entries.length);
319
319
  const selectedOptions = this.getDropdown(selectWrapper).findSelectedOptions();
320
320
  const indexDiff = entries.length === selectedIndices.length ? 1 : 0;
321
- (0, import_vitest3.expect)(selectedOptions, this.msgForExpect()).toHaveLength(selectedIndices.length + indexDiff);
321
+ (0, import_vitest3.expect)(selectedOptions, this.msgForExpect(void 0, "expectEntries - selectedOptions toHaveLength")).toHaveLength(selectedIndices.length + indexDiff);
322
322
  for (let index = indexDiff; index < selectedOptions.length; index++) {
323
323
  const selectedOption = selectedOptions[index];
324
- (0, import_vitest3.expect)(selectedOption.findLabel().getElement().textContent, this.msgForExpect(index)).toBe(entries[selectedIndices[index - indexDiff]]);
324
+ (0, import_vitest3.expect)(selectedOption.findLabel().getElement().textContent, this.msgForExpect(index, "expectEntries - to have label")).toBe(entries[selectedIndices[index - indexDiff]]);
325
325
  }
326
326
  await this.closeDropdown(selectWrapper);
327
327
  }
@@ -334,8 +334,8 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
334
334
  selectedOptionIndices
335
335
  );
336
336
  }
337
- async selectOrDeselect(clickedIndices) {
338
- (0, import_vitest3.expect)(await this.awaitElement(), this.msgForExpect()).toBeInTheDocument();
337
+ async selectOrDeselectByIndices(clickedIndices) {
338
+ (0, import_vitest3.expect)(await this.awaitElement(), this.msgForExpect(void 0, "selectOrDeselect - toBeInTheDocument")).toBeInTheDocument();
339
339
  const sortedIndices = clickedIndices.sort((a, b) => b - a);
340
340
  const selectWrapper = await this.openDropdown();
341
341
  for (let index = 0; index < sortedIndices.length; index++) {
@@ -344,8 +344,15 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
344
344
  }
345
345
  await this.closeDropdown(selectWrapper);
346
346
  }
347
+ async selectOrDeselectEnum(enumFactory, selectedEntry) {
348
+ await this.selectOrDeselectByIndices([enumFactory.getEnumIndex(selectedEntry)]);
349
+ }
350
+ async multiselectEnums(enumFactory, selectedEntries) {
351
+ const localiser = this.view.getLocaliser();
352
+ await this.multiselect(selectedEntries.map((entry) => localiser.getEnumLabel(enumFactory, entry)));
353
+ }
347
354
  // ATTENTION! Do NOT use with enum single select! It will lead to failing tests as it does not change selection.
348
- async select(entries) {
355
+ async multiselect(entries) {
349
356
  console.log("SELECTING options = " + entries);
350
357
  const indicesToSelect = [];
351
358
  const indicesToDeselect = [];
@@ -363,29 +370,29 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
363
370
  indicesToDeselect.push(index);
364
371
  }
365
372
  }
366
- await this.selectOrDeselect(indicesToSelect);
367
- await this.selectOrDeselect(indicesToDeselect);
373
+ await this.selectOrDeselectByIndices(indicesToSelect);
374
+ await this.selectOrDeselectByIndices(indicesToDeselect);
368
375
  await this.closeDropdown(await this.openDropdown());
369
376
  }
370
377
  async openDropdown() {
371
378
  const selectWrapper = this.getElementWrapper();
372
379
  (0, import_react5.act)(() => selectWrapper.openDropdown());
373
- await (0, import_react4.waitFor)(() => (0, import_vitest3.expect)(this.getDropdown(selectWrapper).findOptions().length, this.msgForExpect()).toBeGreaterThan(0));
380
+ await (0, import_react4.waitFor)(() => (0, import_vitest3.expect)(this.getDropdown(selectWrapper).findOptions().length, this.msgForExpect(void 0, "openDropdown - wait till options are present (IF FAILS - Ensure expandToViewPort is set to true in select() method!!!!!!)")).toBeGreaterThan(0));
374
381
  return selectWrapper;
375
382
  }
376
383
  async closeDropdown(selectWrapper) {
377
384
  (0, import_react5.act)(() => selectWrapper.closeDropdown(this.getOptions()));
378
385
  if (!this.expandToViewport) {
379
- await (0, import_react4.waitFor)(() => (0, import_vitest3.expect)(this.getDropdown(selectWrapper).findOptions().length, this.msgForExpect()).toBe(0));
386
+ await (0, import_react4.waitFor)(() => (0, import_vitest3.expect)(this.getDropdown(selectWrapper).findOptions().length, this.msgForExpect(void 0, "closeDropdown - wait till options are gone")).toBe(0));
380
387
  }
381
388
  }
382
389
  async awaitHasSelectedEntryCount(selectedEntryCount, totalEntryCount) {
383
390
  const selectWrapper = await this.openDropdown();
384
391
  const options = this.getDropdown(selectWrapper).findSelectedOptions();
385
392
  if (selectedEntryCount === totalEntryCount) {
386
- (0, import_vitest3.expect)(options, this.msgForExpect()).toHaveLength(selectedEntryCount + 1);
393
+ (0, import_vitest3.expect)(options, this.msgForExpect(void 0, "awaitHasSelectedEntryCount - all selected")).toHaveLength(selectedEntryCount + 1);
387
394
  } else {
388
- (0, import_vitest3.expect)(options, this.msgForExpect()).toHaveLength(selectedEntryCount);
395
+ (0, import_vitest3.expect)(options, this.msgForExpect(void 0, "awaitHasSelectedEntryCount - specific items selected")).toHaveLength(selectedEntryCount);
389
396
  }
390
397
  await this.closeDropdown(selectWrapper);
391
398
  }
@@ -403,7 +410,7 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
403
410
  };
404
411
 
405
412
  // src/views/AbstractViewTesting.tsx
406
- var import_cswrapper6 = require("@ebertjendustries/cswrapper");
413
+ var import_cswrapper7 = require("@ebertjendustries/cswrapper");
407
414
 
408
415
  // src/components/MultiselectTesting.ts
409
416
  var import_dom2 = __toESM(require("@cloudscape-design/components/test-utils/dom"));
@@ -816,6 +823,7 @@ var CheckboxTesting = class extends AbstractComponentTesting {
816
823
 
817
824
  // src/components/HeaderTesting.ts
818
825
  var import_dom12 = __toESM(require("@cloudscape-design/components/test-utils/dom"));
826
+ var import_cswrapper6 = require("@ebertjendustries/cswrapper");
819
827
  var import_vitest11 = require("vitest");
820
828
  var HeaderTesting = class extends AbstractComponentTesting {
821
829
  constructor(fieldSpec, view) {
@@ -829,8 +837,8 @@ var HeaderTesting = class extends AbstractComponentTesting {
829
837
  expectCounter(counterText) {
830
838
  (0, import_vitest11.expect)(this.getElementWrapper().findCounter().getElement()).toHaveTextContent(counterText);
831
839
  }
832
- expectContent(content) {
833
- (0, import_vitest11.expect)(this.getElementWrapper().findHeadingText().getElement()).toHaveTextContent(content);
840
+ expectContent(content, message) {
841
+ (0, import_vitest11.expect)(this.getElementWrapper().findHeadingText().getElement(), message).toHaveTextContent(content);
834
842
  }
835
843
  expectNotContent(content) {
836
844
  (0, import_vitest11.expect)(this.getElementWrapper().findHeadingText().getElement()).not.toHaveTextContent(content);
@@ -838,6 +846,14 @@ var HeaderTesting = class extends AbstractComponentTesting {
838
846
  expectLocalisation(variables, alternateNs) {
839
847
  this.expectContent(this.getLocalisedField(variables, alternateNs).children.trim());
840
848
  }
849
+ expectNotToBeDirty() {
850
+ this.expectPresent();
851
+ this.expectNotContent(new RegExp(`.+\\${import_cswrapper6.DIRTY_MARKER}`));
852
+ }
853
+ expectToBeDirty() {
854
+ this.expectPresent();
855
+ this.expectContent(new RegExp(`.+\\${import_cswrapper6.DIRTY_MARKER}`));
856
+ }
841
857
  };
842
858
 
843
859
  // src/components/BoxTesting.ts
@@ -1447,7 +1463,7 @@ var AbstractViewTesting = class {
1447
1463
  return this.testLocalisation.getLocaliser(this.namespace);
1448
1464
  }
1449
1465
  fromSpec(componentSpec, testElements) {
1450
- return import_cswrapper6.ViewSpec.create(componentSpec.key, componentSpec.ns, (spec) => testElements(componentSpec.elements, this.factory));
1466
+ return import_cswrapper7.ViewSpec.create(componentSpec.key, componentSpec.ns, (spec) => testElements(componentSpec.elements, this.factory));
1451
1467
  }
1452
1468
  printDOM() {
1453
1469
  const dom = (0, import_react29.prettyDOM)(void 0, 1e7, { highlight: false });
@@ -1478,18 +1494,18 @@ var AbstractViewTesting = class {
1478
1494
  };
1479
1495
 
1480
1496
  // src/views/CSVNoItemsViewTesting.tsx
1481
- var import_cswrapper7 = require("@ebertjendustries/cswrapper");
1497
+ var import_cswrapper8 = require("@ebertjendustries/cswrapper");
1482
1498
  var CSVNoItemsViewTesting = class extends AbstractViewTesting {
1483
1499
  constructor(namespace, viewSpec, entityTypeFactory, testLocalisation) {
1484
1500
  super(namespace, viewSpec, testLocalisation);
1485
1501
  this.entityTypeFactory = entityTypeFactory;
1486
- this.noItemsView = this.fromSpec((0, import_cswrapper7.CSV_NO_ITEMS_VIEW_SPEC)(this.namespace), (elements, factory) => ({
1502
+ this.noItemsView = this.fromSpec((0, import_cswrapper8.CSV_NO_ITEMS_VIEW_SPEC)(this.namespace), (elements, factory) => ({
1487
1503
  boxHeading: factory.box(elements.boxHeading),
1488
1504
  boxBody: factory.box(elements.boxBody)
1489
1505
  }));
1490
1506
  }
1491
1507
  async awaitPresent() {
1492
- await this.waitForView((0, import_cswrapper7.CSV_NO_ITEMS_VIEW_SPEC)(this.namespace));
1508
+ await this.waitForView((0, import_cswrapper8.CSV_NO_ITEMS_VIEW_SPEC)(this.namespace));
1493
1509
  this.expectPresent();
1494
1510
  }
1495
1511
  async awaitNotPresent() {
@@ -1507,21 +1523,21 @@ var CSVNoItemsViewTesting = class extends AbstractViewTesting {
1507
1523
  };
1508
1524
 
1509
1525
  // src/views/CSVPriceInputViewTesting.tsx
1510
- var import_cswrapper8 = require("@ebertjendustries/cswrapper");
1511
1526
  var import_cswrapper9 = require("@ebertjendustries/cswrapper");
1527
+ var import_cswrapper10 = require("@ebertjendustries/cswrapper");
1512
1528
  var CSVPriceInputViewTesting = class extends AbstractViewTesting {
1513
1529
  constructor(namespace, viewSpec, testLocalisation, currencyFactory, expandToViewport) {
1514
1530
  super(namespace, viewSpec, testLocalisation);
1515
1531
  this.currencyFactory = currencyFactory;
1516
1532
  this.expandToViewport = expandToViewport;
1517
- this.csvPriceInputView = this.fromSpec((0, import_cswrapper8.CSV_PRICE_INPUT_VIEW_SPEC)(this.parent, this.viewSpec.key), (elements, factory) => ({
1533
+ this.csvPriceInputView = this.fromSpec((0, import_cswrapper9.CSV_PRICE_INPUT_VIEW_SPEC)(this.parent, this.viewSpec.key), (elements, factory) => ({
1518
1534
  amountInput: factory.numberInput(elements.inputPrice),
1519
1535
  currencyInput: factory.select(elements.selectCurrency, this.expandToViewport),
1520
1536
  displayBox: factory.box(elements.boxPriceDisplay)
1521
1537
  }));
1522
1538
  }
1523
1539
  expectDisplayPrice(price) {
1524
- this.csvPriceInputView.elements.displayBox.expectContent(import_cswrapper9.PriceUtils.getFormattedPrice("en", price));
1540
+ this.csvPriceInputView.elements.displayBox.expectContent(import_cswrapper10.PriceUtils.getFormattedPrice("en", price));
1525
1541
  }
1526
1542
  async setPrice(price) {
1527
1543
  if (isNaN(price.priceInCents)) {
@@ -1530,7 +1546,7 @@ var CSVPriceInputViewTesting = class extends AbstractViewTesting {
1530
1546
  const priceX = price.priceInCents / 100;
1531
1547
  this.csvPriceInputView.elements.amountInput.setStringValue(priceX.toString());
1532
1548
  }
1533
- await this.csvPriceInputView.elements.currencyInput.selectOrDeselect([this.currencyFactory.getEnumIndex(price.currency)]);
1549
+ await this.csvPriceInputView.elements.currencyInput.selectOrDeselectByIndices([this.currencyFactory.getEnumIndex(price.currency)]);
1534
1550
  }
1535
1551
  async expectPrice(price) {
1536
1552
  if (isNaN(price.priceInCents)) {
@@ -1544,11 +1560,11 @@ var CSVPriceInputViewTesting = class extends AbstractViewTesting {
1544
1560
  };
1545
1561
 
1546
1562
  // src/views/CSVSearchFilterViewTesting.tsx
1547
- var import_cswrapper10 = require("@ebertjendustries/cswrapper");
1563
+ var import_cswrapper11 = require("@ebertjendustries/cswrapper");
1548
1564
  var CSVSearchFilterViewTesting = class extends AbstractViewTesting {
1549
1565
  constructor(namespace, viewSpec, testLocalisation) {
1550
1566
  super(namespace, viewSpec, testLocalisation);
1551
- this.csvSearchFilterView = this.fromSpec((0, import_cswrapper10.CSV_SEARCH_FILTER_VIEW_SPEC)(this.parent, this.viewSpec.key), (elements, factory) => ({
1567
+ this.csvSearchFilterView = this.fromSpec((0, import_cswrapper11.CSV_SEARCH_FILTER_VIEW_SPEC)(this.parent, this.viewSpec.key), (elements, factory) => ({
1552
1568
  searchTextFilter: factory.stringInput(elements.inputSearch),
1553
1569
  searchButton: factory.button(elements.buttonSearch)
1554
1570
  }));
@@ -1583,11 +1599,11 @@ var CSVSearchFilterViewTesting = class extends AbstractViewTesting {
1583
1599
  };
1584
1600
 
1585
1601
  // src/views/CSVTextPromptModalViewTesting.tsx
1586
- var import_cswrapper11 = require("@ebertjendustries/cswrapper");
1602
+ var import_cswrapper12 = require("@ebertjendustries/cswrapper");
1587
1603
  var CSVTextPromptModalViewTesting = class extends AbstractViewTesting {
1588
1604
  constructor(namespace, viewSpec, testLocalisation) {
1589
1605
  super(namespace, viewSpec, testLocalisation);
1590
- this.csvTextPromptModalView = this.fromSpec((0, import_cswrapper11.CSV_TEXT_PROMPT_MODAL_VIEW_SPEC)(this.parent, this.viewSpec.key), (elements, factory) => ({
1606
+ this.csvTextPromptModalView = this.fromSpec((0, import_cswrapper12.CSV_TEXT_PROMPT_MODAL_VIEW_SPEC)(this.parent, this.viewSpec.key), (elements, factory) => ({
1591
1607
  headerHeading: factory.header(elements.headerHeading),
1592
1608
  boxBodyText: factory.box(elements.boxBodyText),
1593
1609
  buttonPrimary: factory.button(elements.buttonPrimary),
@@ -1663,11 +1679,11 @@ var MockBrowserAPIs = class {
1663
1679
  // src/mocks/MockRestClient.ts
1664
1680
  var import_vitest27 = require("vitest");
1665
1681
  var import_console = require("console");
1666
- var import_cswrapper12 = require("@ebertjendustries/cswrapper");
1667
1682
  var import_cswrapper13 = require("@ebertjendustries/cswrapper");
1668
- var RealRestClient = __toESM(require("@ebertjendustries/cswrapper"));
1669
1683
  var import_cswrapper14 = require("@ebertjendustries/cswrapper");
1670
- var LOGGER = new import_cswrapper12.Log("RestClientMock");
1684
+ var RealRestClient = __toESM(require("@ebertjendustries/cswrapper"));
1685
+ var import_cswrapper15 = require("@ebertjendustries/cswrapper");
1686
+ var LOGGER = new import_cswrapper13.Log("RestClientMock");
1671
1687
  var MockResponseStore = class {
1672
1688
  constructor(parentUUID) {
1673
1689
  this.parentUUID = parentUUID;
@@ -1780,9 +1796,9 @@ var MockRestClient = class {
1780
1796
  const response = val.response;
1781
1797
  const delayInMilliseconds = val.delay;
1782
1798
  if (delayInMilliseconds !== void 0) {
1783
- await (0, import_cswrapper13.sleep)(delayInMilliseconds);
1799
+ await (0, import_cswrapper14.sleep)(delayInMilliseconds);
1784
1800
  }
1785
- if (response !== null && response !== void 0 && (0, import_cswrapper14.isContentWithMessages)(response)) {
1801
+ if (response !== null && response !== void 0 && (0, import_cswrapper15.isContentWithMessages)(response)) {
1786
1802
  return Promise.reject(response);
1787
1803
  }
1788
1804
  return this.mockImpl(response, endpoint, payload, operation, header);
package/dist/index.mjs CHANGED
@@ -207,7 +207,7 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
207
207
  const selectedOptionsText = selectedOptions.map((selectedOption) => selectedOption.findLabel().getElement().textContent);
208
208
  console.log(`CURRENTLY selected options = ${selectedOptionsText}, EXPECTED selected options = ${selectedEntries}`);
209
209
  const indexDiff = selectedEntries.length === totalEntryCount ? 1 : 0;
210
- expect3(selectedOptions, this.msgForExpect()).toHaveLength(selectedEntries.length + indexDiff);
210
+ expect3(selectedOptions, this.msgForExpect(void 0, "expectSelectedEntries - toHaveLength")).toHaveLength(selectedEntries.length + indexDiff);
211
211
  const selectedEntriesSet = /* @__PURE__ */ new Set();
212
212
  selectedEntries.forEach((entry) => selectedEntriesSet.add(entry));
213
213
  for (let index = indexDiff; index < selectedOptionsText.length; index++) {
@@ -216,7 +216,7 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
216
216
  if (!hasElement) {
217
217
  console.log(`Expected element at index ${index} to be selected: ${selectedOption}.`);
218
218
  }
219
- expect3(hasElement, this.msgForExpect(index)).toBeTruthy();
219
+ expect3(hasElement, this.msgForExpect(index, "expectSelectedEntries - hasElement toBeTruthy")).toBeTruthy();
220
220
  }
221
221
  await this.closeDropdown(selectWrapper);
222
222
  }
@@ -231,16 +231,16 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
231
231
  */
232
232
  async expectEntries(entries, selectedIndices) {
233
233
  selectedIndices = selectedIndices.sort((a, b) => a - b);
234
- expect3(await this.awaitElement(), this.msgForExpect()).toBeInTheDocument();
234
+ expect3(await this.awaitElement(), this.msgForExpect(void 0, "expectEntries - toBeInTheDocument")).toBeInTheDocument();
235
235
  const selectWrapper = await this.openDropdown();
236
236
  const options = this.getDropdown(selectWrapper).findOptions();
237
- expect3(options, this.msgForExpect()).toHaveLength(entries.length);
237
+ expect3(options, this.msgForExpect(void 0, "expectEntries - toHaveLength")).toHaveLength(entries.length);
238
238
  const selectedOptions = this.getDropdown(selectWrapper).findSelectedOptions();
239
239
  const indexDiff = entries.length === selectedIndices.length ? 1 : 0;
240
- expect3(selectedOptions, this.msgForExpect()).toHaveLength(selectedIndices.length + indexDiff);
240
+ expect3(selectedOptions, this.msgForExpect(void 0, "expectEntries - selectedOptions toHaveLength")).toHaveLength(selectedIndices.length + indexDiff);
241
241
  for (let index = indexDiff; index < selectedOptions.length; index++) {
242
242
  const selectedOption = selectedOptions[index];
243
- expect3(selectedOption.findLabel().getElement().textContent, this.msgForExpect(index)).toBe(entries[selectedIndices[index - indexDiff]]);
243
+ expect3(selectedOption.findLabel().getElement().textContent, this.msgForExpect(index, "expectEntries - to have label")).toBe(entries[selectedIndices[index - indexDiff]]);
244
244
  }
245
245
  await this.closeDropdown(selectWrapper);
246
246
  }
@@ -253,8 +253,8 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
253
253
  selectedOptionIndices
254
254
  );
255
255
  }
256
- async selectOrDeselect(clickedIndices) {
257
- expect3(await this.awaitElement(), this.msgForExpect()).toBeInTheDocument();
256
+ async selectOrDeselectByIndices(clickedIndices) {
257
+ expect3(await this.awaitElement(), this.msgForExpect(void 0, "selectOrDeselect - toBeInTheDocument")).toBeInTheDocument();
258
258
  const sortedIndices = clickedIndices.sort((a, b) => b - a);
259
259
  const selectWrapper = await this.openDropdown();
260
260
  for (let index = 0; index < sortedIndices.length; index++) {
@@ -263,8 +263,15 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
263
263
  }
264
264
  await this.closeDropdown(selectWrapper);
265
265
  }
266
+ async selectOrDeselectEnum(enumFactory, selectedEntry) {
267
+ await this.selectOrDeselectByIndices([enumFactory.getEnumIndex(selectedEntry)]);
268
+ }
269
+ async multiselectEnums(enumFactory, selectedEntries) {
270
+ const localiser = this.view.getLocaliser();
271
+ await this.multiselect(selectedEntries.map((entry) => localiser.getEnumLabel(enumFactory, entry)));
272
+ }
266
273
  // ATTENTION! Do NOT use with enum single select! It will lead to failing tests as it does not change selection.
267
- async select(entries) {
274
+ async multiselect(entries) {
268
275
  console.log("SELECTING options = " + entries);
269
276
  const indicesToSelect = [];
270
277
  const indicesToDeselect = [];
@@ -282,29 +289,29 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
282
289
  indicesToDeselect.push(index);
283
290
  }
284
291
  }
285
- await this.selectOrDeselect(indicesToSelect);
286
- await this.selectOrDeselect(indicesToDeselect);
292
+ await this.selectOrDeselectByIndices(indicesToSelect);
293
+ await this.selectOrDeselectByIndices(indicesToDeselect);
287
294
  await this.closeDropdown(await this.openDropdown());
288
295
  }
289
296
  async openDropdown() {
290
297
  const selectWrapper = this.getElementWrapper();
291
298
  act2(() => selectWrapper.openDropdown());
292
- await waitFor2(() => expect3(this.getDropdown(selectWrapper).findOptions().length, this.msgForExpect()).toBeGreaterThan(0));
299
+ await waitFor2(() => expect3(this.getDropdown(selectWrapper).findOptions().length, this.msgForExpect(void 0, "openDropdown - wait till options are present (IF FAILS - Ensure expandToViewPort is set to true in select() method!!!!!!)")).toBeGreaterThan(0));
293
300
  return selectWrapper;
294
301
  }
295
302
  async closeDropdown(selectWrapper) {
296
303
  act2(() => selectWrapper.closeDropdown(this.getOptions()));
297
304
  if (!this.expandToViewport) {
298
- await waitFor2(() => expect3(this.getDropdown(selectWrapper).findOptions().length, this.msgForExpect()).toBe(0));
305
+ await waitFor2(() => expect3(this.getDropdown(selectWrapper).findOptions().length, this.msgForExpect(void 0, "closeDropdown - wait till options are gone")).toBe(0));
299
306
  }
300
307
  }
301
308
  async awaitHasSelectedEntryCount(selectedEntryCount, totalEntryCount) {
302
309
  const selectWrapper = await this.openDropdown();
303
310
  const options = this.getDropdown(selectWrapper).findSelectedOptions();
304
311
  if (selectedEntryCount === totalEntryCount) {
305
- expect3(options, this.msgForExpect()).toHaveLength(selectedEntryCount + 1);
312
+ expect3(options, this.msgForExpect(void 0, "awaitHasSelectedEntryCount - all selected")).toHaveLength(selectedEntryCount + 1);
306
313
  } else {
307
- expect3(options, this.msgForExpect()).toHaveLength(selectedEntryCount);
314
+ expect3(options, this.msgForExpect(void 0, "awaitHasSelectedEntryCount - specific items selected")).toHaveLength(selectedEntryCount);
308
315
  }
309
316
  await this.closeDropdown(selectWrapper);
310
317
  }
@@ -735,6 +742,7 @@ var CheckboxTesting = class extends AbstractComponentTesting {
735
742
 
736
743
  // src/components/HeaderTesting.ts
737
744
  import wrapper11 from "@cloudscape-design/components/test-utils/dom";
745
+ import { DIRTY_MARKER } from "@ebertjendustries/cswrapper";
738
746
  import { expect as expect11 } from "vitest";
739
747
  var HeaderTesting = class extends AbstractComponentTesting {
740
748
  constructor(fieldSpec, view) {
@@ -748,8 +756,8 @@ var HeaderTesting = class extends AbstractComponentTesting {
748
756
  expectCounter(counterText) {
749
757
  expect11(this.getElementWrapper().findCounter().getElement()).toHaveTextContent(counterText);
750
758
  }
751
- expectContent(content) {
752
- expect11(this.getElementWrapper().findHeadingText().getElement()).toHaveTextContent(content);
759
+ expectContent(content, message) {
760
+ expect11(this.getElementWrapper().findHeadingText().getElement(), message).toHaveTextContent(content);
753
761
  }
754
762
  expectNotContent(content) {
755
763
  expect11(this.getElementWrapper().findHeadingText().getElement()).not.toHaveTextContent(content);
@@ -757,6 +765,14 @@ var HeaderTesting = class extends AbstractComponentTesting {
757
765
  expectLocalisation(variables, alternateNs) {
758
766
  this.expectContent(this.getLocalisedField(variables, alternateNs).children.trim());
759
767
  }
768
+ expectNotToBeDirty() {
769
+ this.expectPresent();
770
+ this.expectNotContent(new RegExp(`.+\\${DIRTY_MARKER}`));
771
+ }
772
+ expectToBeDirty() {
773
+ this.expectPresent();
774
+ this.expectContent(new RegExp(`.+\\${DIRTY_MARKER}`));
775
+ }
760
776
  };
761
777
 
762
778
  // src/components/BoxTesting.ts
@@ -1449,7 +1465,7 @@ var CSVPriceInputViewTesting = class extends AbstractViewTesting {
1449
1465
  const priceX = price.priceInCents / 100;
1450
1466
  this.csvPriceInputView.elements.amountInput.setStringValue(priceX.toString());
1451
1467
  }
1452
- await this.csvPriceInputView.elements.currencyInput.selectOrDeselect([this.currencyFactory.getEnumIndex(price.currency)]);
1468
+ await this.csvPriceInputView.elements.currencyInput.selectOrDeselectByIndices([this.currencyFactory.getEnumIndex(price.currency)]);
1453
1469
  }
1454
1470
  async expectPrice(price) {
1455
1471
  if (isNaN(price.priceInCents)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebertjendustries/cstestwrapper",
3
- "version": "1.0.27",
3
+ "version": "1.0.30",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "@cloudscape-design/design-tokens": "^3.0.70",
38
38
  "@cloudscape-design/global-styles": "^1.0.50",
39
39
  "@cloudscape-design/test-utils-core": "^1.0.71",
40
- "@ebertjendustries/cswrapper": "^1.0.29",
40
+ "@ebertjendustries/cswrapper": "^1.0.31",
41
41
  "@smastrom/react-rating": "^1.5.0",
42
42
  "@testing-library/dom": "^10.4.0",
43
43
  "@testing-library/jest-dom": "^6.6.3",