Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enhance active route comparison to allow if/else restrictions (#87)
- Loading branch information
Showing
4 changed files
with
63 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,56 @@ | ||
import { getToolbar, getText } from '../support/app.po'; | ||
import { | ||
getToolbar, | ||
getText, | ||
getNavigationLinks, | ||
getToggleButton, | ||
getRestrictionLabel, | ||
} from '../support/app.po'; | ||
|
||
describe('route-restrictions', () => { | ||
beforeEach(() => cy.visit('/')); | ||
|
||
it('should display home page text', () => { | ||
cy.visit('/'); | ||
getToolbar().contains('Route restrictions'); | ||
getText().contains('This route is OPEN'); | ||
getToggleButton().should('be.visible'); | ||
}); | ||
|
||
it('should display toggle button and restriction', () => { | ||
cy.visit('/'); | ||
getToggleButton().should('be.visible'); | ||
getRestrictionLabel().should('contain.text', 'OFF'); | ||
}); | ||
|
||
it('should toggle restriction on toggle click', () => { | ||
cy.visit('/'); | ||
getRestrictionLabel().should('contain.text', 'OFF'); | ||
getToggleButton().click(); | ||
getRestrictionLabel().should('contain.text', 'ON'); | ||
}); | ||
|
||
it('should display restrictions page text', () => { | ||
cy.visit('/restricted'); | ||
getText().contains('This route is restricted'); | ||
}); | ||
|
||
it('should switch to restrictions on nav click', () => { | ||
cy.visit('/'); | ||
getNavigationLinks().eq(1).click(); | ||
cy.url().should('eq', 'http://localhost:4200/restricted'); | ||
getText().contains('This route is restricted'); | ||
}); | ||
|
||
it('should redirect to home page when restriction is set', () => { | ||
cy.visit('/restricted'); | ||
getToggleButton().click(); | ||
cy.url().should('eq', 'http://localhost:4200/'); | ||
getText().contains('This route is OPEN'); | ||
}); | ||
|
||
it('should redirect to home page when restriction is set on nav click', () => { | ||
cy.visit('/'); | ||
getToggleButton().click(); | ||
getNavigationLinks().eq(1).click(); | ||
cy.url().should('eq', 'http://localhost:4200/'); | ||
getText().contains('This route is OPEN'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export const getToolbar = () => cy.get('mat-toolbar'); | ||
export const getText = () => cy.get('p'); | ||
export const getNavigationLinks = () => cy.get('a.mat-button'); | ||
export const getToggleButton = () => cy.get('button:contains("Toggle")'); | ||
export const getRestrictionLabel = () => cy.get('label'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters