From 0f02d98f34cf74e99d85763b73833ef6df225a2d Mon Sep 17 00:00:00 2001 From: Dolav Soker Date: Sat, 26 Oct 2024 21:52:52 -0700 Subject: [PATCH 1/8] Add support to getDiameter and getStrokeWidth in MatProgressSpinnerHarness Adding missing attributes in MatProgressSpinnerHarness --- .../progress-spinner/progress-spinner.ts | 4 ++- .../testing/progress-spinner-harness.spec.ts | 27 +++++++++++++++++++ .../testing/progress-spinner-harness.ts | 14 +++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/material/progress-spinner/progress-spinner.ts b/src/material/progress-spinner/progress-spinner.ts index a8b805e88224..653960c5409f 100644 --- a/src/material/progress-spinner/progress-spinner.ts +++ b/src/material/progress-spinner/progress-spinner.ts @@ -86,7 +86,9 @@ const BASE_STROKE_WIDTH = 10; '[attr.aria-valuemin]': '0', '[attr.aria-valuemax]': '100', '[attr.aria-valuenow]': 'mode === "determinate" ? value : null', - '[attr.mode]': 'mode', + '[attr.data-mat-progress-spinner-mode]': 'mode', + '[attr.data-mat-progress-spinner-diameter]': 'diameter', + '[attr.data-mat-progress-spinner-strokeWidth]': 'strokeWidth', }, templateUrl: 'progress-spinner.html', styleUrl: 'progress-spinner.css', diff --git a/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts b/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts index bac8d2eb0d60..f5a6fec6d870 100644 --- a/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts +++ b/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts @@ -40,6 +40,30 @@ describe('MatProgressSpinnerHarness', () => { expect(await indeterminate.getMode()).toBe('indeterminate'); expect(await impliedIndeterminate.getMode()).toBe('indeterminate'); }); + + it('should get the diameter', async () => { + const withAttributs = + await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-attributs'})); + expect(await withAttributs.getDiameter()).toBe(30); + fixture.componentInstance.diameter.set(20); + expect(await withAttributs.getDiameter()).toBe(20); + }); + + it('should get the strokeWidth', async () => { + const withAttributs = + await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-attributs'})); + expect(await withAttributs.getStrokeWidth()).toBe(3); + fixture.componentInstance.strokeWidth.set(5); + expect(await withAttributs.getStrokeWidth()).toBe(5); + }); + + it('should get the strokeWidth when undefined', async () => { + const withAttributs = + await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-attributs'})); + expect(await withAttributs.getStrokeWidth()).toBe(3); + fixture.componentInstance.diameter.set(20); + expect(await withAttributs.getStrokeWidth()).toBe(2); + }); }); @Component({ @@ -47,10 +71,13 @@ describe('MatProgressSpinnerHarness', () => { + `, standalone: true, imports: [MatProgressSpinnerModule], }) class ProgressSpinnerHarnessTest { value = signal(0); + diameter = signal(30); + strokeWidth = signal(3); } diff --git a/src/material/progress-spinner/testing/progress-spinner-harness.ts b/src/material/progress-spinner/testing/progress-spinner-harness.ts index 5c161cfd165b..dff7a951184f 100644 --- a/src/material/progress-spinner/testing/progress-spinner-harness.ts +++ b/src/material/progress-spinner/testing/progress-spinner-harness.ts @@ -42,7 +42,19 @@ export class MatProgressSpinnerHarness extends ComponentHarness { /** Gets the progress spinner's mode. */ async getMode(): Promise { - const modeAttr = (await this.host()).getAttribute('mode'); + const modeAttr = (await this.host()).getAttribute('data-mat-progress-spinner-mode'); return (await modeAttr) as ProgressSpinnerMode; } + + /** Gets the progress spinner's diameter. */ + async getDiameter(): Promise { + const diameterAttr = (await this.host()).getAttribute('data-mat-progress-spinner-diameter'); + return (await diameterAttr) as ProgressSpinnerMode; + } + + /** Gets the progress spinner's strokeWidth. */ + async getStrokeWidth(): Promise { + const strokeWidthAttr = (await this.host()).getAttribute('data-mat-progress-spinner-strokeWidth'); + return (await strokeWidthAttr) as ProgressSpinnerMode; + } } From 73d4d1cb43520efc873dde5febd7d6679b12158c Mon Sep 17 00:00:00 2001 From: Dolav Soker Date: Sat, 26 Oct 2024 22:02:27 -0700 Subject: [PATCH 2/8] Update progress-spinner-harness.ts --- .../testing/progress-spinner-harness.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/material/progress-spinner/testing/progress-spinner-harness.ts b/src/material/progress-spinner/testing/progress-spinner-harness.ts index dff7a951184f..c4c86a4d2304 100644 --- a/src/material/progress-spinner/testing/progress-spinner-harness.ts +++ b/src/material/progress-spinner/testing/progress-spinner-harness.ts @@ -48,13 +48,15 @@ export class MatProgressSpinnerHarness extends ComponentHarness { /** Gets the progress spinner's diameter. */ async getDiameter(): Promise { - const diameterAttr = (await this.host()).getAttribute('data-mat-progress-spinner-diameter'); - return (await diameterAttr) as ProgressSpinnerMode; + const host = await this.host(); + const diameterAttr = await host.getAttribute('data-mat-progress-spinner-diameter'); + return diameterAttr ? coerceNumberProperty(diameterAttr) : null; } /** Gets the progress spinner's strokeWidth. */ async getStrokeWidth(): Promise { - const strokeWidthAttr = (await this.host()).getAttribute('data-mat-progress-spinner-strokeWidth'); - return (await strokeWidthAttr) as ProgressSpinnerMode; + const host = await this.host(); + const strokeWidthAttr = await host.getAttribute('data-mat-progress-spinner-strokeWidth'); + return strokeWidthAttr ? coerceNumberProperty(strokeWidthAttr) : null; } } From 6a1b116aa2c79be217ab91a5e493dfb2d243e4a2 Mon Sep 17 00:00:00 2001 From: Dolav Soker Date: Sat, 26 Oct 2024 22:04:00 -0700 Subject: [PATCH 3/8] Update progress-spinner-harness.spec.ts --- .../progress-spinner/testing/progress-spinner-harness.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts b/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts index f5a6fec6d870..6eee298362ea 100644 --- a/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts +++ b/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts @@ -71,7 +71,7 @@ describe('MatProgressSpinnerHarness', () => { - + `, standalone: true, imports: [MatProgressSpinnerModule], From c480e6989772bbc591a865152480cf07755a782e Mon Sep 17 00:00:00 2001 From: Dolav Soker Date: Sat, 26 Oct 2024 22:17:00 -0700 Subject: [PATCH 4/8] Update progress-spinner-harness.spec.ts --- .../testing/progress-spinner-harness.spec.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts b/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts index 6eee298362ea..ccad235f3127 100644 --- a/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts +++ b/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts @@ -43,7 +43,7 @@ describe('MatProgressSpinnerHarness', () => { it('should get the diameter', async () => { const withAttributs = - await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-attributs'})); + await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-diameter'})); expect(await withAttributs.getDiameter()).toBe(30); fixture.componentInstance.diameter.set(20); expect(await withAttributs.getDiameter()).toBe(20); @@ -51,7 +51,7 @@ describe('MatProgressSpinnerHarness', () => { it('should get the strokeWidth', async () => { const withAttributs = - await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-attributs'})); + await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-strokeWidth'})); expect(await withAttributs.getStrokeWidth()).toBe(3); fixture.componentInstance.strokeWidth.set(5); expect(await withAttributs.getStrokeWidth()).toBe(5); @@ -59,7 +59,7 @@ describe('MatProgressSpinnerHarness', () => { it('should get the strokeWidth when undefined', async () => { const withAttributs = - await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-attributs'})); + await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-strokeWidth'})); expect(await withAttributs.getStrokeWidth()).toBe(3); fixture.componentInstance.diameter.set(20); expect(await withAttributs.getStrokeWidth()).toBe(2); @@ -70,8 +70,7 @@ describe('MatProgressSpinnerHarness', () => { template: ` - - + `, standalone: true, imports: [MatProgressSpinnerModule], From 591b27252e23f1cdca0f143a37466c3c1b29b1b3 Mon Sep 17 00:00:00 2001 From: Dolav Soker Date: Sat, 26 Oct 2024 22:20:26 -0700 Subject: [PATCH 5/8] Update progress-spinner-harness.spec.ts --- .../testing/progress-spinner-harness.spec.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts b/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts index ccad235f3127..1e5e800cc347 100644 --- a/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts +++ b/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts @@ -42,26 +42,23 @@ describe('MatProgressSpinnerHarness', () => { }); it('should get the diameter', async () => { + fixture.componentInstance.diameter.set(20); const withAttributs = await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-diameter'})); - expect(await withAttributs.getDiameter()).toBe(30); - fixture.componentInstance.diameter.set(20); expect(await withAttributs.getDiameter()).toBe(20); }); it('should get the strokeWidth', async () => { + fixture.componentInstance.strokeWidth.set(5); const withAttributs = await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-strokeWidth'})); - expect(await withAttributs.getStrokeWidth()).toBe(3); - fixture.componentInstance.strokeWidth.set(5); expect(await withAttributs.getStrokeWidth()).toBe(5); }); it('should get the strokeWidth when undefined', async () => { + fixture.componentInstance.diameter.set(20); const withAttributs = await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-strokeWidth'})); - expect(await withAttributs.getStrokeWidth()).toBe(3); - fixture.componentInstance.diameter.set(20); expect(await withAttributs.getStrokeWidth()).toBe(2); }); }); @@ -77,6 +74,6 @@ describe('MatProgressSpinnerHarness', () => { }) class ProgressSpinnerHarnessTest { value = signal(0); - diameter = signal(30); - strokeWidth = signal(3); + diameter = signal(); + strokeWidth = signal(); } From 8793b6fd84f416d176a13d1128ac7f0fac156974 Mon Sep 17 00:00:00 2001 From: Dolav Soker Date: Sat, 26 Oct 2024 22:30:49 -0700 Subject: [PATCH 6/8] Update progress-spinner-harness.spec.ts --- .../testing/progress-spinner-harness.spec.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts b/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts index 1e5e800cc347..63f4f911cf75 100644 --- a/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts +++ b/src/material/progress-spinner/testing/progress-spinner-harness.spec.ts @@ -54,13 +54,6 @@ describe('MatProgressSpinnerHarness', () => { await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-strokeWidth'})); expect(await withAttributs.getStrokeWidth()).toBe(5); }); - - it('should get the strokeWidth when undefined', async () => { - fixture.componentInstance.diameter.set(20); - const withAttributs = - await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-strokeWidth'})); - expect(await withAttributs.getStrokeWidth()).toBe(2); - }); }); @Component({ @@ -74,6 +67,6 @@ describe('MatProgressSpinnerHarness', () => { }) class ProgressSpinnerHarnessTest { value = signal(0); - diameter = signal(); - strokeWidth = signal(); + diameter = signal(30); + strokeWidth = signal(3); } From 839e2935ad3ed7eb92c493585ecd7b169cdc8953 Mon Sep 17 00:00:00 2001 From: Dolav Soker Date: Sat, 26 Oct 2024 22:40:45 -0700 Subject: [PATCH 7/8] Update progress-spinner-harness.ts --- .../progress-spinner/testing/progress-spinner-harness.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/material/progress-spinner/testing/progress-spinner-harness.ts b/src/material/progress-spinner/testing/progress-spinner-harness.ts index c4c86a4d2304..3320f2c61db1 100644 --- a/src/material/progress-spinner/testing/progress-spinner-harness.ts +++ b/src/material/progress-spinner/testing/progress-spinner-harness.ts @@ -42,21 +42,24 @@ export class MatProgressSpinnerHarness extends ComponentHarness { /** Gets the progress spinner's mode. */ async getMode(): Promise { - const modeAttr = (await this.host()).getAttribute('data-mat-progress-spinner-mode'); + const modeAttr = + (await this.host()).getAttribute('data-mat-progress-spinner-mode'); return (await modeAttr) as ProgressSpinnerMode; } /** Gets the progress spinner's diameter. */ async getDiameter(): Promise { const host = await this.host(); - const diameterAttr = await host.getAttribute('data-mat-progress-spinner-diameter'); + const diameterAttr = + await host.getAttribute('data-mat-progress-spinner-diameter'); return diameterAttr ? coerceNumberProperty(diameterAttr) : null; } /** Gets the progress spinner's strokeWidth. */ async getStrokeWidth(): Promise { const host = await this.host(); - const strokeWidthAttr = await host.getAttribute('data-mat-progress-spinner-strokeWidth'); + const strokeWidthAttr = + await host.getAttribute('data-mat-progress-spinner-strokeWidth'); return strokeWidthAttr ? coerceNumberProperty(strokeWidthAttr) : null; } } From 3af200d8404f1f5b55c06be2c6e7eed67b8d5c2b Mon Sep 17 00:00:00 2001 From: Dolav Soker Date: Sat, 26 Oct 2024 22:49:57 -0700 Subject: [PATCH 8/8] Update progress-spinner-harness.ts --- .../progress-spinner/testing/progress-spinner-harness.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/material/progress-spinner/testing/progress-spinner-harness.ts b/src/material/progress-spinner/testing/progress-spinner-harness.ts index 3320f2c61db1..30aa111bf86e 100644 --- a/src/material/progress-spinner/testing/progress-spinner-harness.ts +++ b/src/material/progress-spinner/testing/progress-spinner-harness.ts @@ -50,16 +50,14 @@ export class MatProgressSpinnerHarness extends ComponentHarness { /** Gets the progress spinner's diameter. */ async getDiameter(): Promise { const host = await this.host(); - const diameterAttr = - await host.getAttribute('data-mat-progress-spinner-diameter'); + const diameterAttr = await host.getAttribute('data-mat-progress-spinner-diameter'); return diameterAttr ? coerceNumberProperty(diameterAttr) : null; } /** Gets the progress spinner's strokeWidth. */ async getStrokeWidth(): Promise { const host = await this.host(); - const strokeWidthAttr = - await host.getAttribute('data-mat-progress-spinner-strokeWidth'); + const strokeWidthAttr = await host.getAttribute('data-mat-progress-spinner-strokeWidth'); return strokeWidthAttr ? coerceNumberProperty(strokeWidthAttr) : null; } }