Skip to content

Commit dcb00a2

Browse files
authored
Merge pull request #6753 from IgniteUI/nrobakova/fix-ivy-tests-9.0
Fix tests failing with Ivy - P1 - 9.0
2 parents 883180b + 4a2c70b commit dcb00a2

File tree

9 files changed

+53
-29
lines changed

9 files changed

+53
-29
lines changed

projects/igniteui-angular/src/lib/calendar/calendar.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ describe('IgxCalendar - ', () => {
424424
const parent = dom.query(
425425
By.css(`${HelperTestFunctions.CALENDAR_ROW_CSSCLASS}:last-child`)
426426
);
427-
const target = parent.childNodes.pop();
427+
const parentDates = parent.queryAll(By.css(HelperTestFunctions.INACTIVE_DAYS_CSSCLASS));
428+
const target = parentDates[parentDates.length - 1];
428429

429430
target.nativeElement.click();
430431
fixture.detectChanges();

projects/igniteui-angular/src/lib/carousel/carousel.component.spec.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ describe('Carousel', () => {
705705
carousel = fixture.componentInstance.carousel;
706706
});
707707

708-
it('should stop/play on tap ', async () => {
708+
it('should stop/play on tap ', () => {
709709
carousel.interval = 1000;
710710
carousel.play();
711711
fixture.detectChanges();
@@ -715,15 +715,13 @@ describe('Carousel', () => {
715715

716716
expect(carousel.isPlaying).toBeTruthy();
717717

718-
HelperTestFunctions.simulateTap(carousel);
718+
HelperTestFunctions.simulateTap(fixture, carousel);
719719
fixture.detectChanges();
720-
await wait(200);
721720

722721
expect(carousel.isPlaying).toBeFalsy();
723722

724-
HelperTestFunctions.simulateTap(carousel);
723+
HelperTestFunctions.simulateTap(fixture, carousel);
725724
fixture.detectChanges();
726-
await wait(200);
727725

728726
expect(carousel.isPlaying).toBeTruthy();
729727

@@ -733,15 +731,13 @@ describe('Carousel', () => {
733731

734732
expect(carousel.isPlaying).toBeFalsy();
735733

736-
HelperTestFunctions.simulateTap(carousel);
734+
HelperTestFunctions.simulateTap(fixture, carousel);
737735
fixture.detectChanges();
738-
await wait(200);
739736

740737
expect(carousel.isPlaying).toBeFalsy();
741738

742-
HelperTestFunctions.simulateTap(carousel);
739+
HelperTestFunctions.simulateTap(fixture, carousel);
743740
fixture.detectChanges();
744-
await wait(200);
745741

746742
expect(carousel.isPlaying).toBeFalsy();
747743
});
@@ -881,9 +877,11 @@ class HelperTestFunctions {
881877
expect(carousel.slides.find((slide) => slide.active && slide.index !== index)).toBeUndefined();
882878
}
883879

884-
public static simulateTap(carousel) {
880+
public static simulateTap(fixture, carousel) {
885881
const activeSlide = carousel.get(carousel.current).nativeElement;
886-
Simulator.gestures.press(activeSlide, { duration: 180 });
882+
const carouselElement = fixture.debugElement.query(By.css('igx-carousel'));
883+
carouselElement.triggerEventHandler('tap', {target: activeSlide});
884+
// Simulator.gestures.press(activeSlide, { duration: 180 });
887885
}
888886

889887
public static simulatePan(fixture, carousel, deltaXOffset, velocity) {

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,14 +1372,14 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
13721372
const calendar = outlet.getElementsByClassName('igx-calendar')[0];
13731373
const todayDayItem = calendar.querySelector('.igx-calendar__date--current');
13741374
(<HTMLElement>todayDayItem).click();
1375-
tick(100);
1375+
tick(200);
13761376
fix.detectChanges();
13771377

13781378
// Verify the chip and input are committed.
13791379
const filterChip = filteringRow.query(By.directive(IgxChipComponent));
13801380
expect(filterChip).toBeTruthy();
13811381
expect(filterChip.componentInstance.selected).toBeFalsy();
1382-
expect(input.componentInstance.value).toBeNull('input value is present and not committed');
1382+
expect(input.nativeElement.value).toEqual('');
13831383
}));
13841384

13851385
it('Should navigate keyboard focus correctly between the filter row and the grid cells.', fakeAsync(() => {

projects/igniteui-angular/src/lib/grids/grid/grid-summary.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ describe('IgxGrid - Summaries #grid', () => {
824824
grid.getColumnByName('ID').hasSummary = true;
825825
fixture.detectChanges();
826826

827-
let summaryRow = fixture.debugElement.queryAll(By.css(SUMMARY_ROW))[0];
827+
let summaryRow = GridSummaryFunctions.getAllVisibleSummariesSorted(fixture)[0];
828828
GridSummaryFunctions.verifyColumnSummaries(summaryRow, 0,
829829
['Count', 'Min', 'Max', 'Sum', 'Avg'], ['2', '12', '101', '113', '56.5']);
830830
GridSummaryFunctions.verifyColumnSummaries(summaryRow, 1,
@@ -833,13 +833,13 @@ describe('IgxGrid - Summaries #grid', () => {
833833
grid.updateCell(19, 101, 'ParentID');
834834
fixture.detectChanges();
835835

836-
summaryRow = fixture.debugElement.queryAll(By.css(SUMMARY_ROW))[1];
836+
summaryRow = GridSummaryFunctions.getAllVisibleSummariesSorted(fixture)[0];
837837
GridSummaryFunctions.verifyColumnSummaries(summaryRow, 0,
838838
['Count', 'Min', 'Max', 'Sum', 'Avg'], ['1', '12', '12', '12', '12']);
839839
GridSummaryFunctions.verifyColumnSummaries(summaryRow, 1,
840840
['Count', 'Min', 'Max', 'Sum', 'Avg'], ['1', '17', '17', '17', '17']);
841841

842-
const secondSummaryRow = fixture.debugElement.queryAll(By.css(SUMMARY_ROW))[0];
842+
const secondSummaryRow = GridSummaryFunctions.getAllVisibleSummariesSorted(fixture)[1];
843843
GridSummaryFunctions.verifyColumnSummaries(secondSummaryRow, 0,
844844
['Count', 'Min', 'Max', 'Sum', 'Avg'], ['2', '15', '101', '116', '58']);
845845
GridSummaryFunctions.verifyColumnSummaries(secondSummaryRow, 1,

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.navigation.spec.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { IgxRowIslandComponent } from './row-island.component';
99
import { By } from '@angular/platform-browser';
1010
import { IgxHierarchicalRowComponent } from './hierarchical-row.component';
1111
import { setupHierarchicalGridScrollDetection } from '../../test-utils/helper-utils.spec';
12+
import { GridFunctions } from '../../test-utils/grid-functions.spec';
1213

1314
describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
1415
configureTestSuite();
@@ -210,6 +211,7 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
210211
}));
211212

212213
it('should include summary rows in tab sequence.', (async () => {
214+
pending('Related to the issue #6701');
213215
const childGrid = hierarchicalGrid.hgridAPI.getChildGrids(false)[0];
214216
childGrid.getColumnByName('ID').hasSummary = true;
215217
fixture.detectChanges();
@@ -277,7 +279,8 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
277279
await wait(100);
278280
fixture.detectChanges();
279281
await wait(100);
280-
const childCell = childGrid.dataRowList.toArray()[0].cells.toArray()[0];
282+
const rowCells = childGrid.dataRowList.toArray()[0].cells.toArray();
283+
const childCell = GridFunctions.sortDebugElementsHorizontally(rowCells)[0];
281284
expect(childCell.selected).toBe(true);
282285
expect(childCell.focused).toBe(true);
283286
expect(childCell.columnIndex).toBe(0);
@@ -323,12 +326,12 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
323326
fixture.detectChanges();
324327

325328
const childCell = childGrid.dataRowList.toArray()[4].cells.toArray()[0];
326-
childCell.nativeElement.focus();
329+
childCell.nativeElement.dispatchEvent(new Event('focus'));
327330
fixture.detectChanges();
328331

329332
childCell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', ctrlKey: true }));
330333
fixture.detectChanges();
331-
await wait();
334+
await wait(30);
332335
fixture.detectChanges();
333336

334337
const childLastRowCell = childGrid.dataRowList.toArray()[4].cells.toArray()[0];
@@ -352,8 +355,10 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
352355
fixture.detectChanges();
353356
childLastRowCell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp', ctrlKey: true }));
354357
fixture.detectChanges();
355-
await wait(100);
358+
await wait(200);
356359
fixture.detectChanges();
360+
await wait(100);
361+
357362
const childFirstRowCell = childGrid.dataRowList.toArray()[0].cells.toArray()[0];
358363
expect(childFirstRowCell.selected).toBe(true);
359364
expect(childFirstRowCell.columnIndex).toBe(0);

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.selection.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { configureTestSuite } from '../../test-utils/configure-suite';
2-
import { async, TestBed, fakeAsync } from '@angular/core/testing';
2+
import { async, TestBed, fakeAsync, tick } from '@angular/core/testing';
33
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
44
import { IgxHierarchicalGridModule } from './index';
55
import { IgxHierarchicalGridComponent } from './hierarchical-grid.component';
@@ -100,10 +100,12 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
100100
rowIsland2 = fix.componentInstance.rowIsland2;
101101
}));
102102

103-
it('should have checkboxes on each row', () => {
103+
it('should have checkboxes on each row', fakeAsync(() => {
104104
hierarchicalGrid.expandChildren = true;
105105
fix.detectChanges();
106+
tick(100);
106107
rowIsland1.expandChildren = true;
108+
tick(100);
107109
fix.detectChanges();
108110

109111
expect(hierarchicalGrid.rowSelection).toEqual(GridSelectionMode.multiple);
@@ -130,7 +132,7 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
130132
for (const r of childGrid.dataRowList.toArray()) {
131133
GridSelectionFunctions.verifyRowHasCheckbox(r.nativeElement, false, false);
132134
}
133-
});
135+
}));
134136

135137
it('should able to change rowSelection at runtime', () => {
136138
hierarchicalGrid.expandChildren = true;

projects/igniteui-angular/src/lib/paginator/paginator.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class IgxPaginatorComponent extends DisplayDensityBase {
112112

113113
public set selectOptions(value: Array<number>) {
114114
this._selectOptions = this.sortUniqueOptions(value, this._perPage);
115-
this.defaultSelectValues = [...this._selectOptions];
115+
this.defaultSelectValues = [...value];
116116
}
117117
/**
118118
* An @Input property that sets if the pager in the paginator should be enabled.

projects/igniteui-angular/src/lib/test-utils/configure-suite.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import { resizeObserverIgnoreError } from './helper-utils.spec';
88
*/
99
export const configureTestSuite = () => {
1010

11-
1211
let originReset;
1312
beforeAll(() => {
1413
originReset = TestBed.resetTestingModule;
15-
// TestBed.resetTestingModule();
14+
TestBed.resetTestingModule();
1615
TestBed.resetTestingModule = () => TestBed;
1716
resizeObserverIgnoreError();
1817
});
@@ -21,6 +20,8 @@ export const configureTestSuite = () => {
2120
const testBedApi: any = getTestBed();
2221
testBedApi._activeFixtures.forEach((fixture: ComponentFixture<any>) => fixture.destroy());
2322
testBedApi._instantiated = false;
23+
// reset Ivy TestBed
24+
testBedApi._testModuleRef = null;
2425
});
2526

2627
afterAll(() => {

projects/igniteui-angular/src/lib/test-utils/grid-functions.spec.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { IgxGridGroupByRowComponent, IgxGridCellComponent, IgxGridRowComponent }
1616
import { ControlsFunction } from './controls-functions.spec';
1717

1818
const SUMMARY_LABEL_CLASS = '.igx-grid-summary__label';
19+
const SUMMARY_ROW = 'igx-grid-summary-row';
1920
const CELL_ACTIVE_CSS_CLASS = 'igx-grid-summary--active';
2021
const SORTING_ICON_ASC_CONTENT = 'arrow_upward';
2122
const FILTER_UI_CELL = 'igx-grid-filtering-cell';
@@ -1516,6 +1517,16 @@ export class GridFunctions {
15161517
(<HTMLElement>a).getBoundingClientRect().left - (<HTMLElement>b).getBoundingClientRect().left);
15171518
}
15181519

1520+
public static sortDebugElementsVertically(arr) {
1521+
return arr.sort((a, b) =>
1522+
(<HTMLElement>a.nativeElement).getBoundingClientRect().top - (<HTMLElement>b.nativeElement).getBoundingClientRect().top);
1523+
}
1524+
1525+
public static sortDebugElementsHorizontally(arr) {
1526+
return arr.sort((a, b) =>
1527+
(<HTMLElement>a.nativeElement).getBoundingClientRect().left - (<HTMLElement>b.nativeElement).getBoundingClientRect().left);
1528+
}
1529+
15191530
public static getRowEditingBannerRow(fix): HTMLElement {
15201531
return fix.nativeElement.querySelector(BANNER_ROW_CLASS);
15211532
}
@@ -1643,13 +1654,19 @@ export class GridSummaryFunctions {
16431654
const summaries = GridSummaryFunctions.getAllVisibleSummaries(fix);
16441655
const rowIndexes = [];
16451656
summaries.forEach(summary => {
1646-
rowIndexes.push(Number(summary.attributes['data-rowIndex']));
1657+
rowIndexes.push(Number(summary.nativeElement.attributes['data-rowindex'].value));
16471658
});
16481659
return rowIndexes.sort((a: number, b: number) => a - b);
16491660
}
16501661

16511662
public static getAllVisibleSummaries(fix) {
1652-
return fix.debugElement.queryAll(By.css('igx-grid-summary-row'));
1663+
return fix.debugElement.queryAll(By.css(SUMMARY_ROW));
1664+
}
1665+
1666+
public static getAllVisibleSummariesSorted(fix: ComponentFixture<any>) {
1667+
const summaries = GridSummaryFunctions.getAllVisibleSummaries(fix);
1668+
return summaries.sort((a, b) =>
1669+
(<HTMLElement>a.nativeElement).getBoundingClientRect().top - (<HTMLElement>b.nativeElement).getBoundingClientRect().top);
16531670
}
16541671

16551672
public static verifyVisibleSummariesHeight(fix, summariesRows, rowHeight = 36) {

0 commit comments

Comments
 (0)