From 6782c7007fde1e0635865762c37a5a6ec055c389 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Mon, 16 Dec 2024 10:29:00 +0100 Subject: [PATCH] chore: fix cypress test --- .../EnrollmentEditEventPageForm.feature | 1 + .../EnrollmentEditEventPageForm.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.feature b/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.feature index 31ab0f99c8..b0eb978b21 100644 --- a/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.feature +++ b/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.feature @@ -77,6 +77,7 @@ And the user see the following text: 11 When the user clicks on the cancel button Then the user is navigated to the enrollment dashboard +@with-restore-event-schedule-date Scenario: User can update schedule date for a scheduled event Given you land on the enrollment event page with selected Person by having typed /#/enrollmentEventEdit?eventId=RIrfCcEP8Uu&orgUnitId=DiszpKrYNg8 Then the view enrollment event form is in edit mode diff --git a/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js b/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js index 3f42786176..46c7045b98 100644 --- a/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js +++ b/cypress/e2e/EnrollmentEditEventPage/EnrollmentEditEventPageForm/EnrollmentEditEventPageForm.js @@ -1,6 +1,18 @@ -import { defineStep as And, Given, Then, When } from '@badeball/cypress-cucumber-preprocessor'; +import { defineStep as And, Given, Then, When, Before } from '@badeball/cypress-cucumber-preprocessor'; import { getCurrentYear } from '../../../support/date'; +Before({ tags: '@with-restore-event-schedule-date' }, () => { + cy.buildApiUrl('tracker', 'events/RIrfCcEP8Uu') + .then(url => cy.request(url)) + .then((apiResponse) => { + const event = apiResponse.body; + const eventToUpdate = { ...event, scheduledAt: `${getCurrentYear() - 15}-01-07` }; + return cy + .buildApiUrl('tracker?async=false&importStrategy=UPDATE') + .then(eventUrl => cy.request('POST', eventUrl, { events: [eventToUpdate] })); + }); +}); + const changeEnrollmentAndEventsStatus = () => ( cy.buildApiUrl( 'tracker',