Skip to content

Commit a81d14a

Browse files
committed
test(material/stepper): updates tests affected by new stepper aria roles & attributes
Updates all tests that are affected by the updated stepper aria roles and attributes.
1 parent 3e5f925 commit a81d14a

File tree

5 files changed

+17
-30
lines changed

5 files changed

+17
-30
lines changed

src/components-examples/material/stepper/stepper-harness/stepper-harness-example.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ describe('StepperHarnessExample', () => {
4343

4444
await secondStep.select();
4545

46-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
46+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
4747
false,
4848
true,
4949
false,
5050
]);
5151

5252
await nextButton.click();
5353

54-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
54+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
5555
false,
5656
false,
5757
true,

src/material/stepper/stepper.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ describe('MatStepper', () => {
131131
expect(stepperComponent.selected instanceof MatStep).toBe(true);
132132
});
133133

134-
it('should set the "group" role on a vertical stepper', () => {
135-
const stepperWrapper = fixture.debugElement.query(By.css('.mat-vertical-stepper-wrapper'));
134+
it('should set the "group" role on the stepper', () => {
135+
const stepperWrapper = fixture.debugElement.query(By.css('.mat-stepper-wrapper'));
136136
expect(stepperWrapper).toBeTruthy();
137137

138138
const stepperEl = stepperWrapper!.nativeElement;

src/material/stepper/testing/step-harness-filters.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ export enum StepperOrientation {
1717
export interface StepHarnessFilters extends BaseHarnessFilters {
1818
/** Only find instances whose label matches the given value. */
1919
label?: string | RegExp;
20-
/** Only find steps with the given selected (if Horizontal stepper) state. */
21-
selected?: boolean;
22-
/** Only find steps with the given expanded (if Vertical stepper) state. */
20+
/** Only find steps with the given expanded state. */
2321
expanded?: boolean;
2422
/** Only find completed steps. */
2523
completed?: boolean;

src/material/stepper/testing/step-harness.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ export class MatStepHarness extends ContentContainerComponentHarness<string> {
2929
.addOption('label', options.label, (harness, label) =>
3030
HarnessPredicate.stringMatches(harness.getLabel(), label),
3131
)
32-
.addOption(
33-
'selected',
34-
options.selected,
35-
async (harness, selected) => (await harness.isSelected()) === selected,
36-
)
3732
.addOption(
3833
'expanded',
3934
options.expanded,
@@ -66,13 +61,7 @@ export class MatStepHarness extends ContentContainerComponentHarness<string> {
6661
return (await this.host()).getAttribute('aria-labelledby');
6762
}
6863

69-
/** Whether the step is selected (Horizontal Stepper). */
70-
async isSelected(): Promise<boolean> {
71-
const host = await this.host();
72-
return (await host.getAttribute('aria-selected')) === 'true';
73-
}
74-
75-
/** Whether the step is expanded (Vertical Stepper). */
64+
/** Whether the step is expanded. */
7665
async isExpanded(): Promise<boolean> {
7766
const host = await this.host();
7867
return (await host.getAttribute('aria-expanded')) === 'true';
@@ -81,7 +70,7 @@ export class MatStepHarness extends ContentContainerComponentHarness<string> {
8170
/** Whether the step has been filled out. */
8271
async isCompleted(): Promise<boolean> {
8372
const state = await this._getIconState();
84-
return state === 'done' || (state === 'edit' && !(await this.isSelected()));
73+
return state === 'done' || (state === 'edit' && !(await this.isExpanded()));
8574
}
8675

8776
/**
@@ -103,7 +92,7 @@ export class MatStepHarness extends ContentContainerComponentHarness<string> {
10392
}
10493

10594
/**
106-
* Selects the given step by clicking on the label. The step may not be selected
95+
* Selects the given step by clicking on the label. The step may not be selected/expanded
10796
* if the stepper doesn't allow it (e.g. if there are validation errors).
10897
*/
10998
async select(): Promise<void> {

src/material/stepper/testing/stepper-harness.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ describe('MatStepperHarness', () => {
9090
const stepper = await loader.getHarness(MatStepperHarness.with({selector: '#two-stepper'}));
9191
const steps = await stepper.getSteps();
9292

93-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
93+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
9494
true,
9595
false,
9696
false,
9797
]);
9898

9999
await stepper.selectStep({label: 'Three'});
100100

101-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
101+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
102102
false,
103103
false,
104104
true,
@@ -165,7 +165,7 @@ describe('MatStepperHarness', () => {
165165
const stepper = await loader.getHarness(MatStepperHarness.with({selector: '#two-stepper'}));
166166
const steps = await stepper.getSteps();
167167

168-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
168+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
169169
true,
170170
false,
171171
false,
@@ -197,15 +197,15 @@ describe('MatStepperHarness', () => {
197197
const stepper = await loader.getHarness(MatStepperHarness.with({selector: '#two-stepper'}));
198198
const steps = await stepper.getSteps();
199199

200-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
200+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
201201
true,
202202
false,
203203
false,
204204
]);
205205

206206
await steps[2].select();
207207

208-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
208+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
209209
false,
210210
false,
211211
true,
@@ -263,15 +263,15 @@ describe('MatStepperHarness', () => {
263263

264264
await secondStep.select();
265265

266-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
266+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
267267
false,
268268
true,
269269
false,
270270
]);
271271

272272
await nextButton.click();
273273

274-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
274+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
275275
false,
276276
false,
277277
true,
@@ -311,15 +311,15 @@ describe('MatStepperHarness', () => {
311311

312312
await secondStep.select();
313313

314-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
314+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
315315
false,
316316
true,
317317
false,
318318
]);
319319

320320
await previousButton.click();
321321

322-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
322+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
323323
true,
324324
false,
325325
false,

0 commit comments

Comments
 (0)