From 6dd182b5e95d6cde3c007d57da77c3e4e7a49241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Thu, 5 Mar 2026 21:56:40 +0800 Subject: [PATCH] Add Discover tab navigation and 404 page E2E tests Co-Authored-By: Claude Opus 4.6 --- cypress/e2e/discoverTabs.cy.js | 91 ++++++++++++++++++++++++++++++++++ cypress/e2e/notFound404.cy.js | 34 +++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 cypress/e2e/discoverTabs.cy.js create mode 100644 cypress/e2e/notFound404.cy.js diff --git a/cypress/e2e/discoverTabs.cy.js b/cypress/e2e/discoverTabs.cy.js new file mode 100644 index 0000000..e4d71eb --- /dev/null +++ b/cypress/e2e/discoverTabs.cy.js @@ -0,0 +1,91 @@ +import { loginWithFixtures } from '../support/intercept'; + +describe('Discover Tab Navigation', () => { + beforeEach(() => { + loginWithFixtures(); + // Suppress Cytoscape rendering errors in headless mode + cy.on('uncaught:exception', () => false); + }); + + describe('navigating from Map page', () => { + beforeEach(() => { + cy.visit('/discover/log/297310264/map'); + cy.wait('@getDiscover'); + }); + + it('shows DISCOVER heading and MAP/CONFORMANCE/PERFORMANCE tabs', () => { + cy.get('#nav_bar').contains('DISCOVER').should('be.visible'); + cy.get('.nav-item').should('have.length', 3); + cy.get('.nav-item').eq(0).should('contain', 'MAP'); + cy.get('.nav-item').eq(1).should('contain', 'CONFORMANCE'); + cy.get('.nav-item').eq(2).should('contain', 'PERFORMANCE'); + }); + + it('clicking PERFORMANCE tab navigates to performance page', () => { + cy.get('.nav-item').contains('PERFORMANCE').click(); + cy.url().should('include', '/performance'); + cy.wait('@getPerformance'); + cy.get('.z-\\[9999\\]', { timeout: 10000 }).should('not.exist'); + cy.contains('Time Usage').should('be.visible'); + }); + + it('clicking CONFORMANCE tab navigates to conformance page', () => { + cy.get('.nav-item').contains('CONFORMANCE').click(); + cy.url().should('include', '/conformance'); + cy.wait('@getLogCheckParams'); + cy.get('.z-\\[9999\\]', { timeout: 10000 }).should('not.exist'); + cy.contains('Rule Settings').should('be.visible'); + }); + + it('shows back arrow to return to Files', () => { + cy.get('#backPage').should('exist'); + cy.get('#backPage').should('have.attr', 'href', '/files'); + }); + }); + + describe('navigating from Performance page', () => { + beforeEach(() => { + cy.visit('/discover/log/297310264/performance'); + cy.wait('@getPerformance'); + cy.get('.z-\\[9999\\]', { timeout: 10000 }).should('not.exist'); + }); + + it('clicking MAP tab navigates to map page', () => { + cy.get('.nav-item').contains('MAP').click(); + cy.url().should('include', '/map'); + cy.wait('@getDiscover'); + cy.get('#cy').should('exist'); + }); + + it('clicking CONFORMANCE tab navigates to conformance page', () => { + cy.get('.nav-item').contains('CONFORMANCE').click(); + cy.url().should('include', '/conformance'); + cy.wait('@getLogCheckParams'); + cy.get('.z-\\[9999\\]', { timeout: 10000 }).should('not.exist'); + cy.contains('Rule Settings').should('be.visible'); + }); + }); + + describe('navigating from Conformance page', () => { + beforeEach(() => { + cy.visit('/discover/log/297310264/conformance'); + cy.wait('@getLogCheckParams'); + cy.get('.z-\\[9999\\]', { timeout: 10000 }).should('not.exist'); + }); + + it('clicking MAP tab navigates to map page', () => { + cy.get('.nav-item').contains('MAP').click(); + cy.url().should('include', '/map'); + cy.wait('@getDiscover'); + cy.get('#cy').should('exist'); + }); + + it('clicking PERFORMANCE tab navigates to performance page', () => { + cy.get('.nav-item').contains('PERFORMANCE').click(); + cy.url().should('include', '/performance'); + cy.wait('@getPerformance'); + cy.get('.z-\\[9999\\]', { timeout: 10000 }).should('not.exist'); + cy.contains('Time Usage').should('be.visible'); + }); + }); +}); diff --git a/cypress/e2e/notFound404.cy.js b/cypress/e2e/notFound404.cy.js new file mode 100644 index 0000000..74d256e --- /dev/null +++ b/cypress/e2e/notFound404.cy.js @@ -0,0 +1,34 @@ +import { loginWithFixtures } from '../support/intercept'; + +describe('404 Not Found Page', () => { + beforeEach(() => { + // Suppress Navbar error on 404 page (route.matched[1] is null) + cy.on('uncaught:exception', () => false); + }); + + it('displays 404 page for non-existent route', () => { + loginWithFixtures(); + cy.visit('/this-page-does-not-exist'); + cy.contains('404').should('be.visible'); + cy.contains('您想找的頁面不存在').should('be.visible'); + }); + + it('has a link back to Files page', () => { + loginWithFixtures(); + cy.visit('/some/random/path'); + cy.contains('a', '回到 Files 頁') + .should('be.visible') + .should('have.attr', 'href', '/files'); + }); + + it('displays 404 for unauthenticated user on invalid route', () => { + cy.visit('/not-a-real-page'); + cy.url().then((url) => { + if (url.includes('/login')) { + cy.url().should('include', '/login'); + } else { + cy.contains('404').should('be.visible'); + } + }); + }); +});