Skip to content

Commit

Permalink
Fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
vasharma05 committed Feb 14, 2025
1 parent 2f5330f commit 6b4a275
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions e2e/specs/appointments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { type Visit } from '@openmrs/esm-framework';
import { type Patient } from '../types';
import { test } from '../core';
import { AppointmentsPage } from '../pages';
import dayjs from 'dayjs';

let patient: Patient;
let visit: Visit;
Expand Down Expand Up @@ -38,9 +39,14 @@ test('Add, edit and cancel an appointment', async ({ page, api }) => {
});

await test.step('And I set date for tomorrow', async () => {
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
await page.getByLabel(/^Date$/i).fill(tomorrow.toLocaleDateString('en-GB'));
const tomorrow = dayjs().add(1, 'day');
const dateInput = page.getByTestId('datePickerInput');
const dateDayInput = dateInput.getByRole('spinbutton', { name: /day/i });
const dateMonthInput = dateInput.getByRole('spinbutton', { name: /month/i });
const dateYearInput = dateInput.getByRole('spinbutton', { name: /year/i });
await dateDayInput.fill(tomorrow.format('DD'));
await dateMonthInput.fill(tomorrow.format('MM'));
await dateYearInput.fill(tomorrow.format('YYYY'));
});

await test.step('And I set the “Duration” to 60', async () => {
Expand Down Expand Up @@ -78,17 +84,28 @@ test('Add, edit and cancel an appointment', async ({ page, api }) => {
});

await test.step('And I change the date to Today', async () => {
const today = new Date();
today.setDate(today.getDate());
await page.getByLabel(/^Date$/i).fill(today.toLocaleDateString('en-GB'));
const today = dayjs();
const dateInput = page.getByTestId('datePickerInput');
const dateDayInput = dateInput.getByRole('spinbutton', { name: /day/i });
const dateMonthInput = dateInput.getByRole('spinbutton', { name: /month/i });
const dateYearInput = dateInput.getByRole('spinbutton', { name: /year/i });
await dateDayInput.fill(today.format('DD'));
await dateMonthInput.fill(today.format('MM'));
await dateYearInput.fill(today.format('YYYY'));
});

await test.step('And I set the “Duration” of the appointment”', async () => {
await page.getByLabel('Duration (minutes)').fill('80');
});

await test.step('I set the Date appointment issued', async () => {
await page.getByLabel('Date appointment issued').fill('20/08/2024');
const appointmentIssuedDateInput = page.getByTestId('dateAppointmentScheduledPickerInput');
const appointmentIssuedDateDayInput = appointmentIssuedDateInput.getByRole('spinbutton', { name: /day/i });
const appointmentIssuedDateMonthInput = appointmentIssuedDateInput.getByRole('spinbutton', { name: /month/i });
const appointmentIssuedDateYearInput = appointmentIssuedDateInput.getByRole('spinbutton', { name: /year/i });
await appointmentIssuedDateDayInput.fill('20');
await appointmentIssuedDateMonthInput.fill('08');
await appointmentIssuedDateYearInput.fill('2024');
});
await test.step('And I change the note', async () => {
await page
Expand Down

0 comments on commit 6b4a275

Please # to comment.