ngx-com 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ngx-com-components-alert-testing.mjs +80 -0
- package/fesm2022/ngx-com-components-alert-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-calendar-testing.mjs +157 -0
- package/fesm2022/ngx-com-components-calendar-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-carousel-testing.mjs +121 -0
- package/fesm2022/ngx-com-components-carousel-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-checkbox-testing.mjs +113 -0
- package/fesm2022/ngx-com-components-checkbox-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-code-block-testing.mjs +88 -0
- package/fesm2022/ngx-com-components-code-block-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-collapsible-testing.mjs +104 -0
- package/fesm2022/ngx-com-components-collapsible-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-confirm-testing.mjs +150 -0
- package/fesm2022/ngx-com-components-confirm-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-datepicker-testing.mjs +137 -0
- package/fesm2022/ngx-com-components-datepicker-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-dialog-testing.mjs +109 -0
- package/fesm2022/ngx-com-components-dialog-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-dialog.mjs +18 -18
- package/fesm2022/ngx-com-components-dialog.mjs.map +1 -1
- package/fesm2022/ngx-com-components-dropdown.mjs +39 -0
- package/fesm2022/ngx-com-components-dropdown.mjs.map +1 -1
- package/fesm2022/ngx-com-components-form-field-testing.mjs +140 -0
- package/fesm2022/ngx-com-components-form-field-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-form-field.mjs +5 -1
- package/fesm2022/ngx-com-components-form-field.mjs.map +1 -1
- package/fesm2022/ngx-com-components-menu-testing.mjs +298 -0
- package/fesm2022/ngx-com-components-menu-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-paginator-testing.mjs +128 -0
- package/fesm2022/ngx-com-components-paginator-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-popover-testing.mjs +115 -0
- package/fesm2022/ngx-com-components-popover-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-radio-testing.mjs +157 -0
- package/fesm2022/ngx-com-components-radio-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-segmented-control-testing.mjs +122 -0
- package/fesm2022/ngx-com-components-segmented-control-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-sort-testing.mjs +108 -0
- package/fesm2022/ngx-com-components-sort-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-switch-testing.mjs +103 -0
- package/fesm2022/ngx-com-components-switch-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-table-testing.mjs +198 -0
- package/fesm2022/ngx-com-components-table-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-tabs-testing.mjs +126 -0
- package/fesm2022/ngx-com-components-tabs-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-timepicker-testing.mjs +117 -0
- package/fesm2022/ngx-com-components-timepicker-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-toast-testing.mjs +172 -0
- package/fesm2022/ngx-com-components-toast-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-toast.mjs +4 -4
- package/fesm2022/ngx-com-components-toast.mjs.map +1 -1
- package/fesm2022/ngx-com-components-tooltip-testing.mjs +117 -0
- package/fesm2022/ngx-com-components-tooltip-testing.mjs.map +1 -0
- package/package.json +89 -1
- package/types/ngx-com-components-alert-testing.d.ts +41 -0
- package/types/ngx-com-components-calendar-testing.d.ts +80 -0
- package/types/ngx-com-components-carousel-testing.d.ts +51 -0
- package/types/ngx-com-components-checkbox-testing.d.ts +56 -0
- package/types/ngx-com-components-code-block-testing.d.ts +45 -0
- package/types/ngx-com-components-collapsible-testing.d.ts +53 -0
- package/types/ngx-com-components-confirm-testing.d.ts +78 -0
- package/types/ngx-com-components-datepicker-testing.d.ts +61 -0
- package/types/ngx-com-components-dialog-testing.d.ts +57 -0
- package/types/ngx-com-components-dropdown.d.ts +12 -0
- package/types/ngx-com-components-form-field-testing.d.ts +61 -0
- package/types/ngx-com-components-menu-testing.d.ts +167 -0
- package/types/ngx-com-components-paginator-testing.d.ts +58 -0
- package/types/ngx-com-components-popover-testing.d.ts +63 -0
- package/types/ngx-com-components-radio-testing.d.ts +86 -0
- package/types/ngx-com-components-segmented-control-testing.d.ts +66 -0
- package/types/ngx-com-components-sort-testing.d.ts +62 -0
- package/types/ngx-com-components-switch-testing.d.ts +52 -0
- package/types/ngx-com-components-table-testing.d.ts +124 -0
- package/types/ngx-com-components-tabs-testing.d.ts +67 -0
- package/types/ngx-com-components-timepicker-testing.d.ts +53 -0
- package/types/ngx-com-components-toast-testing.d.ts +93 -0
- package/types/ngx-com-components-tooltip-testing.d.ts +57 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Harness for interacting with a ComAlert in tests.
|
|
5
|
+
*/
|
|
6
|
+
class ComAlertHarness extends ComponentHarness {
|
|
7
|
+
static hostSelector = 'com-alert';
|
|
8
|
+
alertEl = this.locatorForOptional('[role="alert"], [role="status"]');
|
|
9
|
+
titleEl = this.locatorForOptional('[comAlertTitle]');
|
|
10
|
+
descriptionEl = this.locatorForOptional('[comAlertDescription]');
|
|
11
|
+
dismissButton = this.locatorForOptional('button[aria-label="Dismiss"]');
|
|
12
|
+
/**
|
|
13
|
+
* Gets a HarnessPredicate for matching alerts.
|
|
14
|
+
* @param options Filter options.
|
|
15
|
+
*/
|
|
16
|
+
static with(options = {}) {
|
|
17
|
+
return new HarnessPredicate(ComAlertHarness, options)
|
|
18
|
+
.addOption('title', options.title, async (harness, title) => {
|
|
19
|
+
const text = await harness.getTitle();
|
|
20
|
+
if (text === null)
|
|
21
|
+
return false;
|
|
22
|
+
return HarnessPredicate.stringMatches(text, title);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Gets the alert's title text, or null if no title is projected. */
|
|
26
|
+
async getTitle() {
|
|
27
|
+
const el = await this.titleEl();
|
|
28
|
+
return el ? el.text() : null;
|
|
29
|
+
}
|
|
30
|
+
/** Gets the alert's description text, or null if no description is projected. */
|
|
31
|
+
async getDescription() {
|
|
32
|
+
const el = await this.descriptionEl();
|
|
33
|
+
return el ? el.text() : null;
|
|
34
|
+
}
|
|
35
|
+
/** Gets the full text content of the alert element. */
|
|
36
|
+
async getText() {
|
|
37
|
+
const el = await this.alertEl();
|
|
38
|
+
if (!el) {
|
|
39
|
+
throw Error('Cannot get text of a dismissed alert.');
|
|
40
|
+
}
|
|
41
|
+
return el.text();
|
|
42
|
+
}
|
|
43
|
+
/** Gets the role attribute of the alert element. */
|
|
44
|
+
async getRole() {
|
|
45
|
+
const el = await this.alertEl();
|
|
46
|
+
return el ? el.getAttribute('role') : null;
|
|
47
|
+
}
|
|
48
|
+
/** Gets the aria-live attribute of the alert element. */
|
|
49
|
+
async getAriaLive() {
|
|
50
|
+
const el = await this.alertEl();
|
|
51
|
+
return el ? el.getAttribute('aria-live') : null;
|
|
52
|
+
}
|
|
53
|
+
/** Whether the alert has a dismiss button. */
|
|
54
|
+
async isDismissible() {
|
|
55
|
+
const el = await this.dismissButton();
|
|
56
|
+
return el !== null;
|
|
57
|
+
}
|
|
58
|
+
/** Clicks the dismiss button. Throws if the alert is not dismissible. */
|
|
59
|
+
async dismiss() {
|
|
60
|
+
const el = await this.dismissButton();
|
|
61
|
+
if (!el) {
|
|
62
|
+
throw Error('Cannot dismiss an alert that is not dismissible.');
|
|
63
|
+
}
|
|
64
|
+
return el.click();
|
|
65
|
+
}
|
|
66
|
+
/** Whether the alert is currently visible (not dismissed). */
|
|
67
|
+
async isVisible() {
|
|
68
|
+
const el = await this.alertEl();
|
|
69
|
+
return el !== null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Testing utilities for the alert component
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Generated bundle index. Do not edit.
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
export { ComAlertHarness };
|
|
80
|
+
//# sourceMappingURL=ngx-com-components-alert-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-com-components-alert-testing.mjs","sources":["../../../projects/com/components/alert/testing/alert.harness.ts","../../../projects/com/components/alert/testing/index.ts","../../../projects/com/components/alert/testing/ngx-com-components-alert-testing.ts"],"sourcesContent":["import {\n ComponentHarness,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport type { BaseHarnessFilters } from '@angular/cdk/testing';\n\n/** Harness filters for ComAlertHarness. */\nexport interface ComAlertHarnessFilters extends BaseHarnessFilters {\n /** Filter by the alert's title text. */\n title?: string | RegExp;\n}\n\n/**\n * Harness for interacting with a ComAlert in tests.\n */\nexport class ComAlertHarness extends ComponentHarness {\n static hostSelector = 'com-alert';\n\n private readonly alertEl = this.locatorForOptional('[role=\"alert\"], [role=\"status\"]');\n private readonly titleEl = this.locatorForOptional('[comAlertTitle]');\n private readonly descriptionEl = this.locatorForOptional('[comAlertDescription]');\n private readonly dismissButton = this.locatorForOptional('button[aria-label=\"Dismiss\"]');\n\n /**\n * Gets a HarnessPredicate for matching alerts.\n * @param options Filter options.\n */\n static with(options: ComAlertHarnessFilters = {}): HarnessPredicate<ComAlertHarness> {\n return new HarnessPredicate(ComAlertHarness, options)\n .addOption('title', options.title, async (harness, title) => {\n const text = await harness.getTitle();\n if (text === null) return false;\n return HarnessPredicate.stringMatches(text, title);\n });\n }\n\n /** Gets the alert's title text, or null if no title is projected. */\n async getTitle(): Promise<string | null> {\n const el = await this.titleEl();\n return el ? el.text() : null;\n }\n\n /** Gets the alert's description text, or null if no description is projected. */\n async getDescription(): Promise<string | null> {\n const el = await this.descriptionEl();\n return el ? el.text() : null;\n }\n\n /** Gets the full text content of the alert element. */\n async getText(): Promise<string> {\n const el = await this.alertEl();\n if (!el) {\n throw Error('Cannot get text of a dismissed alert.');\n }\n return el.text();\n }\n\n /** Gets the role attribute of the alert element. */\n async getRole(): Promise<string | null> {\n const el = await this.alertEl();\n return el ? el.getAttribute('role') : null;\n }\n\n /** Gets the aria-live attribute of the alert element. */\n async getAriaLive(): Promise<string | null> {\n const el = await this.alertEl();\n return el ? el.getAttribute('aria-live') : null;\n }\n\n /** Whether the alert has a dismiss button. */\n async isDismissible(): Promise<boolean> {\n const el = await this.dismissButton();\n return el !== null;\n }\n\n /** Clicks the dismiss button. Throws if the alert is not dismissible. */\n async dismiss(): Promise<void> {\n const el = await this.dismissButton();\n if (!el) {\n throw Error('Cannot dismiss an alert that is not dismissible.');\n }\n return el.click();\n }\n\n /** Whether the alert is currently visible (not dismissed). */\n async isVisible(): Promise<boolean> {\n const el = await this.alertEl();\n return el !== null;\n }\n}\n","// Testing utilities for the alert component\n\nexport { ComAlertHarness } from './alert.harness';\n\nexport type { ComAlertHarnessFilters } from './alert.harness';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAYA;;AAEG;AACG,MAAO,eAAgB,SAAQ,gBAAgB,CAAA;AACnD,IAAA,OAAO,YAAY,GAAG,WAAW;AAEhB,IAAA,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,iCAAiC,CAAC;AACpE,IAAA,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC;AACpD,IAAA,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC,uBAAuB,CAAC;AAChE,IAAA,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC,8BAA8B,CAAC;AAExF;;;AAGG;AACH,IAAA,OAAO,IAAI,CAAC,OAAA,GAAkC,EAAE,EAAA;AAC9C,QAAA,OAAO,IAAI,gBAAgB,CAAC,eAAe,EAAE,OAAO;AACj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ACjB,QAAA,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE;QACrC,OAAO,EAAE,KAAK,IAAI;IACpB;;AAGA,IAAA,MAAM,OAAO,GAAA;AACX,QAAA,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE;QACrC,IAAI,CAAC,EAAE,EAAE;AACP,YAAA,MAAM,KAAK,CAAC,kDAAkD,CAAC;QACjE;AACA,QAAA,OAAO,EAAE,CAAC,KAAK,EAAE;IACnB;;AAGA,IAAA,MAAM,SAAS,GAAA;AACb,QAAA,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;QAC/B,OAAO,EAAE,KAAK,IAAI;IACpB;;;ACxFF;;ACAA;;AAEG;;;;"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Harness for interacting with an individual calendar cell in tests.
|
|
5
|
+
*/
|
|
6
|
+
class ComCalendarCellHarness extends ComponentHarness {
|
|
7
|
+
static hostSelector = 'com-calendar-cell';
|
|
8
|
+
button = this.locatorFor('button');
|
|
9
|
+
/**
|
|
10
|
+
* Gets a HarnessPredicate for matching calendar cells.
|
|
11
|
+
* @param options Filter options.
|
|
12
|
+
*/
|
|
13
|
+
static with(options = {}) {
|
|
14
|
+
return new HarnessPredicate(ComCalendarCellHarness, options)
|
|
15
|
+
.addOption('text', options.text, async (harness, text) => {
|
|
16
|
+
const cellText = await harness.getText();
|
|
17
|
+
return HarnessPredicate.stringMatches(cellText, text);
|
|
18
|
+
})
|
|
19
|
+
.addOption('selected', options.selected, async (harness, selected) => {
|
|
20
|
+
return (await harness.isSelected()) === selected;
|
|
21
|
+
})
|
|
22
|
+
.addOption('disabled', options.disabled, async (harness, disabled) => {
|
|
23
|
+
return (await harness.isDisabled()) === disabled;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** Gets the cell's display text. */
|
|
27
|
+
async getText() {
|
|
28
|
+
const btn = await this.button();
|
|
29
|
+
return (await btn.text()).trim();
|
|
30
|
+
}
|
|
31
|
+
/** Gets the cell button's aria-label. */
|
|
32
|
+
async getAriaLabel() {
|
|
33
|
+
const btn = await this.button();
|
|
34
|
+
return btn.getAttribute('aria-label');
|
|
35
|
+
}
|
|
36
|
+
/** Whether the cell is currently selected. */
|
|
37
|
+
async isSelected() {
|
|
38
|
+
const btn = await this.button();
|
|
39
|
+
return (await btn.getAttribute('aria-selected')) === 'true';
|
|
40
|
+
}
|
|
41
|
+
/** Whether the cell is disabled. */
|
|
42
|
+
async isDisabled() {
|
|
43
|
+
const btn = await this.button();
|
|
44
|
+
return btn.getProperty('disabled');
|
|
45
|
+
}
|
|
46
|
+
/** Whether the cell represents today's date. */
|
|
47
|
+
async isToday() {
|
|
48
|
+
const btn = await this.button();
|
|
49
|
+
return (await btn.getAttribute('aria-current')) === 'date';
|
|
50
|
+
}
|
|
51
|
+
/** Clicks the cell to select it. */
|
|
52
|
+
async select() {
|
|
53
|
+
const btn = await this.button();
|
|
54
|
+
return btn.click();
|
|
55
|
+
}
|
|
56
|
+
/** Focuses the cell button. */
|
|
57
|
+
async focus() {
|
|
58
|
+
const btn = await this.button();
|
|
59
|
+
return btn.focus();
|
|
60
|
+
}
|
|
61
|
+
/** Whether the cell button is focused. */
|
|
62
|
+
async isFocused() {
|
|
63
|
+
const btn = await this.button();
|
|
64
|
+
return btn.isFocused();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Harness for interacting with a ComCalendar in tests.
|
|
69
|
+
*/
|
|
70
|
+
class ComCalendarHarness extends ComponentHarness {
|
|
71
|
+
static hostSelector = 'com-calendar';
|
|
72
|
+
prevButton = this.locatorFor('com-calendar-header button:first-of-type');
|
|
73
|
+
periodButton = this.locatorFor('com-calendar-header button:nth-of-type(2)');
|
|
74
|
+
nextButton = this.locatorFor('com-calendar-header button:last-of-type');
|
|
75
|
+
/**
|
|
76
|
+
* Gets a HarnessPredicate for matching calendars.
|
|
77
|
+
* @param options Filter options.
|
|
78
|
+
*/
|
|
79
|
+
static with(options = {}) {
|
|
80
|
+
return new HarnessPredicate(ComCalendarHarness, options);
|
|
81
|
+
}
|
|
82
|
+
/** Gets the period label text (e.g., "January 2024", "2024", "2000 – 2023"). */
|
|
83
|
+
async getPeriodLabel() {
|
|
84
|
+
const btn = await this.periodButton();
|
|
85
|
+
return (await btn.text()).trim();
|
|
86
|
+
}
|
|
87
|
+
/** Navigates to the previous period (month, year, or multi-year page). */
|
|
88
|
+
async goToPreviousPage() {
|
|
89
|
+
const btn = await this.prevButton();
|
|
90
|
+
return btn.click();
|
|
91
|
+
}
|
|
92
|
+
/** Navigates to the next period (month, year, or multi-year page). */
|
|
93
|
+
async goToNextPage() {
|
|
94
|
+
const btn = await this.nextButton();
|
|
95
|
+
return btn.click();
|
|
96
|
+
}
|
|
97
|
+
/** Whether the previous page button is disabled. */
|
|
98
|
+
async isPreviousDisabled() {
|
|
99
|
+
const btn = await this.prevButton();
|
|
100
|
+
return btn.getProperty('disabled');
|
|
101
|
+
}
|
|
102
|
+
/** Whether the next page button is disabled. */
|
|
103
|
+
async isNextDisabled() {
|
|
104
|
+
const btn = await this.nextButton();
|
|
105
|
+
return btn.getProperty('disabled');
|
|
106
|
+
}
|
|
107
|
+
/** Clicks the period button to switch to the next higher view (month → year → multi-year). */
|
|
108
|
+
async switchView() {
|
|
109
|
+
const btn = await this.periodButton();
|
|
110
|
+
return btn.click();
|
|
111
|
+
}
|
|
112
|
+
/** Gets the current calendar view. */
|
|
113
|
+
async getCurrentView() {
|
|
114
|
+
const monthView = await this.locatorForOptional('com-calendar-month-view')();
|
|
115
|
+
if (monthView)
|
|
116
|
+
return 'month';
|
|
117
|
+
const yearView = await this.locatorForOptional('com-calendar-year-view')();
|
|
118
|
+
if (yearView)
|
|
119
|
+
return 'year';
|
|
120
|
+
return 'multi-year';
|
|
121
|
+
}
|
|
122
|
+
/** Gets all calendar cells, optionally filtered. */
|
|
123
|
+
async getCells(filters = {}) {
|
|
124
|
+
return this.locatorForAll(ComCalendarCellHarness.with(filters))();
|
|
125
|
+
}
|
|
126
|
+
/** Selects a cell by its display text. Throws if no matching cell is found. */
|
|
127
|
+
async selectCell(text) {
|
|
128
|
+
const cells = await this.getCells({ text });
|
|
129
|
+
if (cells.length === 0) {
|
|
130
|
+
throw new Error(`Could not find calendar cell with text "${text}"`);
|
|
131
|
+
}
|
|
132
|
+
return cells[0].select();
|
|
133
|
+
}
|
|
134
|
+
/** Gets all currently selected cells. */
|
|
135
|
+
async getSelectedCells() {
|
|
136
|
+
return this.getCells({ selected: true });
|
|
137
|
+
}
|
|
138
|
+
/** Gets the cell representing today, or null if not visible. */
|
|
139
|
+
async getTodayCell() {
|
|
140
|
+
const cells = await this.getCells();
|
|
141
|
+
for (const cell of cells) {
|
|
142
|
+
if (await cell.isToday()) {
|
|
143
|
+
return cell;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Testing utilities for the calendar component
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Generated bundle index. Do not edit.
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
export { ComCalendarCellHarness, ComCalendarHarness };
|
|
157
|
+
//# sourceMappingURL=ngx-com-components-calendar-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-com-components-calendar-testing.mjs","sources":["../../../projects/com/components/calendar/testing/calendar.harness.ts","../../../projects/com/components/calendar/testing/index.ts","../../../projects/com/components/calendar/testing/ngx-com-components-calendar-testing.ts"],"sourcesContent":["import {\n ComponentHarness,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport type { BaseHarnessFilters } from '@angular/cdk/testing';\n\n/** Harness filters for ComCalendarCellHarness. */\nexport interface ComCalendarCellHarnessFilters extends BaseHarnessFilters {\n /** Filter by the cell's display text. */\n text?: string | RegExp;\n /** Filter by whether the cell is selected. */\n selected?: boolean;\n /** Filter by whether the cell is disabled. */\n disabled?: boolean;\n}\n\n/** Harness filters for ComCalendarHarness. */\nexport type ComCalendarHarnessFilters = BaseHarnessFilters;\n\n/**\n * Harness for interacting with an individual calendar cell in tests.\n */\nexport class ComCalendarCellHarness extends ComponentHarness {\n static hostSelector = 'com-calendar-cell';\n\n private readonly button = this.locatorFor('button');\n\n /**\n * Gets a HarnessPredicate for matching calendar cells.\n * @param options Filter options.\n */\n static with(options: ComCalendarCellHarnessFilters = {}): HarnessPredicate<ComCalendarCellHarness> {\n return new HarnessPredicate(ComCalendarCellHarness, options)\n .addOption('text', options.text, async (harness, text) => {\n const cellText = await harness.getText();\n return HarnessPredicate.stringMatches(cellText, text);\n })\n .addOption('selected', options.selected, async (harness, selected) => {\n return (await harness.isSelected()) === selected;\n })\n .addOption('disabled', options.disabled, async (harness, disabled) => {\n return (await harness.isDisabled()) === disabled;\n });\n }\n\n /** Gets the cell's display text. */\n async getText(): Promise<string> {\n const btn = await this.button();\n return (await btn.text()).trim();\n }\n\n /** Gets the cell button's aria-label. */\n async getAriaLabel(): Promise<string | null> {\n const btn = await this.button();\n return btn.getAttribute('aria-label');\n }\n\n /** Whether the cell is currently selected. */\n async isSelected(): Promise<boolean> {\n const btn = await this.button();\n return (await btn.getAttribute('aria-selected')) === 'true';\n }\n\n /** Whether the cell is disabled. */\n async isDisabled(): Promise<boolean> {\n const btn = await this.button();\n return btn.getProperty<boolean>('disabled');\n }\n\n /** Whether the cell represents today's date. */\n async isToday(): Promise<boolean> {\n const btn = await this.button();\n return (await btn.getAttribute('aria-current')) === 'date';\n }\n\n /** Clicks the cell to select it. */\n async select(): Promise<void> {\n const btn = await this.button();\n return btn.click();\n }\n\n /** Focuses the cell button. */\n async focus(): Promise<void> {\n const btn = await this.button();\n return btn.focus();\n }\n\n /** Whether the cell button is focused. */\n async isFocused(): Promise<boolean> {\n const btn = await this.button();\n return btn.isFocused();\n }\n}\n\n/**\n * Harness for interacting with a ComCalendar in tests.\n */\nexport class ComCalendarHarness extends ComponentHarness {\n static hostSelector = 'com-calendar';\n\n private readonly prevButton = this.locatorFor('com-calendar-header button:first-of-type');\n private readonly periodButton = this.locatorFor('com-calendar-header button:nth-of-type(2)');\n private readonly nextButton = this.locatorFor('com-calendar-header button:last-of-type');\n\n /**\n * Gets a HarnessPredicate for matching calendars.\n * @param options Filter options.\n */\n static with(options: ComCalendarHarnessFilters = {}): HarnessPredicate<ComCalendarHarness> {\n return new HarnessPredicate(ComCalendarHarness, options);\n }\n\n /** Gets the period label text (e.g., \"January 2024\", \"2024\", \"2000 – 2023\"). */\n async getPeriodLabel(): Promise<string> {\n const btn = await this.periodButton();\n return (await btn.text()).trim();\n }\n\n /** Navigates to the previous period (month, year, or multi-year page). */\n async goToPreviousPage(): Promise<void> {\n const btn = await this.prevButton();\n return btn.click();\n }\n\n /** Navigates to the next period (month, year, or multi-year page). */\n async goToNextPage(): Promise<void> {\n const btn = await this.nextButton();\n return btn.click();\n }\n\n /** Whether the previous page button is disabled. */\n async isPreviousDisabled(): Promise<boolean> {\n const btn = await this.prevButton();\n return btn.getProperty<boolean>('disabled');\n }\n\n /** Whether the next page button is disabled. */\n async isNextDisabled(): Promise<boolean> {\n const btn = await this.nextButton();\n return btn.getProperty<boolean>('disabled');\n }\n\n /** Clicks the period button to switch to the next higher view (month → year → multi-year). */\n async switchView(): Promise<void> {\n const btn = await this.periodButton();\n return btn.click();\n }\n\n /** Gets the current calendar view. */\n async getCurrentView(): Promise<'month' | 'year' | 'multi-year'> {\n const monthView = await this.locatorForOptional('com-calendar-month-view')();\n if (monthView) return 'month';\n const yearView = await this.locatorForOptional('com-calendar-year-view')();\n if (yearView) return 'year';\n return 'multi-year';\n }\n\n /** Gets all calendar cells, optionally filtered. */\n async getCells(filters: ComCalendarCellHarnessFilters = {}): Promise<ComCalendarCellHarness[]> {\n return this.locatorForAll(ComCalendarCellHarness.with(filters))();\n }\n\n /** Selects a cell by its display text. Throws if no matching cell is found. */\n async selectCell(text: string): Promise<void> {\n const cells = await this.getCells({ text });\n if (cells.length === 0) {\n throw new Error(`Could not find calendar cell with text \"${text}\"`);\n }\n return cells[0]!.select();\n }\n\n /** Gets all currently selected cells. */\n async getSelectedCells(): Promise<ComCalendarCellHarness[]> {\n return this.getCells({ selected: true });\n }\n\n /** Gets the cell representing today, or null if not visible. */\n async getTodayCell(): Promise<ComCalendarCellHarness | null> {\n const cells = await this.getCells();\n for (const cell of cells) {\n if (await cell.isToday()) {\n return cell;\n }\n }\n return null;\n }\n}\n","// Testing utilities for the calendar component\n\nexport { ComCalendarHarness, ComCalendarCellHarness } from './calendar.harness';\n\nexport type { ComCalendarHarnessFilters, ComCalendarCellHarnessFilters } from './calendar.harness';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAmBA;;AAEG;AACG,MAAO,sBAAuB,SAAQ,gBAAgB,CAAA;AAC1D,IAAA,OAAO,YAAY,GAAG,mBAAmB;AAExB,IAAA,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;AAEnD;;;AAGG;AACH,IAAA,OAAO,IAAI,CAAC,OAAA,GAAyC,EAAE,EAAA;AACrD,QAAA,OAAO,IAAI,gBAAgB,CAAC,sBAAsB,EAAE,OAAO;AACxD,aAAA,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,OAAO,EAAE,IAAI,KAAI;AACvD,YAAA,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE;YACxC,OAAO,gBAAgB,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC;AACvD,QAAA,CAAC;AACA,aAAA,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,OAAO,EAAE,QAAQ,KAAI;YACnE,OAAO,CAAC,MAAM,OAAO,CAAC,UAAU,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Y,GAAA;AAChB,QAAA,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE;AACnC,QAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACxB,YAAA,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE;AACxB,gBAAA,OAAO,IAAI;YACb;QACF;AACA,QAAA,OAAO,IAAI;IACb;;;ACzLF;;ACAA;;AAEG;;;;"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Harness for interacting with a ComCarousel in tests.
|
|
5
|
+
*/
|
|
6
|
+
class ComCarouselHarness extends ComponentHarness {
|
|
7
|
+
static hostSelector = 'com-carousel';
|
|
8
|
+
prevButton = this.locatorForOptional('button[aria-label="Previous slide"]');
|
|
9
|
+
nextButton = this.locatorForOptional('button[aria-label="Next slide"]');
|
|
10
|
+
paginationTablist = this.locatorForOptional('div[role="tablist"][aria-label="Slide navigation"]');
|
|
11
|
+
paginationDots = this.locatorForAll('button[role="tab"]');
|
|
12
|
+
slides = this.locatorForAll('[comCarouselItem]');
|
|
13
|
+
/**
|
|
14
|
+
* Gets a HarnessPredicate for matching carousels.
|
|
15
|
+
* @param options Filter options.
|
|
16
|
+
*/
|
|
17
|
+
static with(options = {}) {
|
|
18
|
+
return new HarnessPredicate(ComCarouselHarness, options);
|
|
19
|
+
}
|
|
20
|
+
/** Navigates to the next slide. Throws if the next button is not present. */
|
|
21
|
+
async goToNext() {
|
|
22
|
+
const btn = await this.nextButton();
|
|
23
|
+
if (!btn) {
|
|
24
|
+
throw new Error('Next slide button is not present');
|
|
25
|
+
}
|
|
26
|
+
return btn.click();
|
|
27
|
+
}
|
|
28
|
+
/** Navigates to the previous slide. Throws if the previous button is not present. */
|
|
29
|
+
async goToPrevious() {
|
|
30
|
+
const btn = await this.prevButton();
|
|
31
|
+
if (!btn) {
|
|
32
|
+
throw new Error('Previous slide button is not present');
|
|
33
|
+
}
|
|
34
|
+
return btn.click();
|
|
35
|
+
}
|
|
36
|
+
/** Navigates to a specific slide by clicking its pagination dot. Throws if not found. */
|
|
37
|
+
async goToSlide(index) {
|
|
38
|
+
const dots = await this.paginationDots();
|
|
39
|
+
if (index < 0 || index >= dots.length) {
|
|
40
|
+
throw new Error(`Pagination dot at index ${index} is not present`);
|
|
41
|
+
}
|
|
42
|
+
return dots[index].click();
|
|
43
|
+
}
|
|
44
|
+
/** Gets the index of the currently active slide based on the selected pagination dot. */
|
|
45
|
+
async getCurrentIndex() {
|
|
46
|
+
const dots = await this.paginationDots();
|
|
47
|
+
for (let i = 0; i < dots.length; i++) {
|
|
48
|
+
if ((await dots[i].getAttribute('aria-selected')) === 'true') {
|
|
49
|
+
return i;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return -1;
|
|
53
|
+
}
|
|
54
|
+
/** Gets the total number of slide items. */
|
|
55
|
+
async getSlideCount() {
|
|
56
|
+
const items = await this.slides();
|
|
57
|
+
return items.length;
|
|
58
|
+
}
|
|
59
|
+
/** Whether the next slide button is disabled. */
|
|
60
|
+
async isNextDisabled() {
|
|
61
|
+
const btn = await this.nextButton();
|
|
62
|
+
if (!btn) {
|
|
63
|
+
throw new Error('Next slide button is not present');
|
|
64
|
+
}
|
|
65
|
+
return btn.getProperty('disabled');
|
|
66
|
+
}
|
|
67
|
+
/** Whether the previous slide button is disabled. */
|
|
68
|
+
async isPreviousDisabled() {
|
|
69
|
+
const btn = await this.prevButton();
|
|
70
|
+
if (!btn) {
|
|
71
|
+
throw new Error('Previous slide button is not present');
|
|
72
|
+
}
|
|
73
|
+
return btn.getProperty('disabled');
|
|
74
|
+
}
|
|
75
|
+
/** Whether navigation buttons (next/previous) are present. */
|
|
76
|
+
async hasNavigation() {
|
|
77
|
+
const btn = await this.nextButton();
|
|
78
|
+
return btn !== null;
|
|
79
|
+
}
|
|
80
|
+
/** Whether the pagination tablist is present. */
|
|
81
|
+
async hasPagination() {
|
|
82
|
+
const tablist = await this.paginationTablist();
|
|
83
|
+
return tablist !== null;
|
|
84
|
+
}
|
|
85
|
+
/** Gets the number of pagination dots. */
|
|
86
|
+
async getPaginationCount() {
|
|
87
|
+
const dots = await this.paginationDots();
|
|
88
|
+
return dots.length;
|
|
89
|
+
}
|
|
90
|
+
/** Whether the carousel is disabled (both navigation buttons disabled). */
|
|
91
|
+
async isDisabled() {
|
|
92
|
+
const hasNav = await this.hasNavigation();
|
|
93
|
+
if (!hasNav)
|
|
94
|
+
return false;
|
|
95
|
+
return (await this.isPreviousDisabled()) && (await this.isNextDisabled());
|
|
96
|
+
}
|
|
97
|
+
/** Whether the carousel host is focused. */
|
|
98
|
+
async isFocused() {
|
|
99
|
+
const host = await this.host();
|
|
100
|
+
return host.isFocused();
|
|
101
|
+
}
|
|
102
|
+
/** Focuses the carousel host element. */
|
|
103
|
+
async focus() {
|
|
104
|
+
const host = await this.host();
|
|
105
|
+
return host.focus();
|
|
106
|
+
}
|
|
107
|
+
/** Blurs the carousel host element. */
|
|
108
|
+
async blur() {
|
|
109
|
+
const host = await this.host();
|
|
110
|
+
return host.blur();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Testing utilities for the carousel component
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Generated bundle index. Do not edit.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
export { ComCarouselHarness };
|
|
121
|
+
//# sourceMappingURL=ngx-com-components-carousel-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-com-components-carousel-testing.mjs","sources":["../../../projects/com/components/carousel/testing/carousel.harness.ts","../../../projects/com/components/carousel/testing/index.ts","../../../projects/com/components/carousel/testing/ngx-com-components-carousel-testing.ts"],"sourcesContent":["import {\n ComponentHarness,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport type { BaseHarnessFilters } from '@angular/cdk/testing';\n\n/** Harness filters for ComCarouselHarness. */\nexport type ComCarouselHarnessFilters = BaseHarnessFilters;\n\n/**\n * Harness for interacting with a ComCarousel in tests.\n */\nexport class ComCarouselHarness extends ComponentHarness {\n static hostSelector = 'com-carousel';\n\n private readonly prevButton = this.locatorForOptional('button[aria-label=\"Previous slide\"]');\n private readonly nextButton = this.locatorForOptional('button[aria-label=\"Next slide\"]');\n private readonly paginationTablist = this.locatorForOptional('div[role=\"tablist\"][aria-label=\"Slide navigation\"]');\n private readonly paginationDots = this.locatorForAll('button[role=\"tab\"]');\n private readonly slides = this.locatorForAll('[comCarouselItem]');\n\n /**\n * Gets a HarnessPredicate for matching carousels.\n * @param options Filter options.\n */\n static with(options: ComCarouselHarnessFilters = {}): HarnessPredicate<ComCarouselHarness> {\n return new HarnessPredicate(ComCarouselHarness, options);\n }\n\n /** Navigates to the next slide. Throws if the next button is not present. */\n async goToNext(): Promise<void> {\n const btn = await this.nextButton();\n if (!btn) {\n throw new Error('Next slide button is not present');\n }\n return btn.click();\n }\n\n /** Navigates to the previous slide. Throws if the previous button is not present. */\n async goToPrevious(): Promise<void> {\n const btn = await this.prevButton();\n if (!btn) {\n throw new Error('Previous slide button is not present');\n }\n return btn.click();\n }\n\n /** Navigates to a specific slide by clicking its pagination dot. Throws if not found. */\n async goToSlide(index: number): Promise<void> {\n const dots = await this.paginationDots();\n if (index < 0 || index >= dots.length) {\n throw new Error(`Pagination dot at index ${index} is not present`);\n }\n return dots[index]!.click();\n }\n\n /** Gets the index of the currently active slide based on the selected pagination dot. */\n async getCurrentIndex(): Promise<number> {\n const dots = await this.paginationDots();\n for (let i = 0; i < dots.length; i++) {\n if ((await dots[i]!.getAttribute('aria-selected')) === 'true') {\n return i;\n }\n }\n return -1;\n }\n\n /** Gets the total number of slide items. */\n async getSlideCount(): Promise<number> {\n const items = await this.slides();\n return items.length;\n }\n\n /** Whether the next slide button is disabled. */\n async isNextDisabled(): Promise<boolean> {\n const btn = await this.nextButton();\n if (!btn) {\n throw new Error('Next slide button is not present');\n }\n return btn.getProperty<boolean>('disabled');\n }\n\n /** Whether the previous slide button is disabled. */\n async isPreviousDisabled(): Promise<boolean> {\n const btn = await this.prevButton();\n if (!btn) {\n throw new Error('Previous slide button is not present');\n }\n return btn.getProperty<boolean>('disabled');\n }\n\n /** Whether navigation buttons (next/previous) are present. */\n async hasNavigation(): Promise<boolean> {\n const btn = await this.nextButton();\n return btn !== null;\n }\n\n /** Whether the pagination tablist is present. */\n async hasPagination(): Promise<boolean> {\n const tablist = await this.paginationTablist();\n return tablist !== null;\n }\n\n /** Gets the number of pagination dots. */\n async getPaginationCount(): Promise<number> {\n const dots = await this.paginationDots();\n return dots.length;\n }\n\n /** Whether the carousel is disabled (both navigation buttons disabled). */\n async isDisabled(): Promise<boolean> {\n const hasNav = await this.hasNavigation();\n if (!hasNav) return false;\n return (await this.isPreviousDisabled()) && (await this.isNextDisabled());\n }\n\n /** Whether the carousel host is focused. */\n async isFocused(): Promise<boolean> {\n const host = await this.host();\n return host.isFocused();\n }\n\n /** Focuses the carousel host element. */\n async focus(): Promise<void> {\n const host = await this.host();\n return host.focus();\n }\n\n /** Blurs the carousel host element. */\n async blur(): Promise<void> {\n const host = await this.host();\n return host.blur();\n }\n}\n","// Testing utilities for the carousel component\n\nexport { ComCarouselHarness } from './carousel.harness';\n\nexport type { ComCarouselHarnessFilters } from './carousel.harness';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AASA;;AAEG;AACG,MAAO,kBAAmB,SAAQ,gBAAgB,CAAA;AACtD,IAAA,OAAO,YAAY,GAAG,cAAc;AAEnB,IAAA,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,qCAAqC,CAAC;AAC3E,IAAA,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,iCAAiC,CAAC;AACvE,IAAA,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC,oDAAoD,CAAC;AACjG,IAAA,cAAc,GAAG,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,IAAI,CAAC,MAAM;AAAE,YAAA,OAAO,KAAK;AACzB,QAAA,OAAO,CAAC,MAAM,IAAI,CAAC,kBAAkB,EAAE,MAAM,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAC3E;;AAGA,IAAA,MAAM,SAAS,GAAA;AACb,QAAA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE;AAC9B,QAAA,OAAO,IAAI,CAAC,SAAS,EAAE;IACzB;;AAGA,IAAA,MAAM,KAAK,GAAA;AACT,QAAA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE;AAC9B,QAAA,OAAO,IAAI,CAAC,KAAK,EAAE;IACrB;;AAGA,IAAA,MAAM,IAAI,GAAA;AACR,QAAA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE;AAC9B,QAAA,OAAO,IAAI,CAAC,IAAI,EAAE;IACpB;;;ACpIF;;ACAA;;AAEG;;;;"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Harness for interacting with a ComCheckbox in tests.
|
|
5
|
+
*/
|
|
6
|
+
class ComCheckboxHarness extends ComponentHarness {
|
|
7
|
+
static hostSelector = 'com-checkbox';
|
|
8
|
+
label = this.locatorFor('label');
|
|
9
|
+
input = this.locatorFor('input[type="checkbox"]');
|
|
10
|
+
labelText = this.locatorFor('.com-checkbox__label');
|
|
11
|
+
/**
|
|
12
|
+
* Gets a HarnessPredicate for matching checkboxes.
|
|
13
|
+
* @param options Filter options.
|
|
14
|
+
*/
|
|
15
|
+
static with(options = {}) {
|
|
16
|
+
return new HarnessPredicate(ComCheckboxHarness, options)
|
|
17
|
+
.addOption('label', options.label, async (harness, label) => {
|
|
18
|
+
const text = await harness.getLabelText();
|
|
19
|
+
return HarnessPredicate.stringMatches(text, label);
|
|
20
|
+
})
|
|
21
|
+
.addOption('disabled', options.disabled, async (harness, disabled) => {
|
|
22
|
+
return (await harness.isDisabled()) === disabled;
|
|
23
|
+
})
|
|
24
|
+
.addOption('checked', options.checked, async (harness, checked) => {
|
|
25
|
+
return (await harness.isChecked()) === checked;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Whether the checkbox is currently checked. */
|
|
29
|
+
async isChecked() {
|
|
30
|
+
const inputEl = await this.input();
|
|
31
|
+
return inputEl.getProperty('checked');
|
|
32
|
+
}
|
|
33
|
+
/** Whether the checkbox is disabled. */
|
|
34
|
+
async isDisabled() {
|
|
35
|
+
const inputEl = await this.input();
|
|
36
|
+
return inputEl.getProperty('disabled');
|
|
37
|
+
}
|
|
38
|
+
/** Whether the checkbox is in the indeterminate state. */
|
|
39
|
+
async isIndeterminate() {
|
|
40
|
+
const inputEl = await this.input();
|
|
41
|
+
return inputEl.getProperty('indeterminate');
|
|
42
|
+
}
|
|
43
|
+
/** Whether the checkbox is required. */
|
|
44
|
+
async isRequired() {
|
|
45
|
+
const inputEl = await this.input();
|
|
46
|
+
const ariaRequired = await inputEl.getAttribute('aria-required');
|
|
47
|
+
if (ariaRequired !== null) {
|
|
48
|
+
return ariaRequired === 'true';
|
|
49
|
+
}
|
|
50
|
+
return inputEl.getProperty('required');
|
|
51
|
+
}
|
|
52
|
+
/** Gets the checkbox's projected label text. */
|
|
53
|
+
async getLabelText() {
|
|
54
|
+
const labelEl = await this.labelText();
|
|
55
|
+
return labelEl.text();
|
|
56
|
+
}
|
|
57
|
+
/** Gets the checkbox's name attribute. */
|
|
58
|
+
async getName() {
|
|
59
|
+
const inputEl = await this.input();
|
|
60
|
+
return inputEl.getAttribute('name');
|
|
61
|
+
}
|
|
62
|
+
/** Gets the checkbox's aria-label attribute. */
|
|
63
|
+
async getAriaLabel() {
|
|
64
|
+
const inputEl = await this.input();
|
|
65
|
+
return inputEl.getAttribute('aria-label');
|
|
66
|
+
}
|
|
67
|
+
/** Gets the checkbox's aria-labelledby attribute. */
|
|
68
|
+
async getAriaLabelledby() {
|
|
69
|
+
const inputEl = await this.input();
|
|
70
|
+
return inputEl.getAttribute('aria-labelledby');
|
|
71
|
+
}
|
|
72
|
+
/** Toggles the checkbox by clicking the label element. */
|
|
73
|
+
async toggle() {
|
|
74
|
+
const labelEl = await this.label();
|
|
75
|
+
return labelEl.click();
|
|
76
|
+
}
|
|
77
|
+
/** Checks the checkbox if it is currently unchecked. */
|
|
78
|
+
async check() {
|
|
79
|
+
if (!(await this.isChecked())) {
|
|
80
|
+
await this.toggle();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Unchecks the checkbox if it is currently checked. */
|
|
84
|
+
async uncheck() {
|
|
85
|
+
if (await this.isChecked()) {
|
|
86
|
+
await this.toggle();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Focuses the checkbox's input element. */
|
|
90
|
+
async focus() {
|
|
91
|
+
const inputEl = await this.input();
|
|
92
|
+
return inputEl.focus();
|
|
93
|
+
}
|
|
94
|
+
/** Blurs the checkbox's input element. */
|
|
95
|
+
async blur() {
|
|
96
|
+
const inputEl = await this.input();
|
|
97
|
+
return inputEl.blur();
|
|
98
|
+
}
|
|
99
|
+
/** Whether the checkbox's input element is focused. */
|
|
100
|
+
async isFocused() {
|
|
101
|
+
const inputEl = await this.input();
|
|
102
|
+
return inputEl.isFocused();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Testing utilities for the checkbox component
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Generated bundle index. Do not edit.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
export { ComCheckboxHarness };
|
|
113
|
+
//# sourceMappingURL=ngx-com-components-checkbox-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-com-components-checkbox-testing.mjs","sources":["../../../projects/com/components/checkbox/testing/checkbox.harness.ts","../../../projects/com/components/checkbox/testing/index.ts","../../../projects/com/components/checkbox/testing/ngx-com-components-checkbox-testing.ts"],"sourcesContent":["import {\n ComponentHarness,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport type { BaseHarnessFilters } from '@angular/cdk/testing';\n\n/** Harness filters for ComCheckboxHarness. */\nexport interface ComCheckboxHarnessFilters extends BaseHarnessFilters {\n /** Filter by the checkbox's projected label text. */\n label?: string | RegExp;\n /** Filter by whether the checkbox is disabled. */\n disabled?: boolean;\n /** Filter by whether the checkbox is checked. */\n checked?: boolean;\n}\n\n/**\n * Harness for interacting with a ComCheckbox in tests.\n */\nexport class ComCheckboxHarness extends ComponentHarness {\n static hostSelector = 'com-checkbox';\n\n private readonly label = this.locatorFor('label');\n private readonly input = this.locatorFor('input[type=\"checkbox\"]');\n private readonly labelText = this.locatorFor('.com-checkbox__label');\n\n /**\n * Gets a HarnessPredicate for matching checkboxes.\n * @param options Filter options.\n */\n static with(options: ComCheckboxHarnessFilters = {}): HarnessPredicate<ComCheckboxHarness> {\n return new HarnessPredicate(ComCheckboxHarness, options)\n .addOption('label', options.label, async (harness, label) => {\n const text = await harness.getLabelText();\n return HarnessPredicate.stringMatches(text, label);\n })\n .addOption('disabled', options.disabled, async (harness, disabled) => {\n return (await harness.isDisabled()) === disabled;\n })\n .addOption('checked', options.checked, async (harness, checked) => {\n return (await harness.isChecked()) === checked;\n });\n }\n\n /** Whether the checkbox is currently checked. */\n async isChecked(): Promise<boolean> {\n const inputEl = await this.input();\n return inputEl.getProperty<boolean>('checked');\n }\n\n /** Whether the checkbox is disabled. */\n async isDisabled(): Promise<boolean> {\n const inputEl = await this.input();\n return inputEl.getProperty<boolean>('disabled');\n }\n\n /** Whether the checkbox is in the indeterminate state. */\n async isIndeterminate(): Promise<boolean> {\n const inputEl = await this.input();\n return inputEl.getProperty<boolean>('indeterminate');\n }\n\n /** Whether the checkbox is required. */\n async isRequired(): Promise<boolean> {\n const inputEl = await this.input();\n const ariaRequired = await inputEl.getAttribute('aria-required');\n if (ariaRequired !== null) {\n return ariaRequired === 'true';\n }\n return inputEl.getProperty<boolean>('required');\n }\n\n /** Gets the checkbox's projected label text. */\n async getLabelText(): Promise<string> {\n const labelEl = await this.labelText();\n return labelEl.text();\n }\n\n /** Gets the checkbox's name attribute. */\n async getName(): Promise<string | null> {\n const inputEl = await this.input();\n return inputEl.getAttribute('name');\n }\n\n /** Gets the checkbox's aria-label attribute. */\n async getAriaLabel(): Promise<string | null> {\n const inputEl = await this.input();\n return inputEl.getAttribute('aria-label');\n }\n\n /** Gets the checkbox's aria-labelledby attribute. */\n async getAriaLabelledby(): Promise<string | null> {\n const inputEl = await this.input();\n return inputEl.getAttribute('aria-labelledby');\n }\n\n /** Toggles the checkbox by clicking the label element. */\n async toggle(): Promise<void> {\n const labelEl = await this.label();\n return labelEl.click();\n }\n\n /** Checks the checkbox if it is currently unchecked. */\n async check(): Promise<void> {\n if (!(await this.isChecked())) {\n await this.toggle();\n }\n }\n\n /** Unchecks the checkbox if it is currently checked. */\n async uncheck(): Promise<void> {\n if (await this.isChecked()) {\n await this.toggle();\n }\n }\n\n /** Focuses the checkbox's input element. */\n async focus(): Promise<void> {\n const inputEl = await this.input();\n return inputEl.focus();\n }\n\n /** Blurs the checkbox's input element. */\n async blur(): Promise<void> {\n const inputEl = await this.input();\n return inputEl.blur();\n }\n\n /** Whether the checkbox's input element is focused. */\n async isFocused(): Promise<boolean> {\n const inputEl = await this.input();\n return inputEl.isFocused();\n }\n}\n","// Testing utilities for the checkbox component\n\nexport { ComCheckboxHarness } from './checkbox.harness';\n\nexport type { ComCheckboxHarnessFilters } from './checkbox.harness';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAgBA;;AAEG;AACG,MAAO,kBAAmB,SAAQ,gBAAgB,CAAA;AACtD,IAAA,OAAO,YAAY,GAAG,cAAc;AAEnB,IAAA,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;AAChC,IAAA,KAAK,GAAG,IAAI,C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ACX,QAAA,IAAI,MAAM,IAAI,CAAC,SAAS,EAAE,EAAE;AAC1B,YAAA,MAAM,IAAI,CAAC,MAAM,EAAE;QACrB;IACF;;AAGA,IAAA,MAAM,KAAK,GAAA;AACT,QAAA,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE;AAClC,QAAA,OAAO,OAAO,CAAC,KAAK,EAAE;IACxB;;AAGA,IAAA,MAAM,IAAI,GAAA;AACR,QAAA,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE;AAClC,QAAA,OAAO,OAAO,CAAC,IAAI,EAAE;IACvB;;AAGA,IAAA,MAAM,SAAS,GAAA;AACb,QAAA,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE;AAClC,QAAA,OAAO,OAAO,CAAC,SAAS,EAAE;IAC5B;;;ACpIF;;ACAA;;AAEG;;;;"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Harness for interacting with a ComCodeBlock in tests.
|
|
5
|
+
*/
|
|
6
|
+
class ComCodeBlockHarness extends ComponentHarness {
|
|
7
|
+
static hostSelector = 'com-code-block';
|
|
8
|
+
codeElement = this.locatorFor('code');
|
|
9
|
+
preElement = this.locatorFor('pre');
|
|
10
|
+
copyButton = this.locatorFor('button[type="button"]');
|
|
11
|
+
/**
|
|
12
|
+
* Gets a HarnessPredicate for matching code blocks.
|
|
13
|
+
* @param options Filter options.
|
|
14
|
+
*/
|
|
15
|
+
static with(options = {}) {
|
|
16
|
+
return new HarnessPredicate(ComCodeBlockHarness, options)
|
|
17
|
+
.addOption('language', options.language, async (harness, language) => {
|
|
18
|
+
const lang = await harness.getLanguage();
|
|
19
|
+
if (lang === null) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return HarnessPredicate.stringMatches(lang, language);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Gets the code text content. */
|
|
26
|
+
async getCode() {
|
|
27
|
+
const codeEl = await this.codeElement();
|
|
28
|
+
return codeEl.text();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets the language label.
|
|
32
|
+
* Returns `null` if no language is set.
|
|
33
|
+
*/
|
|
34
|
+
async getLanguage() {
|
|
35
|
+
const preEl = await this.preElement();
|
|
36
|
+
const ariaLabel = await preEl.getAttribute('aria-label');
|
|
37
|
+
if (!ariaLabel || ariaLabel === 'Code') {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
// aria-label follows the pattern "{language} code"
|
|
41
|
+
return ariaLabel.replace(/ code$/, '');
|
|
42
|
+
}
|
|
43
|
+
/** Clicks the copy button to copy code to clipboard. */
|
|
44
|
+
async copyToClipboard() {
|
|
45
|
+
const button = await this.copyButton();
|
|
46
|
+
return button.click();
|
|
47
|
+
}
|
|
48
|
+
/** Whether the copy button is currently showing the "Copied" state. */
|
|
49
|
+
async isCopied() {
|
|
50
|
+
const label = await this.getCopyButtonLabel();
|
|
51
|
+
return label === 'Copied';
|
|
52
|
+
}
|
|
53
|
+
/** Gets the copy button's aria-label. */
|
|
54
|
+
async getCopyButtonLabel() {
|
|
55
|
+
const button = await this.copyButton();
|
|
56
|
+
const label = await button.getAttribute('aria-label');
|
|
57
|
+
return label ?? '';
|
|
58
|
+
}
|
|
59
|
+
/** Whether the code block is disabled (copy button is disabled). */
|
|
60
|
+
async isDisabled() {
|
|
61
|
+
const button = await this.copyButton();
|
|
62
|
+
return button.getProperty('disabled');
|
|
63
|
+
}
|
|
64
|
+
/** Whether the code block host is focused. */
|
|
65
|
+
async isFocused() {
|
|
66
|
+
const host = await this.host();
|
|
67
|
+
return host.isFocused();
|
|
68
|
+
}
|
|
69
|
+
/** Focuses the code block host element. */
|
|
70
|
+
async focus() {
|
|
71
|
+
const host = await this.host();
|
|
72
|
+
return host.focus();
|
|
73
|
+
}
|
|
74
|
+
/** Blurs the code block host element. */
|
|
75
|
+
async blur() {
|
|
76
|
+
const host = await this.host();
|
|
77
|
+
return host.blur();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Testing utilities for the code-block component
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Generated bundle index. Do not edit.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
export { ComCodeBlockHarness };
|
|
88
|
+
//# sourceMappingURL=ngx-com-components-code-block-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-com-components-code-block-testing.mjs","sources":["../../../projects/com/components/code-block/testing/code-block.harness.ts","../../../projects/com/components/code-block/testing/index.ts","../../../projects/com/components/code-block/testing/ngx-com-components-code-block-testing.ts"],"sourcesContent":["import {\n ComponentHarness,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport type { BaseHarnessFilters } from '@angular/cdk/testing';\n\n/** Harness filters for ComCodeBlockHarness. */\nexport interface ComCodeBlockHarnessFilters extends BaseHarnessFilters {\n /** Filter by the code block's language label. */\n language?: string | RegExp;\n}\n\n/**\n * Harness for interacting with a ComCodeBlock in tests.\n */\nexport class ComCodeBlockHarness extends ComponentHarness {\n static hostSelector = 'com-code-block';\n\n private readonly codeElement = this.locatorFor('code');\n private readonly preElement = this.locatorFor('pre');\n private readonly copyButton = this.locatorFor('button[type=\"button\"]');\n\n /**\n * Gets a HarnessPredicate for matching code blocks.\n * @param options Filter options.\n */\n static with(options: ComCodeBlockHarnessFilters = {}): HarnessPredicate<ComCodeBlockHarness> {\n return new HarnessPredicate(ComCodeBlockHarness, options)\n .addOption('language', options.language, async (harness, language) => {\n const lang = await harness.getLanguage();\n if (lang === null) {\n return false;\n }\n return HarnessPredicate.stringMatches(lang, language);\n });\n }\n\n /** Gets the code text content. */\n async getCode(): Promise<string> {\n const codeEl = await this.codeElement();\n return codeEl.text();\n }\n\n /**\n * Gets the language label.\n * Returns `null` if no language is set.\n */\n async getLanguage(): Promise<string | null> {\n const preEl = await this.preElement();\n const ariaLabel = await preEl.getAttribute('aria-label');\n if (!ariaLabel || ariaLabel === 'Code') {\n return null;\n }\n // aria-label follows the pattern \"{language} code\"\n return ariaLabel.replace(/ code$/, '');\n }\n\n /** Clicks the copy button to copy code to clipboard. */\n async copyToClipboard(): Promise<void> {\n const button = await this.copyButton();\n return button.click();\n }\n\n /** Whether the copy button is currently showing the \"Copied\" state. */\n async isCopied(): Promise<boolean> {\n const label = await this.getCopyButtonLabel();\n return label === 'Copied';\n }\n\n /** Gets the copy button's aria-label. */\n async getCopyButtonLabel(): Promise<string> {\n const button = await this.copyButton();\n const label = await button.getAttribute('aria-label');\n return label ?? '';\n }\n\n /** Whether the code block is disabled (copy button is disabled). */\n async isDisabled(): Promise<boolean> {\n const button = await this.copyButton();\n return button.getProperty<boolean>('disabled');\n }\n\n /** Whether the code block host is focused. */\n async isFocused(): Promise<boolean> {\n const host = await this.host();\n return host.isFocused();\n }\n\n /** Focuses the code block host element. */\n async focus(): Promise<void> {\n const host = await this.host();\n return host.focus();\n }\n\n /** Blurs the code block host element. */\n async blur(): Promise<void> {\n const host = await this.host();\n return host.blur();\n }\n}\n","// Testing utilities for the code-block component\n\nexport { ComCodeBlockHarness } from './code-block.harness';\n\nexport type { ComCodeBlockHarnessFilters } from './code-block.harness';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAYA;;AAEG;AACG,MAAO,mBAAoB,SAAQ,gBAAgB,CAAA;AACvD,IAAA,OAAO,YAAY,GAAG,gBAAgB;AAErB,IAAA,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;AACrC,IAAA,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;AACnC,IAAA,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC;AAEtE;;;AAGG;AACH,IAAA,OAAO,IAAI,CAAC,OAAA,GAAsC,EAAE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