Skip to content

Commit 46e152e

Browse files
committed
test: clean up IE/Edge test workarounds
The workarounds shouldn't be necessary since we don't run tests against IE and legacy Edge anymore.
1 parent 64606fa commit 46e152e

File tree

9 files changed

+30
-170
lines changed

9 files changed

+30
-170
lines changed

src/material-experimental/mdc-input/input.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('MatMdcInput without forms', () => {
7272
const platform = TestBed.inject(Platform);
7373
fixture.detectChanges();
7474

75-
if (!(platform.TRIDENT || (platform.SAFARI && !platform.IOS))) {
75+
if (!platform.SAFARI && !platform.IOS) {
7676
const formField = fixture.debugElement.query(By.directive(MatFormField))!
7777
.componentInstance as MatFormField;
7878
expect(formField).toBeTruthy();
@@ -86,7 +86,7 @@ describe('MatMdcInput without forms', () => {
8686
const platform = TestBed.inject(Platform);
8787
fixture.detectChanges();
8888

89-
if (platform.TRIDENT || (platform.SAFARI && !platform.IOS)) {
89+
if (!platform.SAFARI && !platform.IOS) {
9090
const formField = fixture.debugElement.query(By.directive(MatFormField))!
9191
.componentInstance as MatFormField;
9292
expect(formField).toBeTruthy();

src/material/button/testing/shared.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function runHarnessTests(
9393
// cancel dispatched click events on disabled buttons. We skip this check on Edge and Firefox.
9494
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1582570 and:
9595
// https://stackoverflow.com/questions/32377026/disabled-button-is-clickable-on-edge-browser
96-
if (platform.EDGE || platform.FIREFOX) {
96+
if (platform.FIREFOX) {
9797
return;
9898
}
9999

src/material/grid-list/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ ng_test_library(
4949
deps = [
5050
":grid-list",
5151
"//src/cdk/bidi",
52-
"//src/cdk/platform",
5352
"@npm//@angular/platform-browser",
5453
],
5554
)

src/material/grid-list/grid-list.spec.ts

Lines changed: 2 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,20 @@
1-
import {TestBed, ComponentFixture, inject} from '@angular/core/testing';
1+
import {TestBed, ComponentFixture} from '@angular/core/testing';
22
import {Component, DebugElement, Type, ViewChild} from '@angular/core';
33
import {By} from '@angular/platform-browser';
44
import {MatGridList, MatGridListModule} from './index';
55
import {MatGridTile, MatGridTileText} from './grid-tile';
66
import {Directionality} from '@angular/cdk/bidi';
7-
import {Platform} from '@angular/cdk/platform';
87

98
describe('MatGridList', () => {
10-
let disableComputedStyleTests = false;
11-
129
function createComponent<T>(componentType: Type<T>): ComponentFixture<T> {
1310
TestBed.configureTestingModule({
1411
imports: [MatGridListModule],
1512
declarations: [componentType],
1613
}).compileComponents();
1714

18-
const fixture = TestBed.createComponent<T>(componentType);
19-
20-
inject([Platform], (platform: Platform) => {
21-
// IE and Edge aren't consistent in the values that they return from `getComputedStyle`.
22-
// In some cases they return the computed values, and in others the passed-in ones. We use
23-
// this flag to disable the tests that depend on `getComputedStyle` in order to avoid flakes.
24-
// TODO: we can re-enable them when we start testing against the Chromium-based Edge.
25-
disableComputedStyleTests = platform.EDGE || platform.TRIDENT;
26-
})();
27-
28-
return fixture;
15+
return TestBed.createComponent<T>(componentType);
2916
}
3017

31-
afterEach(() => (disableComputedStyleTests = false));
32-
3318
it('should throw error if cols is not defined', () => {
3419
const fixture = createComponent(GridListWithoutCols);
3520

@@ -86,10 +71,6 @@ describe('MatGridList', () => {
8671
it('should default to 1:1 row height if undefined ', () => {
8772
const fixture = createComponent(GridListWithUnspecifiedRowHeight);
8873

89-
if (disableComputedStyleTests) {
90-
return;
91-
}
92-
9374
fixture.detectChanges();
9475
const tile = fixture.debugElement.query(By.directive(MatGridTile))!;
9576
const inlineStyles = tile.nativeElement.style;
@@ -103,10 +84,6 @@ describe('MatGridList', () => {
10384
it('should use a ratio row height if passed in', () => {
10485
const fixture = createComponent(GirdListWithRowHeightRatio);
10586

106-
if (disableComputedStyleTests) {
107-
return;
108-
}
109-
11087
fixture.componentInstance.rowHeight = '4:1';
11188
fixture.detectChanges();
11289

@@ -128,10 +105,6 @@ describe('MatGridList', () => {
128105
it('should divide row height evenly in "fit" mode', () => {
129106
const fixture = createComponent(GridListWithFitRowHeightMode);
130107

131-
if (disableComputedStyleTests) {
132-
return;
133-
}
134-
135108
fixture.componentInstance.totalHeight = '300px';
136109
fixture.detectChanges();
137110
const tile = fixture.debugElement.query(By.directive(MatGridTile))!;
@@ -149,10 +122,6 @@ describe('MatGridList', () => {
149122
it('should use the fixed row height if passed in', () => {
150123
const fixture = createComponent(GridListWithFixedRowHeightMode);
151124

152-
if (disableComputedStyleTests) {
153-
return;
154-
}
155-
156125
fixture.componentInstance.rowHeight = '100px';
157126
fixture.detectChanges();
158127

@@ -168,10 +137,6 @@ describe('MatGridList', () => {
168137
it('should default to pixels if row height units are missing', () => {
169138
const fixture = createComponent(GridListWithUnitlessFixedRowHeight);
170139

171-
if (disableComputedStyleTests) {
172-
return;
173-
}
174-
175140
fixture.detectChanges();
176141
const tile = fixture.debugElement.query(By.directive(MatGridTile))!;
177142
expect(getDimension(tile, 'height')).toBe(100);
@@ -180,10 +145,6 @@ describe('MatGridList', () => {
180145
it('should default gutter size to 1px', () => {
181146
const fixture = createComponent(GridListWithUnspecifiedGutterSize);
182147

183-
if (disableComputedStyleTests) {
184-
return;
185-
}
186-
187148
fixture.detectChanges();
188149
const tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile'));
189150

@@ -200,10 +161,6 @@ describe('MatGridList', () => {
200161
const fixture = createComponent(GridListWithUnspecifiedGutterSize);
201162
const gridList = fixture.debugElement.query(By.directive(MatGridList))!;
202163

203-
if (disableComputedStyleTests) {
204-
return;
205-
}
206-
207164
gridList.componentInstance.gutterSize = 0;
208165
fixture.detectChanges();
209166

@@ -221,10 +178,6 @@ describe('MatGridList', () => {
221178
it('should lay out the tiles correctly for a nested grid list', () => {
222179
const fixture = createComponent(NestedGridList);
223180

224-
if (disableComputedStyleTests) {
225-
return;
226-
}
227-
228181
fixture.detectChanges();
229182
const innerTiles = fixture.debugElement.queryAll(
230183
By.css('mat-grid-tile mat-grid-list mat-grid-tile'),
@@ -238,10 +191,6 @@ describe('MatGridList', () => {
238191
it('should set the gutter size if passed', () => {
239192
const fixture = createComponent(GridListWithGutterSize);
240193

241-
if (disableComputedStyleTests) {
242-
return;
243-
}
244-
245194
fixture.detectChanges();
246195
const tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile'));
247196

@@ -257,10 +206,6 @@ describe('MatGridList', () => {
257206
it('should use pixels if gutter units are missing', () => {
258207
const fixture = createComponent(GridListWithUnitlessGutterSize);
259208

260-
if (disableComputedStyleTests) {
261-
return;
262-
}
263-
264209
fixture.detectChanges();
265210
const tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile'));
266211

@@ -277,10 +222,6 @@ describe('MatGridList', () => {
277222
const fixture = createComponent(GridListWithUnspecifiedGutterSize);
278223
const gridList = fixture.debugElement.query(By.directive(MatGridList))!;
279224

280-
if (disableComputedStyleTests) {
281-
return;
282-
}
283-
284225
gridList.componentInstance.gutterSize = '10%';
285226
fixture.detectChanges();
286227

@@ -293,10 +234,6 @@ describe('MatGridList', () => {
293234
it('should set the correct list height in ratio mode', () => {
294235
const fixture = createComponent(GridListWithRatioHeightAndMulipleRows);
295236

296-
if (disableComputedStyleTests) {
297-
return;
298-
}
299-
300237
fixture.detectChanges();
301238
const list = fixture.debugElement.query(By.directive(MatGridList))!;
302239
const inlineStyles = list.nativeElement.style;
@@ -309,10 +246,6 @@ describe('MatGridList', () => {
309246
it('should set the correct list height in fixed mode', () => {
310247
const fixture = createComponent(GridListWithFixRowHeightAndMultipleRows);
311248

312-
if (disableComputedStyleTests) {
313-
return;
314-
}
315-
316249
fixture.detectChanges();
317250
const list = fixture.debugElement.query(By.directive(MatGridList))!;
318251
expect(getDimension(list, 'height')).toBe(201);
@@ -321,10 +254,6 @@ describe('MatGridList', () => {
321254
it('should allow adjustment of tile colspan', () => {
322255
const fixture = createComponent(GridListWithColspanBinding);
323256

324-
if (disableComputedStyleTests) {
325-
return;
326-
}
327-
328257
fixture.componentInstance.colspan = 2;
329258
fixture.detectChanges();
330259

@@ -339,10 +268,6 @@ describe('MatGridList', () => {
339268
it('should allow adjustment of tile rowspan', () => {
340269
const fixture = createComponent(GridListWithRowspanBinding);
341270

342-
if (disableComputedStyleTests) {
343-
return;
344-
}
345-
346271
fixture.componentInstance.rowspan = 2;
347272
fixture.detectChanges();
348273

@@ -357,10 +282,6 @@ describe('MatGridList', () => {
357282
it('should lay out tiles correctly for a complex layout', () => {
358283
const fixture = createComponent(GridListWithComplexLayout);
359284

360-
if (disableComputedStyleTests) {
361-
return;
362-
}
363-
364285
fixture.componentInstance.tiles = [
365286
{cols: 3, rows: 1},
366287
{cols: 1, rows: 2},
@@ -395,10 +316,6 @@ describe('MatGridList', () => {
395316
it('should lay out tiles correctly', () => {
396317
const fixture = createComponent(GridListWithLayout);
397318

398-
if (disableComputedStyleTests) {
399-
return;
400-
}
401-
402319
fixture.detectChanges();
403320
const tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile'));
404321

@@ -431,10 +348,6 @@ describe('MatGridList', () => {
431348
it('should lay out tiles correctly when single cell to be placed at the beginning', () => {
432349
const fixture = createComponent(GridListWithSingleCellAtBeginning);
433350

434-
if (disableComputedStyleTests) {
435-
return;
436-
}
437-
438351
fixture.detectChanges();
439352
const tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile'));
440353

@@ -497,10 +410,6 @@ describe('MatGridList', () => {
497410
it('should reset the old styles when switching to a new tile styler', () => {
498411
const fixture = createComponent(GirdListWithRowHeightRatio);
499412

500-
if (disableComputedStyleTests) {
501-
return;
502-
}
503-
504413
fixture.componentInstance.rowHeight = '4:1';
505414
fixture.detectChanges();
506415

@@ -562,10 +471,6 @@ describe('MatGridList', () => {
562471
it('should lay out the tiles if they are not direct descendants of the list', () => {
563472
const fixture = createComponent(GridListWithIndirectTileDescendants);
564473

565-
if (disableComputedStyleTests) {
566-
return;
567-
}
568-
569474
fixture.detectChanges();
570475
const tile = fixture.debugElement.query(By.directive(MatGridTile))!;
571476
const inlineStyles = tile.nativeElement.style;

src/material/input/input.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('MatInput without forms', () => {
8080
const platform = TestBed.inject(Platform);
8181
fixture.detectChanges();
8282

83-
if (!(platform.TRIDENT || (platform.SAFARI && !platform.IOS))) {
83+
if (!platform.SAFARI && !platform.IOS) {
8484
const el = fixture.debugElement.query(By.css('label'))!.nativeElement;
8585
expect(el).not.toBeNull();
8686
expect(el.classList.contains('mat-form-field-empty')).toBe(false);
@@ -93,7 +93,7 @@ describe('MatInput without forms', () => {
9393
const platform = TestBed.inject(Platform);
9494
fixture.detectChanges();
9595

96-
if (platform.TRIDENT || (platform.SAFARI && !platform.IOS)) {
96+
if (!platform.SAFARI && !platform.IOS) {
9797
const el = fixture.debugElement.query(By.css('label'))!.nativeElement;
9898
expect(el).not.toBeNull();
9999
expect(el.classList.contains('mat-form-field-empty')).toBe(true);

src/material/select/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ ng_test_library(
6363
"//src/cdk/bidi",
6464
"//src/cdk/keycodes",
6565
"//src/cdk/overlay",
66-
"//src/cdk/platform",
6766
"//src/cdk/scrolling",
6867
"//src/cdk/testing/private",
6968
"//src/material/core",

src/material/select/select.spec.ts

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
ESCAPE,
1414
} from '@angular/cdk/keycodes';
1515
import {OverlayContainer} from '@angular/cdk/overlay';
16-
import {Platform} from '@angular/cdk/platform';
1716
import {ScrollDispatcher, ViewportRuler} from '@angular/cdk/scrolling';
1817
import {
1918
createKeyboardEvent,
@@ -78,7 +77,6 @@ describe('MatSelect', () => {
7877
let dir: {value: 'ltr' | 'rtl'; change: Observable<string>};
7978
let scrolledSubject = new Subject();
8079
let viewportRuler: ViewportRuler;
81-
let platform: Platform;
8280

8381
/**
8482
* Configures the test module for MatSelect with the given declarations. This is broken out so
@@ -109,9 +107,8 @@ describe('MatSelect', () => {
109107
],
110108
}).compileComponents();
111109

112-
inject([OverlayContainer, Platform], (oc: OverlayContainer, p: Platform) => {
110+
inject([OverlayContainer], (oc: OverlayContainer) => {
113111
overlayContainerElement = oc.getContainerElement();
114-
platform = p;
115112
})();
116113
}
117114

@@ -3890,12 +3887,6 @@ describe('MatSelect', () => {
38903887
}));
38913888

38923889
it('should account for preceding label groups when aligning the option', fakeAsync(() => {
3893-
// Test is off-by-one on edge for some reason, but verified that it looks correct through
3894-
// manual testing.
3895-
if (platform.EDGE) {
3896-
return;
3897-
}
3898-
38993890
fixture.destroy();
39003891

39013892
const groupFixture = TestBed.createComponent(SelectWithGroups);
@@ -3933,12 +3924,6 @@ describe('MatSelect', () => {
39333924
}));
39343925

39353926
it('should account for indirect preceding label groups when aligning the option', fakeAsync(() => {
3936-
// Test is off-by-one on edge for some reason, but verified that it looks correct through
3937-
// manual testing.
3938-
if (platform.EDGE) {
3939-
return;
3940-
}
3941-
39423927
fixture.destroy();
39433928

39443929
const groupFixture = TestBed.createComponent(SelectWithIndirectDescendantGroups);
@@ -4642,20 +4627,9 @@ describe('MatSelect', () => {
46424627
const option = overlayContainerElement.querySelector('.cdk-overlay-pane mat-option');
46434628
const optionTop = option ? option.getBoundingClientRect().top : 0;
46444629

4645-
// There appears to be a small rounding error on IE, so we verify that the value is close,
4646-
// not exact.
4647-
if (platform.TRIDENT) {
4648-
const difference = Math.abs(
4649-
optionTop + (menuItemHeight - triggerHeight) / 2 - triggerTop,
4650-
);
4651-
expect(difference)
4652-
.withContext('Expected trigger to align with the first option.')
4653-
.toBeLessThan(0.1);
4654-
} else {
4655-
expect(Math.floor(optionTop + (menuItemHeight - triggerHeight) / 2))
4656-
.withContext('Expected trigger to align with the first option.')
4657-
.toBe(Math.floor(triggerTop));
4658-
}
4630+
expect(Math.floor(optionTop + (menuItemHeight - triggerHeight) / 2))
4631+
.withContext('Expected trigger to align with the first option.')
4632+
.toBe(Math.floor(triggerTop));
46594633
}));
46604634

46614635
it('should not adjust if option centering is disabled any option under a group is selected', fakeAsync(() => {

0 commit comments

Comments
 (0)