diff --git a/src/material/checkbox/testing/checkbox-harness.spec.ts b/src/material/checkbox/testing/checkbox-harness.spec.ts index dadfad5e56af..5d5d9fc2fcbc 100644 --- a/src/material/checkbox/testing/checkbox-harness.spec.ts +++ b/src/material/checkbox/testing/checkbox-harness.spec.ts @@ -167,6 +167,17 @@ describe('MatCheckboxHarness', () => { await disabledCheckbox.toggle(); expect(await disabledCheckbox.isChecked()).toBe(false); }); + + it('should get disabled state for checkbox with disabledInteractive', async () => { + fixture.componentInstance.disabled.set(false); + fixture.componentInstance.disabledInteractive.set(true); + + const checkbox = await loader.getHarness(MatCheckboxHarness.with({label: 'Second'})); + expect(await checkbox.isDisabled()).toBe(false); + + fixture.componentInstance.disabled.set(true); + expect(await checkbox.isDisabled()).toBe(true); + }); }); @Component({ @@ -179,7 +190,11 @@ describe('MatCheckboxHarness', () => { aria-label="First checkbox"> First - + Second Second checkbox @@ -190,4 +205,5 @@ describe('MatCheckboxHarness', () => { class CheckboxHarnessTest { ctrl = new FormControl(true); disabled = signal(true); + disabledInteractive = signal(false); } diff --git a/src/material/checkbox/testing/checkbox-harness.ts b/src/material/checkbox/testing/checkbox-harness.ts index f81e1c1c1f9e..9a0f07ec601d 100644 --- a/src/material/checkbox/testing/checkbox-harness.ts +++ b/src/material/checkbox/testing/checkbox-harness.ts @@ -72,8 +72,14 @@ export class MatCheckboxHarness extends ComponentHarness { /** Whether the checkbox is disabled. */ async isDisabled(): Promise { - const disabled = (await this._input()).getAttribute('disabled'); - return coerceBooleanProperty(await disabled); + const input = await this._input(); + const disabled = await input.getAttribute('disabled'); + + if (disabled !== null) { + return coerceBooleanProperty(disabled); + } + + return (await input.getAttribute('aria-disabled')) === 'true'; } /** Whether the checkbox is required. */