Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress image change #961

Merged
merged 20 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions appointment-frontend/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
env: {
'cypress-plugin-snapshots': {
imageConfig: {
threshold: 0,
threshold: 10,
thresholdType: 'percent',
},
screenshotConfig: {
Expand All @@ -15,7 +15,7 @@ export default defineConfig({
disableTimersAndAnimations: true,
log: false,
scale: false,
timeout: 30000,
timeout: 50000,
},
},
},
Expand Down
10 changes: 8 additions & 2 deletions appointment-frontend/cypress/e2e/image_snapshot/step3.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import { API_PREFIX } from '../../support/e2e'

describe('step 3', () => {
beforeEach(() => {

cy.viewport(1000, 920)

// Intercept API calls to provide testing data.

cy.fixture('offices').then((json) => {
Expand Down Expand Up @@ -61,7 +64,7 @@ describe('step 3', () => {
.type('Legal Change of Name{downarrow}{enter}')

// The API fixtures are based on a certain date, so act like it's that day.
cy.clock(new Date('2022-01-17').getTime())
cy.clock(new Date('2022-01-16').getTime())

cy.get(SELECTOR_STEP_2_BUTTON_NEXT)
.click()
Expand All @@ -80,6 +83,9 @@ describe('step 3', () => {
})

it('page loaded', () => {
cy.matchImageSnapshot()
cy.matchImageSnapshot({
failureThreshold: 0.01,
failureThresholdType: 'percent',
})
})
})
18 changes: 12 additions & 6 deletions appointment-frontend/cypress/e2e/image_snapshot/step4.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ import {
SELECTOR_STEP_2_COMBOBOX_SERVICE,
SELECTOR_STEP_3_BUTTON_TIMESLOT,
SELECTOR_STEP_4_IMAGE_BCEID_LOGIN,
SELECTOR_STEP_4_IMAGE_BCSC
SELECTOR_STEP_4_IMAGE_BCSC,
SELECTOR_STEP_4_BUTTON_BCEID
} from '../../support/selectors'

import { API_PREFIX } from '../../support/e2e'

describe('step 4', () => {
beforeEach(() => {
// Intercept API calls to provide testing data.
cy.viewport(1000, 920)

cy.fixture('appointments/draft').then((json) => {
cy.intercept('POST', API_PREFIX + 'appointments/draft', json)
Expand Down Expand Up @@ -66,27 +68,31 @@ describe('step 4', () => {
.type('Legal Change of Name{downarrow}{enter}')

// The API fixtures are based on a certain date, so act like it's that day.
cy.clock(new Date('2022-01-17').getTime())
cy.clock(new Date('2022-01-16').getTime())

cy.get(SELECTOR_STEP_2_BUTTON_NEXT)
.click()

cy.get(SELECTOR_STEP_3_BUTTON_TIMESLOT)
.click()
.first().click()

// Get something from the next page, so that we know page load is complete.
cy.get(SELECTOR_STEP_4_IMAGE_BCSC)
cy.get(SELECTOR_STEP_4_BUTTON_BCEID).should('be.visible')

// Flake: https://github.com/cypress-io/cypress/issues/2681
cy.workaroundPositionFixed(SELECTOR_FEEDBACK)

// Flake: v-img has a default fade transition. Wait for it to complete.
cy.workaroundImageFade(SELECTOR_HEADER_IMAGE_BCGOV)
// cy.workaroundImageFade(SELECTOR_HEADER_IMAGE_BCGOV)
cy.workaroundImageFade(SELECTOR_STEP_4_IMAGE_BCEID_LOGIN)

cy.workaroundImageFade(SELECTOR_STEP_4_IMAGE_BCSC)
})

it('page loaded', () => {
cy.matchImageSnapshot()
cy.matchImageSnapshot({
failureThreshold: 0.01,
failureThresholdType: 'percent',
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('step 5', () => {
.type('Legal Change of Name{downarrow}{enter}')

// The API fixtures are based on a certain date, so act like it's that day.
cy.clock(new Date('2022-01-17').getTime())
cy.clock(new Date('2022-01-16').getTime())

cy.get(SELECTOR_STEP_2_BUTTON_NEXT)
.click()
Expand Down Expand Up @@ -129,6 +129,8 @@ describe('step 5', () => {
cy.get(SELECTOR_STEP_5_BUTTON_CONFIRM)
.should('be.visible')

cy.screenshot('SELECTOR_STEP_5_BUTTON_CONFIRM');

cy.matchImageSnapshot()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"01/17/2022": [],

"01/17/2022": [
{
"start_time": "09:00",
"end_time": "09:20",
"no_of_slots": 1
}
],
"01/18/2022": [],
"01/19/2022": [
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion appointment-frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

import { addMatchImageSnapshotCommand } from '@simonsmith/cypress-image-snapshot/command'

addMatchImageSnapshotCommand()
addMatchImageSnapshotCommand({
failureThreshold: 0.2,
})

declare global {
namespace Cypress {
Expand Down
3 changes: 3 additions & 0 deletions appointment-frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"scripthost"
]
},
"types":[
"@simonsmith/cypress-image-snapshot/types"
],
"include": [
"src/**/*.ts",
"src/**/*.tsx",
Expand Down
Loading