Skip to content

Commit d36ab12

Browse files
committed
test(material/stepper): update stepper tests
Work on fixing failing tests.
1 parent 8d4e68e commit d36ab12

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

src/material/stepper/stepper.html

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
[tabIndex]="_getFocusIndex() === $index ? 0 : -1"
7474
[id]="_getStepLabelId($index)"
7575
[attr.aria-expanded]="selectedIndex === $index"
76+
[attr.aria-pressed]="selectedIndex == $index"
7677
[attr.aria-controls]="_getStepContentId($index)"
7778
[attr.aria-current]="selectedIndex == $index"
7879
[attr.aria-label]="step.ariaLabel || null"

src/material/stepper/stepper.spec.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ describe('MatStepper', () => {
133133
});
134134

135135
it('should set the "region" role on the vertical stepper', () => {
136-
const stepperEl = fixture.debugElement.query(By.css('mat-stepper'))!.nativeElement;
136+
const stepperEl = fixture.debugElement.query(
137+
By.css('mat-vertical-stepper-wrapper'),
138+
)!.nativeElement;
137139
expect(stepperEl.getAttribute('role')).toBe('region');
138140
});
139141

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

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export interface StepHarnessFilters extends BaseHarnessFilters {
1919
label?: string | RegExp;
2020
/** Only find steps with the given selected state. */
2121
selected?: boolean;
22+
/** Only find steps with the given pressed state. */
23+
pressed?: boolean;
2224
/** Only find completed steps. */
2325
completed?: boolean;
2426
/** Only find steps that have errors. */

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export class MatStepHarness extends ContentContainerComponentHarness<string> {
3434
options.selected,
3535
async (harness, selected) => (await harness.isSelected()) === selected,
3636
)
37+
.addOption(
38+
'pressed',
39+
options.pressed,
40+
async (harness, pressed) => (await harness.isPressed()) === pressed,
41+
)
3742
.addOption(
3843
'completed',
3944
options.completed,
@@ -67,10 +72,19 @@ export class MatStepHarness extends ContentContainerComponentHarness<string> {
6772
return (await host.getAttribute('aria-selected')) === 'true';
6873
}
6974

75+
/** Whether the step is selected. */
76+
async isPressed(): Promise<boolean> {
77+
const host = await this.host();
78+
return (await host.getAttribute('aria-pressed')) === 'true';
79+
}
80+
7081
/** Whether the step has been filled out. */
7182
async isCompleted(): Promise<boolean> {
7283
const state = await this._getIconState();
73-
return state === 'done' || (state === 'edit' && !(await this.isSelected()));
84+
return (
85+
state === 'done' ||
86+
(state === 'edit' && !((await this.isSelected()) || (await this.isPressed())))
87+
);
7488
}
7589

7690
/**

0 commit comments

Comments
 (0)