From 3700bb2a9ea985c467dde0e9f5486b4c184c0be7 Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Mon, 19 Aug 2024 09:33:34 +0200 Subject: [PATCH] Fix cy routing --- src/client/cypress/e2e/editor/bulkedit.cy.js | 15 ++++++++++----- src/client/cypress/e2e/editor/completion.cy.js | 4 ++-- .../cypress/e2e/editor/fieldMeasurement.cy.js | 4 ++-- src/client/cypress/e2e/helpers/testHelpers.js | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/client/cypress/e2e/editor/bulkedit.cy.js b/src/client/cypress/e2e/editor/bulkedit.cy.js index bdb983b80..3221b6883 100644 --- a/src/client/cypress/e2e/editor/bulkedit.cy.js +++ b/src/client/cypress/e2e/editor/bulkedit.cy.js @@ -1,4 +1,10 @@ -import { createBorehole, loginAsAdmin, startBoreholeEditing, stopBoreholeEditing } from "../helpers/testHelpers"; +import { + createBorehole, + goToRouteAndAccptTerms, + loginAsAdmin, + startBoreholeEditing, + stopBoreholeEditing, +} from "../helpers/testHelpers"; import adminUser from "../../fixtures/adminUser.json"; import { checkAllVisibleRows, checkRowWithText, showTableAndWaitForData } from "../helpers/dataGridHelpers"; @@ -74,7 +80,6 @@ describe("Test the borehole bulk edit feature.", () => { cy.get('[data-cy="borehole-table"]').within(() => { checkRowWithText("AAA_NINTIC"); checkRowWithText("AAA_LOMONE"); - section; }); cy.contains("button", "Bulk editing").click(); @@ -119,14 +124,14 @@ describe("Test the borehole bulk edit feature.", () => { it("cannot select locked boreholes for bulk edit", () => { createBorehole({ "extended.original_name": "AAA_JUNIORSOUFFLE" }).as("borehole_id"); cy.get("@borehole_id").then(id => { - cy.visit(`/${id}/borehole`); + goToRouteAndAccptTerms(`/${id}/borehole`); startBoreholeEditing(); - cy.visit("/"); + goToRouteAndAccptTerms(`/`); showTableAndWaitForData(); cy.contains(".MuiDataGrid-row", "AAA_JUNIORSOUFFLE") .find('.MuiCheckbox-root input[type="checkbox"]') .should("be.disabled"); - cy.visit(`/${id}/borehole`); + goToRouteAndAccptTerms(`/${id}/borehole`); stopBoreholeEditing(); }); }); diff --git a/src/client/cypress/e2e/editor/completion.cy.js b/src/client/cypress/e2e/editor/completion.cy.js index f499a4d41..484ffb7c2 100644 --- a/src/client/cypress/e2e/editor/completion.cy.js +++ b/src/client/cypress/e2e/editor/completion.cy.js @@ -1,6 +1,7 @@ import { createBorehole, createCompletion, + goToRouteAndAccptTerms, handlePrompt, loginAsAdmin, startBoreholeEditing, @@ -612,8 +613,7 @@ describe("completion crud tests", () => { cy.get("@borehole_id").then(id => { cy.get("@completion1_id").then(completion1Id => { // Preserves hash when reloading - cy.visit(`/${id}/completion/${completion1Id}`); - cy.get('[data-cy="accept-button"]').click(); + goToRouteAndAccptTerms(`/${id}/completion/${completion1Id}`); cy.location().should(location => { expect(location.hash).to.eq("#casing"); }); diff --git a/src/client/cypress/e2e/editor/fieldMeasurement.cy.js b/src/client/cypress/e2e/editor/fieldMeasurement.cy.js index f3d4b2e39..b15f5b884 100644 --- a/src/client/cypress/e2e/editor/fieldMeasurement.cy.js +++ b/src/client/cypress/e2e/editor/fieldMeasurement.cy.js @@ -3,6 +3,7 @@ import { createCasing, createCompletion, createFieldMeasurement, + goToRouteAndAccptTerms, handlePrompt, loginAsAdmin, selectLanguage, @@ -90,8 +91,7 @@ describe("Tests for the field measurement editor.", () => { cy.get("@borehole_id").then(id => { createFieldMeasurement(id, "2012-11-14T12:06Z", 15203157, 15203209, 15203219, 10, null, 0, 10); createFieldMeasurement(id, "2012-11-14T12:07Z", 15203157, 15203209, 15203219, 10, null, 0, 12); - cy.visit(`/${id}/hydrogeology/fieldmeasurement`); - cy.get('[data-cy="accept-button"]').click(); + goToRouteAndAccptTerms(`/${id}/hydrogeology/fieldmeasurement`); startBoreholeEditing(); cy.get('[data-cy="fieldMeasurement-card.0"] [data-cy="todepth-formDisplay"]').contains("10"); diff --git a/src/client/cypress/e2e/helpers/testHelpers.js b/src/client/cypress/e2e/helpers/testHelpers.js index 9871655fe..0aced31f9 100644 --- a/src/client/cypress/e2e/helpers/testHelpers.js +++ b/src/client/cypress/e2e/helpers/testHelpers.js @@ -136,7 +136,7 @@ export const login = user => { * Login into the application as admin. */ -const goToRouteAndAccptTerms = route => { +export const goToRouteAndAccptTerms = route => { cy.visit(route); cy.get('[data-cy="accept-button"]').click(); };