✅ 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 { defineConfig } from "cypress";
|
||||||
|
import { plugin } from "./cypress/plugins/index";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
e2e: {
|
viewportHeight: 1300,
|
||||||
setupNodeEvents(on, config) {
|
viewportWidth: 1800,
|
||||||
// implement node event listeners here
|
requestTimeout: 10000,
|
||||||
},
|
defaultCommandTimeout: 10000,
|
||||||
|
video: false,
|
||||||
|
retries: {
|
||||||
|
runMode: 2,
|
||||||
},
|
},
|
||||||
});
|
e2e: {
|
||||||
|
//@ts-ignore
|
||||||
|
setupNodeEvents(on, config) {
|
||||||
|
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" />
|
/// <reference types="cypress" />
|
||||||
// ***********************************************
|
// ***********************************************
|
||||||
// This example commands.ts shows you how to
|
// This example commands.ts shows you how to
|
||||||
|
@ -24,14 +26,19 @@
|
||||||
//
|
//
|
||||||
// -- This will overwrite an existing command --
|
// -- This will overwrite an existing command --
|
||||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||||
//
|
|
||||||
// declare global {
|
Cypress.Commands.add("checkPageA11y", () => {
|
||||||
// namespace Cypress {
|
cy.injectAxe();
|
||||||
// interface Chainable {
|
cy.configureAxe({
|
||||||
// login(email: string, password: string): Chainable<void>
|
rules: [
|
||||||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
// {
|
||||||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
|
// id: "svg-img-alt",
|
||||||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
|
// enabled: false,
|
||||||
// }
|
// },
|
||||||
// }
|
//Skrur av fordi checkA11y ikke vet at div er en gyldig children av <dl>-elementer
|
||||||
// }
|
],
|
||||||
|
});
|
||||||
|
cy.checkA11y(
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
});
|
|
@ -17,4 +17,12 @@
|
||||||
import './commands'
|
import './commands'
|
||||||
|
|
||||||
// Alternatively you can use CommonJS syntax:
|
// Alternatively you can use CommonJS syntax:
|
||||||
// require('./commands')
|
// require('./commands')
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
namespace Cypress {
|
||||||
|
interface Chainable {
|
||||||
|
checkPageA11y(): Chainable<JQuery<HTMLElement>>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue