Skip to content

Commit bb7af77

Browse files
crisbetojelbourn
authored andcommitted
test(grid-list): disable flaky tests in Edge (#16504)
Disables some tests that have become so flaky that they aren't very useful in Edge.
1 parent e8c8866 commit bb7af77

File tree

2 files changed

+108
-10
lines changed

2 files changed

+108
-10
lines changed

src/material/grid-list/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ng_test_library(
4848
deps = [
4949
":grid-list",
5050
"//src/cdk/bidi",
51+
"//src/cdk/platform",
5152
"@npm//@angular/platform-browser",
5253
],
5354
)

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

Lines changed: 107 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
1-
import {TestBed, ComponentFixture} from '@angular/core/testing';
1+
import {TestBed, ComponentFixture, inject} 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';
78

89

910
describe('MatGridList', () => {
11+
let disableComputedStyleTests = false;
12+
1013
function createComponent<T>(componentType: Type<T>): ComponentFixture<T> {
1114
TestBed.configureTestingModule({
1215
imports: [MatGridListModule],
1316
declarations: [componentType],
1417
}).compileComponents();
1518

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

32+
afterEach(() => disableComputedStyleTests = false);
33+
1934
it('should throw error if cols is not defined', () => {
2035
const fixture = createComponent(GridListWithoutCols);
2136

@@ -71,6 +86,11 @@ describe('MatGridList', () => {
7186

7287
it('should default to 1:1 row height if undefined ', () => {
7388
const fixture = createComponent(GridListWithUnspecifiedRowHeight);
89+
90+
if (disableComputedStyleTests) {
91+
return;
92+
}
93+
7494
fixture.detectChanges();
7595
const tile = fixture.debugElement.query(By.directive(MatGridTile));
7696
const inlineStyles = tile.nativeElement.style;
@@ -84,6 +104,10 @@ describe('MatGridList', () => {
84104
it('should use a ratio row height if passed in', () => {
85105
const fixture = createComponent(GirdListWithRowHeightRatio);
86106

107+
if (disableComputedStyleTests) {
108+
return;
109+
}
110+
87111
fixture.componentInstance.rowHeight = '4:1';
88112
fixture.detectChanges();
89113

@@ -105,6 +129,10 @@ describe('MatGridList', () => {
105129
it('should divide row height evenly in "fit" mode', () => {
106130
const fixture = createComponent(GridListWithFitRowHeightMode);
107131

132+
if (disableComputedStyleTests) {
133+
return;
134+
}
135+
108136
fixture.componentInstance.totalHeight = '300px';
109137
fixture.detectChanges();
110138
const tile = fixture.debugElement.query(By.directive(MatGridTile));
@@ -122,6 +150,10 @@ describe('MatGridList', () => {
122150
it('should use the fixed row height if passed in', () => {
123151
const fixture = createComponent(GridListWithFixedRowHeightMode);
124152

153+
if (disableComputedStyleTests) {
154+
return;
155+
}
156+
125157
fixture.componentInstance.rowHeight = '100px';
126158
fixture.detectChanges();
127159

@@ -136,16 +168,24 @@ describe('MatGridList', () => {
136168

137169
it('should default to pixels if row height units are missing', () => {
138170
const fixture = createComponent(GridListWithUnitlessFixedRowHeight);
139-
fixture.detectChanges();
140171

172+
if (disableComputedStyleTests) {
173+
return;
174+
}
175+
176+
fixture.detectChanges();
141177
const tile = fixture.debugElement.query(By.directive(MatGridTile));
142178
expect(getDimension(tile, 'height')).toBe(100);
143179
});
144180

145181
it('should default gutter size to 1px', () => {
146182
const fixture = createComponent(GridListWithUnspecifiedGutterSize);
147-
fixture.detectChanges();
148183

184+
if (disableComputedStyleTests) {
185+
return;
186+
}
187+
188+
fixture.detectChanges();
149189
const tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile'));
150190

151191
// check horizontal gutter
@@ -161,6 +201,10 @@ describe('MatGridList', () => {
161201
const fixture = createComponent(GridListWithUnspecifiedGutterSize);
162202
const gridList = fixture.debugElement.query(By.directive(MatGridList));
163203

204+
if (disableComputedStyleTests) {
205+
return;
206+
}
207+
164208
gridList.componentInstance.gutterSize = 0;
165209
fixture.detectChanges();
166210

@@ -177,8 +221,12 @@ describe('MatGridList', () => {
177221

178222
it('should lay out the tiles correctly for a nested grid list', () => {
179223
const fixture = createComponent(NestedGridList);
180-
fixture.detectChanges();
181224

225+
if (disableComputedStyleTests) {
226+
return;
227+
}
228+
229+
fixture.detectChanges();
182230
const innerTiles = fixture.debugElement.queryAll(
183231
By.css('mat-grid-tile mat-grid-list mat-grid-tile'));
184232

@@ -189,8 +237,12 @@ describe('MatGridList', () => {
189237

190238
it('should set the gutter size if passed', () => {
191239
const fixture = createComponent(GridListWithGutterSize);
192-
fixture.detectChanges();
193240

241+
if (disableComputedStyleTests) {
242+
return;
243+
}
244+
245+
fixture.detectChanges();
194246
const tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile'));
195247

196248
// check horizontal gutter
@@ -204,8 +256,12 @@ describe('MatGridList', () => {
204256

205257
it('should use pixels if gutter units are missing', () => {
206258
const fixture = createComponent(GridListWithUnitlessGutterSize);
207-
fixture.detectChanges();
208259

260+
if (disableComputedStyleTests) {
261+
return;
262+
}
263+
264+
fixture.detectChanges();
209265
const tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile'));
210266

211267
// check horizontal gutter
@@ -221,6 +277,10 @@ describe('MatGridList', () => {
221277
const fixture = createComponent(GridListWithUnspecifiedGutterSize);
222278
const gridList = fixture.debugElement.query(By.directive(MatGridList));
223279

280+
if (disableComputedStyleTests) {
281+
return;
282+
}
283+
224284
gridList.componentInstance.gutterSize = '10%';
225285
fixture.detectChanges();
226286

@@ -232,8 +292,12 @@ describe('MatGridList', () => {
232292

233293
it('should set the correct list height in ratio mode', () => {
234294
const fixture = createComponent(GridListWithRatioHeightAndMulipleRows);
235-
fixture.detectChanges();
236295

296+
if (disableComputedStyleTests) {
297+
return;
298+
}
299+
300+
fixture.detectChanges();
237301
const list = fixture.debugElement.query(By.directive(MatGridList));
238302
const inlineStyles = list.nativeElement.style;
239303

@@ -244,14 +308,23 @@ describe('MatGridList', () => {
244308

245309
it('should set the correct list height in fixed mode', () => {
246310
const fixture = createComponent(GridListWithFixRowHeightAndMultipleRows);
247-
fixture.detectChanges();
248311

312+
if (disableComputedStyleTests) {
313+
return;
314+
}
315+
316+
fixture.detectChanges();
249317
const list = fixture.debugElement.query(By.directive(MatGridList));
250318
expect(getDimension(list, 'height')).toBe(201);
251319
});
252320

253321
it('should allow adjustment of tile colspan', () => {
254322
const fixture = createComponent(GridListWithColspanBinding);
323+
324+
if (disableComputedStyleTests) {
325+
return;
326+
}
327+
255328
fixture.componentInstance.colspan = 2;
256329
fixture.detectChanges();
257330

@@ -266,6 +339,10 @@ describe('MatGridList', () => {
266339
it('should allow adjustment of tile rowspan', () => {
267340
const fixture = createComponent(GridListWithRowspanBinding);
268341

342+
if (disableComputedStyleTests) {
343+
return;
344+
}
345+
269346
fixture.componentInstance.rowspan = 2;
270347
fixture.detectChanges();
271348

@@ -280,6 +357,10 @@ describe('MatGridList', () => {
280357
it('should lay out tiles correctly for a complex layout', () => {
281358
const fixture = createComponent(GridListWithComplexLayout);
282359

360+
if (disableComputedStyleTests) {
361+
return;
362+
}
363+
283364
fixture.componentInstance.tiles = [
284365
{cols: 3, rows: 1},
285366
{cols: 1, rows: 2},
@@ -314,6 +395,10 @@ describe('MatGridList', () => {
314395
it('should lay out tiles correctly', () => {
315396
const fixture = createComponent(GridListWithLayout);
316397

398+
if (disableComputedStyleTests) {
399+
return;
400+
}
401+
317402
fixture.detectChanges();
318403
const tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile'));
319404

@@ -347,6 +432,10 @@ describe('MatGridList', () => {
347432
() => {
348433
const fixture = createComponent(GridListWithSingleCellAtBeginning);
349434

435+
if (disableComputedStyleTests) {
436+
return;
437+
}
438+
350439
fixture.detectChanges();
351440
const tiles = fixture.debugElement.queryAll(By.css('mat-grid-tile'));
352441

@@ -401,6 +490,10 @@ describe('MatGridList', () => {
401490
it('should reset the old styles when switching to a new tile styler', () => {
402491
const fixture = createComponent(GirdListWithRowHeightRatio);
403492

493+
if (disableComputedStyleTests) {
494+
return;
495+
}
496+
404497
fixture.componentInstance.rowHeight = '4:1';
405498
fixture.detectChanges();
406499

@@ -456,8 +549,12 @@ describe('MatGridList', () => {
456549

457550
it('should lay out the tiles if they are not direct descendants of the list', () => {
458551
const fixture = createComponent(GridListWithIndirectTileDescendants);
459-
fixture.detectChanges();
460552

553+
if (disableComputedStyleTests) {
554+
return;
555+
}
556+
557+
fixture.detectChanges();
461558
const tile = fixture.debugElement.query(By.directive(MatGridTile));
462559
const inlineStyles = tile.nativeElement.style;
463560

0 commit comments

Comments
 (0)