Skip to content

Commit

Permalink
chore: add cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Oct 26, 2023
1 parent 736b3f2 commit 3dfa0b0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3dfa0b0

Please sign in to comment.