Skip to content

Commit 5b2ccd2

Browse files
CopilotLipata
andcommitted
Update routing guard tests to expect tab selection regardless of guard behavior
Co-authored-by: Lipata <[email protected]>
1 parent 92fc559 commit 5b2ccd2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

projects/igniteui-angular/src/lib/tabs/bottom-nav/bottom-nav.component.spec.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ describe('IgxBottomNav', () => {
249249
});
250250

251251
describe('', () => {
252-
it('should not navigate to an URL blocked by activate guard', fakeAsync(() => {
252+
it('should allow tab selection for routing tabs regardless of router guard', fakeAsync(() => {
253253
fixture = TestBed.createComponent(BottomNavRoutingGuardTestComponent);
254254
fixture.detectChanges();
255255

@@ -269,15 +269,18 @@ describe('IgxBottomNav', () => {
269269
expect(tabItems[0].selected).toBe(true);
270270
expect(tabItems[1].selected).toBe(false);
271271

272+
// Even when router guard blocks navigation, tab should still be selected
272273
fixture.ngZone.run(() => {
273274
UIInteractions.simulateClickAndSelectEvent(headers[1]);
274275
});
275276
tick();
277+
// Navigation blocked by guard, so URL stays the same
276278
expect(location.path()).toBe('/view1');
277279
fixture.detectChanges();
278-
expect(bottomNav.selectedIndex).toBe(0);
279-
expect(tabItems[0].selected).toBe(true);
280-
expect(tabItems[1].selected).toBe(false);
280+
// But tab selection should still work
281+
expect(bottomNav.selectedIndex).toBe(1);
282+
expect(tabItems[0].selected).toBe(false);
283+
expect(tabItems[1].selected).toBe(true);
281284
}));
282285
});
283286
});

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ describe('IgxTabs', () => {
706706
expect(document.activeElement).toBe(headerElements[3]);
707707
}));
708708

709-
it('should not navigate to an URL blocked by activate guard', fakeAsync(() => {
709+
it('should allow tab selection for routing tabs regardless of router guard', fakeAsync(() => {
710710
fixture = TestBed.createComponent(TabsRoutingGuardTestComponent);
711711
tabsComp = fixture.componentInstance.tabs;
712712
fixture.detectChanges();
@@ -729,15 +729,18 @@ describe('IgxTabs', () => {
729729
expect(tabItems[0].selected).toBe(true);
730730
expect(tabItems[1].selected).toBe(false);
731731

732+
// Even when router guard blocks navigation, tab should still be selected
732733
fixture.ngZone.run(() => {
733734
UIInteractions.simulateClickAndSelectEvent(headerElements[1]);
734735
});
735736
tick();
737+
// Navigation blocked by guard, so URL stays the same
736738
expect(location.path()).toBe('/view1');
737739
fixture.detectChanges();
738-
expect(tabsComp.selectedIndex).toBe(0);
739-
expect(tabItems[0].selected).toBe(true);
740-
expect(tabItems[1].selected).toBe(false);
740+
// But tab selection should still work
741+
expect(tabsComp.selectedIndex).toBe(1);
742+
expect(tabItems[0].selected).toBe(false);
743+
expect(tabItems[1].selected).toBe(true);
741744
}));
742745

743746
it('should set auto activation mode by default and change selectedIndex on arrow keys', fakeAsync(() => {

0 commit comments

Comments
 (0)