@ebertjendustries/cstestwrapper 1.0.34 → 1.0.35
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 +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +39 -37
- package/dist/index.mjs +38 -36
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,8 @@ 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
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
|
-
import DropdownHostComponentWrapper from '@cloudscape-design/components/test-utils/dom/internal/dropdown-host';
|
|
5
|
+
import DropdownHostComponentWrapper, { OptionsDropdownContentWrapper } from '@cloudscape-design/components/test-utils/dom/internal/dropdown-host';
|
|
6
|
+
import OptionWrapper from '@cloudscape-design/components/test-utils/dom/internal/option';
|
|
6
7
|
import * as vitest from 'vitest';
|
|
7
8
|
import React from 'react';
|
|
8
9
|
|
|
@@ -29,26 +30,27 @@ declare class AbstractSelectTesting<SelectWrapperType extends DropdownHostCompon
|
|
|
29
30
|
*/
|
|
30
31
|
expectEntries(entries: string[], selectedIndices: number[]): Promise<void>;
|
|
31
32
|
expectEnumEntries<E extends Object>(enumFactory: EnumFactory<E>, selectedEnums: E[], except?: E[]): Promise<void>;
|
|
32
|
-
|
|
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>;
|
|
33
|
+
clickIndices(clickedIndices: number[]): Promise<void>;
|
|
36
34
|
openDropdown(): Promise<SelectWrapperType>;
|
|
37
35
|
closeDropdown(selectWrapper: DropdownHostComponentWrapper): Promise<void>;
|
|
38
36
|
awaitHasSelectedEntryCount(selectedEntryCount: number, totalEntryCount: number): Promise<void>;
|
|
39
37
|
private getOptions;
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
protected getDropdown(selectWrapper: DropdownHostComponentWrapper): OptionsDropdownContentWrapper;
|
|
39
|
+
protected optionsToEntrySet(options: OptionWrapper[]): Set<string>;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
declare class MultiselectTesting extends AbstractSelectTesting<MultiselectWrapper> {
|
|
45
43
|
protected view: AbstractViewTesting<any>;
|
|
46
44
|
constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>, expandToViewport?: boolean);
|
|
45
|
+
multiselectOrDeselectByEnums<E extends Object>(enumFactory: EnumFactory<E>, selectedEntries: E[]): Promise<void>;
|
|
46
|
+
multiselectOrDeselectByLabels(labels: string[]): Promise<void>;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
declare class
|
|
49
|
+
declare class SingleSelectTesting extends AbstractSelectTesting<SelectWrapper> {
|
|
50
50
|
protected view: AbstractViewTesting<any>;
|
|
51
51
|
constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>, expandToViewport?: boolean);
|
|
52
|
+
singleSelectByIndex(index: number): Promise<void>;
|
|
53
|
+
singleSelectByEnum<E extends Object>(enumFactory: EnumFactory<E>, selectedEntry: E): Promise<void>;
|
|
52
54
|
expectEnabled(): void;
|
|
53
55
|
expectDisabled(): void;
|
|
54
56
|
}
|
|
@@ -358,7 +360,7 @@ declare class TestingFactory {
|
|
|
358
360
|
parentView: AbstractViewTesting<any>;
|
|
359
361
|
constructor(parentView: AbstractViewTesting<any>);
|
|
360
362
|
multiselect(fieldSpec: FieldSpec, expandToViewport?: boolean): MultiselectTesting;
|
|
361
|
-
select(fieldSpec: FieldSpec, expandToViewport?: boolean):
|
|
363
|
+
select(fieldSpec: FieldSpec, expandToViewport?: boolean): SingleSelectTesting;
|
|
362
364
|
stringInput(fieldSpec: FieldSpec): StringInputTesting;
|
|
363
365
|
numberInput(fieldSpec: FieldSpec): NumberInputTesting;
|
|
364
366
|
table(fieldSpec: FieldSpec): TableTesting;
|
|
@@ -474,7 +476,7 @@ declare class CSVPriceInputViewTesting extends AbstractViewTesting<CSVPriceInput
|
|
|
474
476
|
private expandToViewport?;
|
|
475
477
|
csvPriceInputView: ViewSpec<{
|
|
476
478
|
amountInput: NumberInputTesting;
|
|
477
|
-
currencyInput:
|
|
479
|
+
currencyInput: SingleSelectTesting;
|
|
478
480
|
displayBox: BoxTesting;
|
|
479
481
|
}>;
|
|
480
482
|
constructor(namespace: LocalisationNamespace, viewSpec: ViewSpec<CSVPriceInputViewElements>, testLocalisation: TestLocalisation, currencyFactory: EnumFactory<any>, expandToViewport?: boolean | undefined);
|
|
@@ -556,4 +558,4 @@ declare class ViewTestWrapperProps<T> {
|
|
|
556
558
|
}
|
|
557
559
|
declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): React.JSX.Element;
|
|
558
560
|
|
|
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,
|
|
561
|
+
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, SingleSelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ 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
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
|
-
import DropdownHostComponentWrapper from '@cloudscape-design/components/test-utils/dom/internal/dropdown-host';
|
|
5
|
+
import DropdownHostComponentWrapper, { OptionsDropdownContentWrapper } from '@cloudscape-design/components/test-utils/dom/internal/dropdown-host';
|
|
6
|
+
import OptionWrapper from '@cloudscape-design/components/test-utils/dom/internal/option';
|
|
6
7
|
import * as vitest from 'vitest';
|
|
7
8
|
import React from 'react';
|
|
8
9
|
|
|
@@ -29,26 +30,27 @@ declare class AbstractSelectTesting<SelectWrapperType extends DropdownHostCompon
|
|
|
29
30
|
*/
|
|
30
31
|
expectEntries(entries: string[], selectedIndices: number[]): Promise<void>;
|
|
31
32
|
expectEnumEntries<E extends Object>(enumFactory: EnumFactory<E>, selectedEnums: E[], except?: E[]): Promise<void>;
|
|
32
|
-
|
|
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>;
|
|
33
|
+
clickIndices(clickedIndices: number[]): Promise<void>;
|
|
36
34
|
openDropdown(): Promise<SelectWrapperType>;
|
|
37
35
|
closeDropdown(selectWrapper: DropdownHostComponentWrapper): Promise<void>;
|
|
38
36
|
awaitHasSelectedEntryCount(selectedEntryCount: number, totalEntryCount: number): Promise<void>;
|
|
39
37
|
private getOptions;
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
protected getDropdown(selectWrapper: DropdownHostComponentWrapper): OptionsDropdownContentWrapper;
|
|
39
|
+
protected optionsToEntrySet(options: OptionWrapper[]): Set<string>;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
declare class MultiselectTesting extends AbstractSelectTesting<MultiselectWrapper> {
|
|
45
43
|
protected view: AbstractViewTesting<any>;
|
|
46
44
|
constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>, expandToViewport?: boolean);
|
|
45
|
+
multiselectOrDeselectByEnums<E extends Object>(enumFactory: EnumFactory<E>, selectedEntries: E[]): Promise<void>;
|
|
46
|
+
multiselectOrDeselectByLabels(labels: string[]): Promise<void>;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
declare class
|
|
49
|
+
declare class SingleSelectTesting extends AbstractSelectTesting<SelectWrapper> {
|
|
50
50
|
protected view: AbstractViewTesting<any>;
|
|
51
51
|
constructor(fieldSpec: FieldSpec, view: AbstractViewTesting<any>, expandToViewport?: boolean);
|
|
52
|
+
singleSelectByIndex(index: number): Promise<void>;
|
|
53
|
+
singleSelectByEnum<E extends Object>(enumFactory: EnumFactory<E>, selectedEntry: E): Promise<void>;
|
|
52
54
|
expectEnabled(): void;
|
|
53
55
|
expectDisabled(): void;
|
|
54
56
|
}
|
|
@@ -358,7 +360,7 @@ declare class TestingFactory {
|
|
|
358
360
|
parentView: AbstractViewTesting<any>;
|
|
359
361
|
constructor(parentView: AbstractViewTesting<any>);
|
|
360
362
|
multiselect(fieldSpec: FieldSpec, expandToViewport?: boolean): MultiselectTesting;
|
|
361
|
-
select(fieldSpec: FieldSpec, expandToViewport?: boolean):
|
|
363
|
+
select(fieldSpec: FieldSpec, expandToViewport?: boolean): SingleSelectTesting;
|
|
362
364
|
stringInput(fieldSpec: FieldSpec): StringInputTesting;
|
|
363
365
|
numberInput(fieldSpec: FieldSpec): NumberInputTesting;
|
|
364
366
|
table(fieldSpec: FieldSpec): TableTesting;
|
|
@@ -474,7 +476,7 @@ declare class CSVPriceInputViewTesting extends AbstractViewTesting<CSVPriceInput
|
|
|
474
476
|
private expandToViewport?;
|
|
475
477
|
csvPriceInputView: ViewSpec<{
|
|
476
478
|
amountInput: NumberInputTesting;
|
|
477
|
-
currencyInput:
|
|
479
|
+
currencyInput: SingleSelectTesting;
|
|
478
480
|
displayBox: BoxTesting;
|
|
479
481
|
}>;
|
|
480
482
|
constructor(namespace: LocalisationNamespace, viewSpec: ViewSpec<CSVPriceInputViewElements>, testLocalisation: TestLocalisation, currencyFactory: EnumFactory<any>, expandToViewport?: boolean | undefined);
|
|
@@ -556,4 +558,4 @@ declare class ViewTestWrapperProps<T> {
|
|
|
556
558
|
}
|
|
557
559
|
declare function ViewTestWrapper<T>(props: ViewTestWrapperProps<T>): React.JSX.Element;
|
|
558
560
|
|
|
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,
|
|
561
|
+
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, SingleSelectTesting, StatusIndicatorTesting, StringInputTesting, TableTesting, TabsTesting, TestLocalisation, TestingFactory, TextContentTesting, TextFilterTesting, TextareaTesting, ToggleTesting, ViewTestWrapper, WizardTesting, setupRestClientMock };
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ __export(index_exports, {
|
|
|
62
62
|
ProgressBarTesting: () => ProgressBarTesting,
|
|
63
63
|
RatingTesting: () => RatingTesting,
|
|
64
64
|
SegmentedControlTesting: () => SegmentedControlTesting,
|
|
65
|
-
|
|
65
|
+
SingleSelectTesting: () => SingleSelectTesting,
|
|
66
66
|
StatusIndicatorTesting: () => StatusIndicatorTesting,
|
|
67
67
|
StringInputTesting: () => StringInputTesting,
|
|
68
68
|
TableTesting: () => TableTesting,
|
|
@@ -334,7 +334,7 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
|
|
|
334
334
|
selectedOptionIndices
|
|
335
335
|
);
|
|
336
336
|
}
|
|
337
|
-
async
|
|
337
|
+
async clickIndices(clickedIndices) {
|
|
338
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();
|
|
@@ -344,36 +344,6 @@ 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
|
-
}
|
|
354
|
-
// ATTENTION! Do NOT use with enum single select! It will lead to failing tests as it does not change selection.
|
|
355
|
-
async multiselect(entries) {
|
|
356
|
-
console.log("SELECTING options = " + entries);
|
|
357
|
-
const indicesToSelect = [];
|
|
358
|
-
const indicesToDeselect = [];
|
|
359
|
-
const selectWrapper = await this.openDropdown();
|
|
360
|
-
const selectedOptionValues = this.optionsToEntrySet(this.getDropdown(selectWrapper).findSelectedOptions());
|
|
361
|
-
const allOptions = this.getDropdown(selectWrapper).findOptions();
|
|
362
|
-
await this.closeDropdown(selectWrapper);
|
|
363
|
-
const optionValuesToSelect = /* @__PURE__ */ new Set();
|
|
364
|
-
entries.forEach((entry) => optionValuesToSelect.add(entry));
|
|
365
|
-
for (let index = 0; index < allOptions.length; index++) {
|
|
366
|
-
const optionValue = allOptions[index].getElement().textContent;
|
|
367
|
-
if (optionValuesToSelect.has(optionValue) && !selectedOptionValues.has(optionValue)) {
|
|
368
|
-
indicesToSelect.push(index);
|
|
369
|
-
} else if (!optionValuesToSelect.has(optionValue) && selectedOptionValues.has(optionValue)) {
|
|
370
|
-
indicesToDeselect.push(index);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
await this.selectOrDeselectByIndices(indicesToSelect);
|
|
374
|
-
await this.selectOrDeselectByIndices(indicesToDeselect);
|
|
375
|
-
await this.closeDropdown(await this.openDropdown());
|
|
376
|
-
}
|
|
377
347
|
async openDropdown() {
|
|
378
348
|
const selectWrapper = this.getElementWrapper();
|
|
379
349
|
(0, import_react5.act)(() => selectWrapper.openDropdown());
|
|
@@ -419,16 +389,48 @@ var MultiselectTesting = class extends AbstractSelectTesting {
|
|
|
419
389
|
super(fieldSpec, view, (selector) => (0, import_dom2.default)().findMultiselect(selector), expandToViewport);
|
|
420
390
|
this.view = view;
|
|
421
391
|
}
|
|
392
|
+
async multiselectOrDeselectByEnums(enumFactory, selectedEntries) {
|
|
393
|
+
const localiser = this.view.getLocaliser();
|
|
394
|
+
await this.multiselectOrDeselectByLabels(selectedEntries.map((entry) => localiser.getEnumLabel(enumFactory, entry)));
|
|
395
|
+
}
|
|
396
|
+
async multiselectOrDeselectByLabels(labels) {
|
|
397
|
+
console.log("SELECTING option labels = " + labels);
|
|
398
|
+
const indicesToSelect = [];
|
|
399
|
+
const indicesToDeselect = [];
|
|
400
|
+
const selectWrapper = await this.openDropdown();
|
|
401
|
+
const selectedOptionValues = this.optionsToEntrySet(this.getDropdown(selectWrapper).findSelectedOptions());
|
|
402
|
+
const allOptions = this.getDropdown(selectWrapper).findOptions();
|
|
403
|
+
await this.closeDropdown(selectWrapper);
|
|
404
|
+
const optionValuesToSelect = /* @__PURE__ */ new Set();
|
|
405
|
+
labels.forEach((entry) => optionValuesToSelect.add(entry));
|
|
406
|
+
for (let index = 0; index < allOptions.length; index++) {
|
|
407
|
+
const optionValue = allOptions[index].getElement().textContent;
|
|
408
|
+
if (optionValuesToSelect.has(optionValue) && !selectedOptionValues.has(optionValue)) {
|
|
409
|
+
indicesToSelect.push(index);
|
|
410
|
+
} else if (!optionValuesToSelect.has(optionValue) && selectedOptionValues.has(optionValue)) {
|
|
411
|
+
indicesToDeselect.push(index);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
await this.clickIndices(indicesToSelect);
|
|
415
|
+
await this.clickIndices(indicesToDeselect);
|
|
416
|
+
await this.closeDropdown(await this.openDropdown());
|
|
417
|
+
}
|
|
422
418
|
};
|
|
423
419
|
|
|
424
|
-
// src/components/
|
|
420
|
+
// src/components/SingleSelectTesting.ts
|
|
425
421
|
var import_dom3 = __toESM(require("@cloudscape-design/components/test-utils/dom"));
|
|
426
422
|
var import_vitest4 = require("vitest");
|
|
427
|
-
var
|
|
423
|
+
var SingleSelectTesting = class extends AbstractSelectTesting {
|
|
428
424
|
constructor(fieldSpec, view, expandToViewport) {
|
|
429
425
|
super(fieldSpec, view, (selector) => (0, import_dom3.default)().findSelect(selector), expandToViewport);
|
|
430
426
|
this.view = view;
|
|
431
427
|
}
|
|
428
|
+
async singleSelectByIndex(index) {
|
|
429
|
+
await this.clickIndices([index]);
|
|
430
|
+
}
|
|
431
|
+
async singleSelectByEnum(enumFactory, selectedEntry) {
|
|
432
|
+
await this.singleSelectByIndex(enumFactory.getEnumIndex(selectedEntry));
|
|
433
|
+
}
|
|
432
434
|
expectEnabled() {
|
|
433
435
|
(0, import_vitest4.expect)(this.getElementWrapper().isDisabled(), this.msgForExpect()).toBeFalsy();
|
|
434
436
|
}
|
|
@@ -1355,7 +1357,7 @@ var TestingFactory = class {
|
|
|
1355
1357
|
return new MultiselectTesting(fieldSpec, this.parentView, expandToViewport);
|
|
1356
1358
|
}
|
|
1357
1359
|
select(fieldSpec, expandToViewport) {
|
|
1358
|
-
return new
|
|
1360
|
+
return new SingleSelectTesting(fieldSpec, this.parentView, expandToViewport);
|
|
1359
1361
|
}
|
|
1360
1362
|
stringInput(fieldSpec) {
|
|
1361
1363
|
return new StringInputTesting(fieldSpec, this.parentView);
|
|
@@ -1546,7 +1548,7 @@ var CSVPriceInputViewTesting = class extends AbstractViewTesting {
|
|
|
1546
1548
|
const priceX = price.priceInCents / 100;
|
|
1547
1549
|
this.csvPriceInputView.elements.amountInput.setStringValue(priceX.toString());
|
|
1548
1550
|
}
|
|
1549
|
-
await this.csvPriceInputView.elements.currencyInput.
|
|
1551
|
+
await this.csvPriceInputView.elements.currencyInput.clickIndices([this.currencyFactory.getEnumIndex(price.currency)]);
|
|
1550
1552
|
}
|
|
1551
1553
|
async expectPrice(price) {
|
|
1552
1554
|
if (isNaN(price.priceInCents)) {
|
|
@@ -1855,7 +1857,7 @@ function ViewTestWrapper(props) {
|
|
|
1855
1857
|
ProgressBarTesting,
|
|
1856
1858
|
RatingTesting,
|
|
1857
1859
|
SegmentedControlTesting,
|
|
1858
|
-
|
|
1860
|
+
SingleSelectTesting,
|
|
1859
1861
|
StatusIndicatorTesting,
|
|
1860
1862
|
StringInputTesting,
|
|
1861
1863
|
TableTesting,
|
package/dist/index.mjs
CHANGED
|
@@ -253,7 +253,7 @@ var AbstractSelectTesting = class extends AbstractComponentTesting {
|
|
|
253
253
|
selectedOptionIndices
|
|
254
254
|
);
|
|
255
255
|
}
|
|
256
|
-
async
|
|
256
|
+
async clickIndices(clickedIndices) {
|
|
257
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();
|
|
@@ -263,36 +263,6 @@ 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
|
-
}
|
|
273
|
-
// ATTENTION! Do NOT use with enum single select! It will lead to failing tests as it does not change selection.
|
|
274
|
-
async multiselect(entries) {
|
|
275
|
-
console.log("SELECTING options = " + entries);
|
|
276
|
-
const indicesToSelect = [];
|
|
277
|
-
const indicesToDeselect = [];
|
|
278
|
-
const selectWrapper = await this.openDropdown();
|
|
279
|
-
const selectedOptionValues = this.optionsToEntrySet(this.getDropdown(selectWrapper).findSelectedOptions());
|
|
280
|
-
const allOptions = this.getDropdown(selectWrapper).findOptions();
|
|
281
|
-
await this.closeDropdown(selectWrapper);
|
|
282
|
-
const optionValuesToSelect = /* @__PURE__ */ new Set();
|
|
283
|
-
entries.forEach((entry) => optionValuesToSelect.add(entry));
|
|
284
|
-
for (let index = 0; index < allOptions.length; index++) {
|
|
285
|
-
const optionValue = allOptions[index].getElement().textContent;
|
|
286
|
-
if (optionValuesToSelect.has(optionValue) && !selectedOptionValues.has(optionValue)) {
|
|
287
|
-
indicesToSelect.push(index);
|
|
288
|
-
} else if (!optionValuesToSelect.has(optionValue) && selectedOptionValues.has(optionValue)) {
|
|
289
|
-
indicesToDeselect.push(index);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
await this.selectOrDeselectByIndices(indicesToSelect);
|
|
293
|
-
await this.selectOrDeselectByIndices(indicesToDeselect);
|
|
294
|
-
await this.closeDropdown(await this.openDropdown());
|
|
295
|
-
}
|
|
296
266
|
async openDropdown() {
|
|
297
267
|
const selectWrapper = this.getElementWrapper();
|
|
298
268
|
act2(() => selectWrapper.openDropdown());
|
|
@@ -338,16 +308,48 @@ var MultiselectTesting = class extends AbstractSelectTesting {
|
|
|
338
308
|
super(fieldSpec, view, (selector) => wrapper2().findMultiselect(selector), expandToViewport);
|
|
339
309
|
this.view = view;
|
|
340
310
|
}
|
|
311
|
+
async multiselectOrDeselectByEnums(enumFactory, selectedEntries) {
|
|
312
|
+
const localiser = this.view.getLocaliser();
|
|
313
|
+
await this.multiselectOrDeselectByLabels(selectedEntries.map((entry) => localiser.getEnumLabel(enumFactory, entry)));
|
|
314
|
+
}
|
|
315
|
+
async multiselectOrDeselectByLabels(labels) {
|
|
316
|
+
console.log("SELECTING option labels = " + labels);
|
|
317
|
+
const indicesToSelect = [];
|
|
318
|
+
const indicesToDeselect = [];
|
|
319
|
+
const selectWrapper = await this.openDropdown();
|
|
320
|
+
const selectedOptionValues = this.optionsToEntrySet(this.getDropdown(selectWrapper).findSelectedOptions());
|
|
321
|
+
const allOptions = this.getDropdown(selectWrapper).findOptions();
|
|
322
|
+
await this.closeDropdown(selectWrapper);
|
|
323
|
+
const optionValuesToSelect = /* @__PURE__ */ new Set();
|
|
324
|
+
labels.forEach((entry) => optionValuesToSelect.add(entry));
|
|
325
|
+
for (let index = 0; index < allOptions.length; index++) {
|
|
326
|
+
const optionValue = allOptions[index].getElement().textContent;
|
|
327
|
+
if (optionValuesToSelect.has(optionValue) && !selectedOptionValues.has(optionValue)) {
|
|
328
|
+
indicesToSelect.push(index);
|
|
329
|
+
} else if (!optionValuesToSelect.has(optionValue) && selectedOptionValues.has(optionValue)) {
|
|
330
|
+
indicesToDeselect.push(index);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
await this.clickIndices(indicesToSelect);
|
|
334
|
+
await this.clickIndices(indicesToDeselect);
|
|
335
|
+
await this.closeDropdown(await this.openDropdown());
|
|
336
|
+
}
|
|
341
337
|
};
|
|
342
338
|
|
|
343
|
-
// src/components/
|
|
339
|
+
// src/components/SingleSelectTesting.ts
|
|
344
340
|
import wrapper3 from "@cloudscape-design/components/test-utils/dom";
|
|
345
341
|
import { expect as expect4 } from "vitest";
|
|
346
|
-
var
|
|
342
|
+
var SingleSelectTesting = class extends AbstractSelectTesting {
|
|
347
343
|
constructor(fieldSpec, view, expandToViewport) {
|
|
348
344
|
super(fieldSpec, view, (selector) => wrapper3().findSelect(selector), expandToViewport);
|
|
349
345
|
this.view = view;
|
|
350
346
|
}
|
|
347
|
+
async singleSelectByIndex(index) {
|
|
348
|
+
await this.clickIndices([index]);
|
|
349
|
+
}
|
|
350
|
+
async singleSelectByEnum(enumFactory, selectedEntry) {
|
|
351
|
+
await this.singleSelectByIndex(enumFactory.getEnumIndex(selectedEntry));
|
|
352
|
+
}
|
|
351
353
|
expectEnabled() {
|
|
352
354
|
expect4(this.getElementWrapper().isDisabled(), this.msgForExpect()).toBeFalsy();
|
|
353
355
|
}
|
|
@@ -1274,7 +1276,7 @@ var TestingFactory = class {
|
|
|
1274
1276
|
return new MultiselectTesting(fieldSpec, this.parentView, expandToViewport);
|
|
1275
1277
|
}
|
|
1276
1278
|
select(fieldSpec, expandToViewport) {
|
|
1277
|
-
return new
|
|
1279
|
+
return new SingleSelectTesting(fieldSpec, this.parentView, expandToViewport);
|
|
1278
1280
|
}
|
|
1279
1281
|
stringInput(fieldSpec) {
|
|
1280
1282
|
return new StringInputTesting(fieldSpec, this.parentView);
|
|
@@ -1465,7 +1467,7 @@ var CSVPriceInputViewTesting = class extends AbstractViewTesting {
|
|
|
1465
1467
|
const priceX = price.priceInCents / 100;
|
|
1466
1468
|
this.csvPriceInputView.elements.amountInput.setStringValue(priceX.toString());
|
|
1467
1469
|
}
|
|
1468
|
-
await this.csvPriceInputView.elements.currencyInput.
|
|
1470
|
+
await this.csvPriceInputView.elements.currencyInput.clickIndices([this.currencyFactory.getEnumIndex(price.currency)]);
|
|
1469
1471
|
}
|
|
1470
1472
|
async expectPrice(price) {
|
|
1471
1473
|
if (isNaN(price.priceInCents)) {
|
|
@@ -1775,7 +1777,7 @@ export {
|
|
|
1775
1777
|
ProgressBarTesting,
|
|
1776
1778
|
RatingTesting,
|
|
1777
1779
|
SegmentedControlTesting,
|
|
1778
|
-
|
|
1780
|
+
SingleSelectTesting,
|
|
1779
1781
|
StatusIndicatorTesting,
|
|
1780
1782
|
StringInputTesting,
|
|
1781
1783
|
TableTesting,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebertjendustries/cstestwrapper",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.35",
|
|
4
4
|
"main": "dist/index.cjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@cloudscape-design/design-tokens": "^3.0.70",
|
|
21
21
|
"@cloudscape-design/global-styles": "^1.0.50",
|
|
22
22
|
"@cloudscape-design/test-utils-core": "^1.0.71",
|
|
23
|
-
"@ebertjendustries/cswrapper": "^1.0.
|
|
23
|
+
"@ebertjendustries/cswrapper": "^1.0.41",
|
|
24
24
|
"@smastrom/react-rating": "^1.5.0",
|
|
25
25
|
"@testing-library/dom": "^10.4.0",
|
|
26
26
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -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.
|
|
40
|
+
"@ebertjendustries/cswrapper": "^1.0.41",
|
|
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",
|