From ebfe2b4b14e1c52b76371d02b82e4e195d96de34 Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Fri, 27 Oct 2023 11:57:04 +0200 Subject: [PATCH] fix: [DHIS2-15879] Unable to schedule event with note (#3421) --- .../EnrollmentAddEventPageForm.feature | 8 +++++- .../EnrollmentAddEventPageForm/index.js | 28 ++++++++++++++++++- .../hooks/useCommentDetails.js | 4 +-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm.feature b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm.feature index f1c0da9caf..966cd9083f 100644 --- a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm.feature +++ b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm.feature @@ -48,7 +48,7 @@ Feature: User interacts with the Enrollment New Event Workspace Scenario: User should be asked to create new event after completing a stage and choose to cancel Given you open the main page with Ngelehun and Malaria focus investigation context - And you opt in to use the new enrollment Dashboard for Malaria focus investigation + And you opt in to use the new enrollment Dashboard for Malaria focus investigation Then you land on the enrollment new event page by having typed #/enrollmentEventNew?enrollmentId=zRfAPUpjoG3&orgUnitId=DiszpKrYNg8&programId=M3xtLkYBlKI&stageId=CWaAcQYKVpq&teiId=S3JjTA4QMNe Then you see the following Enrollment: New Event And you see the widget header Foci investigation & classification @@ -72,3 +72,9 @@ Feature: User interacts with the Enrollment New Event Workspace When you choose option Yes, create new event in the modal Then you will be navigate to page #/enrollmentEventNew?enrollmentId=zRfAPUpjoG3&orgUnitId=DiszpKrYNg8&programId=M3xtLkYBlKI&teiId=S3JjTA4QMNe + Scenario: User is able to schedule an event with a note + Given you land on the enrollment new event page by having typed /#/enrollmentEventNew?enrollmentId=qcFFRp7DpcX&orgUnitId=DiszpKrYNg8&programId=WSGAb5XwJ3Y&stageId=edqlbukwRfQ&teiId=erqa3phUfpI + And you see the following Enrollment: New Event + And you select the schedule tab + When you add a comment to the event + And the events saves successfully diff --git a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js index 9791f3f190..d4b2f403a9 100644 --- a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js +++ b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js @@ -1,4 +1,4 @@ -import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'; +import { Given, When, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor'; import '../sharedSteps'; const showAllEventsInProgramStage = () => { @@ -30,6 +30,32 @@ Given(/^you land on the enrollment new event page by having typed (.*)$/, (url) cy.visit(url); }); +Given('you select the schedule tab', () => { + cy.get('[data-test="new-event-schedule-tab"]') + .click(); +}); + +When('you add a comment to the event', () => { + cy.get('[data-test="comment-textfield"]') + .type('This is a comment') + .blur(); + + cy.get('[data-test="add-comment-btn"]') + .click(); +}); + +And('the events saves successfully', () => { + cy.intercept('POST', '**/tracker?async=false').as('postEvent'); + + cy.get('[data-test="dhis2-uicore-button"]') + .contains('Schedule') + .click(); + + cy.wait('@postEvent') + .its('response.statusCode') + .should('eq', 200); +}); + When(/^you click the create new button number (.*)$/, (eq) => { cy.get('[data-test="create-new-button"]') .eq(eq) diff --git a/src/core_modules/capture-core/components/WidgetEventSchedule/hooks/useCommentDetails.js b/src/core_modules/capture-core/components/WidgetEventSchedule/hooks/useCommentDetails.js index 21394c5a8d..4544faf9af 100644 --- a/src/core_modules/capture-core/components/WidgetEventSchedule/hooks/useCommentDetails.js +++ b/src/core_modules/capture-core/components/WidgetEventSchedule/hooks/useCommentDetails.js @@ -1,7 +1,7 @@ // @flow import { useMemo } from 'react'; import { useDataQuery } from '@dhis2/app-runtime'; -import uuid from 'd2-utilizr/lib/uuid'; +import { generateUID } from '../../../utils/uid/generateUID'; export const useCommentDetails = () => { const { data, error, loading } = useDataQuery(useMemo(() => ({ @@ -18,6 +18,6 @@ export const useCommentDetails = () => { return { error, currentUser: !loading && data.currentUser, - noteId: uuid(), + noteId: generateUID(), }; };