diff --git a/frontend/cypress/e2e/lagFeilmelding.cy.ts b/frontend/cypress/e2e/lagFeilmelding.cy.ts
new file mode 100644
index 0000000..0005b84
--- /dev/null
+++ b/frontend/cypress/e2e/lagFeilmelding.cy.ts
@@ -0,0 +1,26 @@
+const fyllFeilmeldingInputs = () => {
+ cy.getByTestId('tittel-inputfelt').type('Cypress-test Tittel')
+ cy.getByTestId('beskrivelse-inputfelt').type('Cypress-test Beskrivelse')
+ cy.getByTestId('switch-toggle').click()
+}
+
+describe('Klarer å melde inn feil', () => {
+ context('Fyller ut felt, melder inn og går tilbake til hovedside', () => {
+ beforeEach(() => {
+ cy.viewport(1920, 1080)
+ cy.visit('http://localhost:5173/')
+ })
+
+ it('sjekker axe', () => {
+ cy.checkPageA11y()
+ })
+
+ it('Fyller ut felt og melder inn feil som haster', () => {
+ cy.contains('Meld inn feil').click()
+
+ fyllFeilmeldingInputs()
+
+ cy.contains('Meld inn feil').click()
+ })
+ })
+})
\ No newline at end of file
diff --git a/frontend/cypress/support/commands.ts b/frontend/cypress/support/commands.ts
index 5bbc609..39a889c 100644
--- a/frontend/cypress/support/commands.ts
+++ b/frontend/cypress/support/commands.ts
@@ -1,5 +1,4 @@
import 'cypress-axe'
-
///
// ***********************************************
// This example commands.ts shows you how to
@@ -27,6 +26,10 @@ import 'cypress-axe'
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
+Cypress.Commands.add("getByTestId", (selector, ...args) => {
+ return cy.get(`[data-testid=${selector}]`, ...args);
+});
+
Cypress.Commands.add("checkPageA11y", () => {
cy.injectAxe();
cy.configureAxe({
@@ -35,7 +38,7 @@ Cypress.Commands.add("checkPageA11y", () => {
// id: "svg-img-alt",
// enabled: false,
// },
- //Skrur av fordi checkA11y ikke vet at div er en gyldig children av
-elementer
+ // Skrur av fordi checkA11y ikke vet at div er en gyldig children av -elementer
],
});
cy.checkA11y(
diff --git a/frontend/cypress/support/e2e.ts b/frontend/cypress/support/e2e.ts
index 05caa4c..87a34cc 100644
--- a/frontend/cypress/support/e2e.ts
+++ b/frontend/cypress/support/e2e.ts
@@ -22,6 +22,10 @@ import './commands'
declare global {
namespace Cypress {
interface Chainable {
+ getByTestId(
+ selector: string,
+ ...rest: any
+ ): Chainable>;
checkPageA11y(): Chainable>;
}
}
diff --git a/frontend/src/pages/feil.tsx b/frontend/src/pages/feil.tsx
index 91d91fe..bfc7399 100644
--- a/frontend/src/pages/feil.tsx
+++ b/frontend/src/pages/feil.tsx
@@ -93,11 +93,13 @@ export default function Feil() {
setTittel(e.target.value)}
/>