Skip to content

Commit 334d4de

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 199d17f commit 334d4de

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ describe('StepperHarnessExample', () => {
4747

4848
await secondStep.select();
4949

50-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
50+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
5151
false,
5252
true,
5353
false,
5454
]);
5555

5656
await nextButton.click();
5757

58-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
58+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
5959
false,
6060
false,
6161
true,

src/material/stepper/stepper.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ describe('MatStepper', () => {
132132
expect(stepperComponent.selected instanceof MatStep).toBe(true);
133133
});
134134

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

139139
const stepperEl = stepperWrapper!.nativeElement;

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

+1-3
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

+3-14
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

+9-9
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ describe('MatStepperHarness', () => {
9292
const stepper = await loader.getHarness(MatStepperHarness.with({selector: '#two-stepper'}));
9393
const steps = await stepper.getSteps();
9494

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

101101
await stepper.selectStep({label: 'Three'});
102102

103-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
103+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
104104
false,
105105
false,
106106
true,
@@ -167,7 +167,7 @@ describe('MatStepperHarness', () => {
167167
const stepper = await loader.getHarness(MatStepperHarness.with({selector: '#two-stepper'}));
168168
const steps = await stepper.getSteps();
169169

170-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
170+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
171171
true,
172172
false,
173173
false,
@@ -199,15 +199,15 @@ describe('MatStepperHarness', () => {
199199
const stepper = await loader.getHarness(MatStepperHarness.with({selector: '#two-stepper'}));
200200
const steps = await stepper.getSteps();
201201

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

208208
await steps[2].select();
209209

210-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
210+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
211211
false,
212212
false,
213213
true,
@@ -265,15 +265,15 @@ describe('MatStepperHarness', () => {
265265

266266
await secondStep.select();
267267

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

274274
await nextButton.click();
275275

276-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
276+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
277277
false,
278278
false,
279279
true,
@@ -313,15 +313,15 @@ describe('MatStepperHarness', () => {
313313

314314
await secondStep.select();
315315

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

322322
await previousButton.click();
323323

324-
expect(await parallel(() => steps.map(step => step.isSelected()))).toEqual([
324+
expect(await parallel(() => steps.map(step => step.isExpanded()))).toEqual([
325325
true,
326326
false,
327327
false,

0 commit comments

Comments
 (0)