✅ Oppdaterer landingsside tester
This commit is contained in:
parent
f303081d4e
commit
2fb4a478bd
5 changed files with 77 additions and 60 deletions
|
@ -1,9 +1,20 @@
|
|||
import { defineConfig } from "cypress";
|
||||
import { plugin } from "./cypress/plugins/index";
|
||||
|
||||
export default defineConfig({
|
||||
viewportHeight: 1300,
|
||||
viewportWidth: 1800,
|
||||
requestTimeout: 10000,
|
||||
defaultCommandTimeout: 10000,
|
||||
video: false,
|
||||
retries: {
|
||||
runMode: 2,
|
||||
},
|
||||
e2e: {
|
||||
//@ts-ignore
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
return plugin(on, config);
|
||||
},
|
||||
baseUrl: "http://localhost:5173",
|
||||
},
|
||||
});
|
|
@ -1,43 +0,0 @@
|
|||
import { slowCypressDown } from 'cypress-slow-down'
|
||||
|
||||
// Notat: Husk å kjør opp frontend før tester
|
||||
|
||||
slowCypressDown() // gjør at testene ikke kjører dritfort
|
||||
|
||||
describe('Landingsside loader ordentlig', () => {
|
||||
context('Resolution er 1080p', () => {
|
||||
beforeEach(() => {
|
||||
cy.viewport(1920, 1080)
|
||||
})
|
||||
|
||||
it('passes', () => {
|
||||
cy.visit('http://localhost:5173/')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Klarer å navigere frem og tilbake til/fra "Meld inn feil"-side', () => {
|
||||
context('Går til "Meld inn feil"-siden', () => {
|
||||
beforeEach(() => {
|
||||
cy.viewport(1920, 1080)
|
||||
})
|
||||
|
||||
it('passes', () => {
|
||||
cy.visit('http://localhost:5173/')
|
||||
|
||||
cy.contains('Meld inn feil').click()
|
||||
})
|
||||
})
|
||||
|
||||
context('Går tilbake til hovedsiden', () => {
|
||||
beforeEach(() => {
|
||||
cy.viewport(1920, 1080)
|
||||
})
|
||||
|
||||
it('passes', () => {
|
||||
cy.visit('http://localhost:5173/nyfeil')
|
||||
|
||||
cy.contains('Gå tilbake til hovedmenyen').click()
|
||||
})
|
||||
})
|
||||
})
|
34
frontend/cypress/plugins/index.ts
Normal file
34
frontend/cypress/plugins/index.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
/// <reference types="cypress" />
|
||||
// ***********************************************************
|
||||
// This example plugins/index.js can be used to load plugins
|
||||
//
|
||||
// You can change the location of this file or turn off loading
|
||||
// the plugins file with the 'pluginsFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/plugins-guide
|
||||
// ***********************************************************
|
||||
|
||||
// This function is called when a project is opened or re-opened (e.g. due to
|
||||
// the project's config changing)
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
export const plugin: Cypress.PluginConfig = (on: Cypress.PluginEvents) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
on("task", {
|
||||
log(message: string) {
|
||||
console.log(message);
|
||||
|
||||
return null;
|
||||
},
|
||||
table(message: string) {
|
||||
console.table(message);
|
||||
|
||||
return null;
|
||||
},
|
||||
});
|
||||
};
|
|
@ -1,3 +1,5 @@
|
|||
import 'cypress-axe'
|
||||
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************
|
||||
// This example commands.ts shows you how to
|
||||
|
@ -24,14 +26,19 @@
|
|||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
//
|
||||
// declare global {
|
||||
// namespace Cypress {
|
||||
// interface Chainable {
|
||||
// login(email: string, password: string): Chainable<void>
|
||||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
||||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
||||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Cypress.Commands.add("checkPageA11y", () => {
|
||||
cy.injectAxe();
|
||||
cy.configureAxe({
|
||||
rules: [
|
||||
// {
|
||||
// id: "svg-img-alt",
|
||||
// enabled: false,
|
||||
// },
|
||||
//Skrur av fordi checkA11y ikke vet at div er en gyldig children av <dl>-elementer
|
||||
],
|
||||
});
|
||||
cy.checkA11y(
|
||||
undefined
|
||||
);
|
||||
});
|
|
@ -18,3 +18,11 @@ import './commands'
|
|||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
|
||||
declare global {
|
||||
namespace Cypress {
|
||||
interface Chainable {
|
||||
checkPageA11y(): Chainable<JQuery<HTMLElement>>;
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue