Add Cypress E2E tests with fixture-based API mocking for UI regression protection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
57
cypress/e2e/navigation.cy.js
Normal file
57
cypress/e2e/navigation.cy.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import { loginWithFixtures, setupApiIntercepts } from '../support/intercept';
|
||||
|
||||
describe('Navigation and Routing', () => {
|
||||
it('redirects / to /files when logged in', () => {
|
||||
loginWithFixtures();
|
||||
cy.visit('/');
|
||||
cy.url().should('include', '/files');
|
||||
});
|
||||
|
||||
it('shows 404 page for unknown routes', () => {
|
||||
loginWithFixtures();
|
||||
cy.visit('/nonexistent-page');
|
||||
cy.contains('404').should('exist');
|
||||
});
|
||||
|
||||
it('navbar shows correct view name', () => {
|
||||
loginWithFixtures();
|
||||
cy.visit('/files');
|
||||
cy.wait('@getFiles');
|
||||
cy.get('#nav_bar').should('exist');
|
||||
cy.get('#nav_bar h2').should('contain', 'FILES');
|
||||
});
|
||||
|
||||
it('navbar shows back arrow on non-files pages', () => {
|
||||
loginWithFixtures();
|
||||
cy.visit('/discover/log/1/map');
|
||||
// Back arrow should be visible on discover pages
|
||||
cy.get('#backPage').should('exist');
|
||||
});
|
||||
|
||||
it('navbar tabs are clickable on discover page', () => {
|
||||
loginWithFixtures();
|
||||
cy.visit('/discover/log/1/map');
|
||||
// Discover navbar should show MAP, CONFORMANCE, PERFORMANCE tabs
|
||||
cy.contains('.nav-item', 'MAP').should('exist');
|
||||
cy.contains('.nav-item', 'CONFORMANCE').should('exist');
|
||||
cy.contains('.nav-item', 'PERFORMANCE').should('exist');
|
||||
|
||||
// Click CONFORMANCE tab
|
||||
cy.contains('.nav-item', 'CONFORMANCE').click();
|
||||
cy.url().should('include', '/conformance');
|
||||
|
||||
// Click PERFORMANCE tab
|
||||
cy.contains('.nav-item', 'PERFORMANCE').click();
|
||||
cy.url().should('include', '/performance');
|
||||
|
||||
// Click MAP tab to go back
|
||||
cy.contains('.nav-item', 'MAP').click();
|
||||
cy.url().should('include', '/map');
|
||||
});
|
||||
|
||||
it('login page is accessible at /login', () => {
|
||||
setupApiIntercepts();
|
||||
cy.visit('/login');
|
||||
cy.get('h2').should('contain', 'LOGIN');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user