Skip to content

Commit

Permalink
Merge pull request #1974 from ministryofjustice/no-ticket/fix-cypress…
Browse files Browse the repository at this point in the history
…-test

Specify timezone in Cypress test appointmentTimes
  • Loading branch information
marcocolluramoj authored Mar 29, 2023
2 parents 0d9b6a2 + 68f7e15 commit fc1fc2a
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 24 deletions.
2 changes: 1 addition & 1 deletion integration_tests/integration/referral.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import moment from 'moment'
import moment from 'moment-timezone'
import draftReferralFactory from '../../testutils/factories/draftReferral'
import sentReferralFactory from '../../testutils/factories/sentReferral'
import serviceCategoryFactory from '../../testutils/factories/serviceCategory'
Expand Down
14 changes: 7 additions & 7 deletions integration_tests/integration/serviceProviderReferrals.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import moment from 'moment'
import moment from 'moment-timezone'
import sentReferralFactory from '../../testutils/factories/sentReferral'
import sentReferralForSummaries from '../../testutils/factories/sentReferralSummaries'
import serviceCategoryFactory from '../../testutils/factories/serviceCategory'
Expand Down Expand Up @@ -912,7 +912,7 @@ describe('Service provider referrals dashboard', () => {
describe('with valid inputs and an appointment in the future', () => {
describe('when booking for an In-Person Meeting - Other Location', () => {
it('should present no errors and display scheduled appointment', () => {
const tomorrow = moment('09:02:00', 'HH:mm:ss').add(1, 'days')
const tomorrow = moment.tz('09:02:00', 'HH:mm:ss', 'Europe/London').add(1, 'days')
cy.visit(`/service-provider/action-plan/${actionPlan.id}/sessions/1/edit/start`)
cy.get('#date-day').type(tomorrow.format('D'))
cy.get('#date-month').type(tomorrow.format('M'))
Expand Down Expand Up @@ -984,7 +984,7 @@ describe('Service provider referrals dashboard', () => {

describe('and their chosen date causes a clash of appointments', () => {
it('the user is able to amend their chosen date and re-submit', () => {
const tomorrow = moment('09:02:00', 'HH:mm:ss').add(1, 'days')
const tomorrow = moment.tz('09:02:00', 'HH:mm:ss', 'Europe/London').add(1, 'days')
const rescheduledDate = moment('09:02:00', 'HH:mm:ss').add(2, 'days')
cy.visit(`/service-provider/action-plan/${actionPlan.id}/sessions/1/edit/start`)
cy.get('#date-day').type(tomorrow.format('D'))
Expand Down Expand Up @@ -1070,7 +1070,7 @@ describe('Service provider referrals dashboard', () => {

describe('when booking for an In-Person Meeting - NPS Location', () => {
it('should present no errors and display scheduled appointment', () => {
const tomorrow = moment('09:02:00', 'HH:mm:ss').add(1, 'days')
const tomorrow = moment.tz('09:02:00', 'HH:mm:ss', 'Europe/London').add(1, 'days')
cy.visit(`/service-provider/action-plan/${actionPlan.id}/sessions/1/edit/start`)
cy.get('#date-day').type(tomorrow.format('D'))
cy.get('#date-month').type(tomorrow.format('M'))
Expand Down Expand Up @@ -2201,7 +2201,7 @@ describe('Service provider referrals dashboard', () => {

describe('with appointments in the future', () => {
it('presents a confirmation page and the booking is successful', () => {
const tomorrow = moment('09:02:02', 'HH:mm:ss').add(1, 'days')
const tomorrow = moment.tz('09:02:00', 'HH:mm:ss', 'Europe/London').add(1, 'days')
cy.visit(`/service-provider/referrals/${referral.id}/progress`)
cy.get('#supplier-assessment-status').contains('not scheduled')
cy.contains('Schedule initial assessment').click()
Expand Down Expand Up @@ -2290,7 +2290,7 @@ describe('Service provider referrals dashboard', () => {
})

it('User schedules a supplier assessment appointment, changing their chosen time after it turns out to cause a clash of appointments', () => {
const tomorrow = moment('09:02:02', 'HH:mm:ss').add(1, 'days')
const tomorrow = moment.tz('09:02:00', 'HH:mm:ss', 'Europe/London').add(1, 'days')
const rescheduledDate = moment('16:15:00', 'HH:mm:ss').add(2, 'days')
cy.visit(`/service-provider/referrals/${referral.id}/supplier-assessment/schedule/start`)

Expand Down Expand Up @@ -2361,7 +2361,7 @@ describe('Service provider referrals dashboard', () => {
})

it('User reschedules a supplier assessment appointment', () => {
const tomorrow = moment('09:02:02', 'HH:mm:ss').add(1, 'days')
const tomorrow = moment.tz('09:02:00', 'HH:mm:ss', 'Europe/London').add(1, 'days')
const rescheduledDate = moment('16:15:00', 'HH:mm:ss').add(1, 'days')
const scheduledAppointment = initialAssessmentAppointmentFactory.build({
appointmentTime: tomorrow.format(),
Expand Down
41 changes: 32 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.0",
"mockdate": "^3.0.5",
"moment": "^2.29.4",
"moment-timezone": "^0.5.42",
"nock": "^13.2.9",
"nodemon": "^2.0.20",
"prettier": "^2.8.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import moment from 'moment'
import moment from 'moment-timezone'
import ExpectedReleaseDateForm from './expectedReleaseDateForm'
import TestUtils from '../../../../testutils/testUtils'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import request from 'supertest'
import { Express } from 'express'
import createError from 'http-errors'
import moment from 'moment'
import moment from 'moment-timezone'
import InterventionsService from '../../services/interventionsService'
import ServiceUser from '../../models/serviceUser'
import CommunityApiService from '../../services/communityApiService'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import moment from 'moment'
import moment from 'moment-timezone'
import { ListStyle } from '../../../utils/summaryList'
import ServiceUserDetailsPresenter from './serviceUserDetailsPresenter'
import expandedDeliusServiceUserFactory from '../../../../testutils/factories/expandedDeliusServiceUser'
Expand Down
2 changes: 1 addition & 1 deletion server/services/interventionsService.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pactWith } from 'jest-pact'
import { Matchers } from '@pact-foundation/pact'
import moment from 'moment'
import moment from 'moment-timezone'
import InterventionsService, { UpdateDraftEndOfServiceReportParams } from './interventionsService'
import SentReferral from '../models/sentReferral'
import SentReferralSummaries from '../models/sentReferralSummaries'
Expand Down
2 changes: 1 addition & 1 deletion testutils/factories/draftReferral.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Factory } from 'fishery'
import moment from 'moment'
import moment from 'moment-timezone'
import DraftReferral, { CurrentLocationType } from '../../server/models/draftReferral'
import serviceCategoryFactory from './serviceCategory'
import interventionFactory from './intervention'
Expand Down
2 changes: 1 addition & 1 deletion testutils/factories/sentReferral.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Factory } from 'fishery'
import moment from 'moment'
import moment from 'moment-timezone'
import SentReferral from '../../server/models/sentReferral'
import { CurrentLocationType, ReferralFields } from '../../server/models/draftReferral'
import serviceCategoryFactory from './serviceCategory'
Expand Down

0 comments on commit fc1fc2a

Please sign in to comment.