Skip to content

Commit ad4ee5a

Browse files
committed
test(grid): enhance action strip visibility tests for pinned rows
1 parent 1927f71 commit ad4ee5a

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

projects/igniteui-angular/src/lib/action-strip/grid-actions/grid-pinning-actions.component.spec.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,52 @@ describe('igxGridPinningActions #grid ', () => {
7171
const secondToLastVisible = grid.rowList.toArray()[grid.rowList.length - 2];
7272
expect(secondToLastVisible.key).toEqual('FAMIA');
7373
});
74+
75+
it('should keep action strip visible and preserve context when jumping from hovered pinned row', async () => {
76+
grid.pinRow('FAMIA');
77+
fixture.detectChanges();
78+
79+
const pinnedRow = grid.pinnedRows[0];
80+
actionStrip.show(pinnedRow);
81+
fixture.detectChanges();
82+
83+
const initialContext = actionStrip.context;
84+
const contextElement = initialContext.element.nativeElement as HTMLElement;
85+
spyOn(contextElement, 'matches').and.callFake((selector: string) =>
86+
selector === ':hover' ? true : HTMLElement.prototype.matches.call(contextElement, selector)
87+
);
88+
89+
const pinningButtons = fixture.debugElement.queryAll(By.css(`igx-grid-pinning-actions button`));
90+
const jumpButton = pinningButtons[0];
91+
jumpButton.triggerEventHandler('click', new Event('click'));
92+
await wait();
93+
fixture.detectChanges();
94+
await wait(DEBOUNCETIME);
95+
fixture.detectChanges();
96+
97+
expect(actionStrip.hidden).toBeFalse();
98+
expect(actionStrip.context).toBe(initialContext);
99+
});
100+
101+
it('should not hide action strip in base mode when scrollToRow is invoked', () => {
102+
grid.pinRow('FAMIA');
103+
fixture.detectChanges();
104+
105+
const pinnedRow = grid.pinnedRows[0];
106+
actionStrip.show(pinnedRow);
107+
fixture.detectChanges();
108+
109+
const pinningActions = fixture.debugElement.query(By.directive(IgxGridPinningActionsComponent))
110+
.componentInstance as IgxGridPinningActionsComponent;
111+
spyOn<any>(grid, 'scrollTo');
112+
113+
pinningActions.scrollToRow(null);
114+
fixture.detectChanges();
115+
116+
expect((grid as any).scrollTo).toHaveBeenCalledWith(pinnedRow.data, 0);
117+
expect(actionStrip.hidden).toBeFalse();
118+
expect(actionStrip.context).toBe(pinnedRow);
119+
});
74120
});
75121

76122
describe('Menu ', () => {
@@ -94,6 +140,25 @@ describe('igxGridPinningActions #grid ', () => {
94140
fixture.detectChanges();
95141
expect(grid.pinnedRows.length).toBe(1);
96142
});
143+
144+
it('should hide action strip in menu mode when scrollToRow is invoked', () => {
145+
grid.pinRow('FAMIA');
146+
fixture.detectChanges();
147+
148+
const pinnedRow = grid.pinnedRows[0];
149+
actionStrip.show(pinnedRow);
150+
fixture.detectChanges();
151+
152+
const pinningActions = fixture.debugElement.query(By.directive(IgxGridPinningActionsComponent))
153+
.componentInstance as IgxGridPinningActionsComponent;
154+
spyOn<any>(grid, 'scrollTo');
155+
156+
pinningActions.scrollToRow(null);
157+
fixture.detectChanges();
158+
159+
expect((grid as any).scrollTo).toHaveBeenCalledWith(pinnedRow.data, 0);
160+
expect(actionStrip.hidden).toBeTrue();
161+
});
97162
});
98163
});
99164

0 commit comments

Comments
 (0)