From b15d736ec5aa85e7d040f10e3ee4160747fae3da Mon Sep 17 00:00:00 2001 From: ingrid <ingrimeg@stud.ntnu.no> Date: Fri, 21 Apr 2023 11:23:09 +0200 Subject: [PATCH] sypress tester til navbar --- cypress.config.js | 2 +- cypress/e2e/navbar.cy.js | 23 +++++++++++++++++++++-- src/components/Navbar.vue | 4 ++-- src/views/MissingPage.vue | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/cypress.config.js b/cypress.config.js index 9cf6a19..de4d849 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -3,6 +3,6 @@ const { defineConfig } = require('cypress') module.exports = defineConfig({ e2e: { specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}', - baseUrl: 'http://localhost:4173' + baseUrl: 'http://localhost:5173' } }) diff --git a/cypress/e2e/navbar.cy.js b/cypress/e2e/navbar.cy.js index 2cbd9b1..68eeaa6 100644 --- a/cypress/e2e/navbar.cy.js +++ b/cypress/e2e/navbar.cy.js @@ -1,6 +1,25 @@ describe('Correct navigation links', () => { - /*TODO*/ + it("is sent to error page if page does not exist", () => { + cy.visit('/qwerty') + cy.contains('#msg', '404') + }) + + it("navigates to settings page", () => { + cy.visit('/') + cy.get('#settingsIcon').click() + cy.url().should('include', '/profileSettings') + }) + /*TODO: Other pages*/ }) describe('Navbar on all pages', () => { - /*TODO*/ + it("front page has a navbar",()=> { + cy.visit('/') + cy.get('nav').should('exist') + }) + + it("settings page has a navbar",()=> { + cy.visit('/profileSettings') + cy.get('nav').should('exist') + }) + /*TODO: other pages*/ }) \ No newline at end of file diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index 1364857..b71d45b 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -26,8 +26,8 @@ </RouterLink> </li> <li> - <RouterLink :to="'/'" :aria-label="'link to settings page'"> - <Icon icon="mdi:cog" :color="iconColor" :style="{ fontSize: iconSize }"/> + <RouterLink :to="'/profileSettings'" :aria-label="'link to settings page'"> + <Icon id="settingsIcon" icon="mdi:cog" :color="iconColor" :style="{ fontSize: iconSize }"/> </RouterLink> </li> </ul> diff --git a/src/views/MissingPage.vue b/src/views/MissingPage.vue index 1f97af7..e110350 100644 --- a/src/views/MissingPage.vue +++ b/src/views/MissingPage.vue @@ -1,5 +1,5 @@ <template> - <h1>404</h1> + <h1 id="msg">404</h1> <h2>Oida, denne siden finnes ikke</h2> <RouterLink to="/">GÃ¥ tilbake til forsiden</RouterLink> </template> -- GitLab