Skip to content

Commit

Permalink
update Cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
rikukissa committed Nov 13, 2023
1 parent 37051b2 commit dc0ea0a
Show file tree
Hide file tree
Showing 16 changed files with 214 additions and 77 deletions.
23 changes: 23 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { defineConfig } from 'cypress'

export default defineConfig({
chromeWebSecurity: false,
video: false,
projectId: 'j9bgv5',
viewportWidth: 1024,
viewportHeight: 768,
defaultCommandTimeout: 60000,
videoCompression: 0,
retries: {
runMode: 5,
openMode: 2,
},
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
},
})
13 changes: 0 additions & 13 deletions cypress.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,40 @@

import faker from '@faker-js/faker'

function refreshTrackingIdSearchUntilNameIsFound(
trackingId: string,
firstName: string,
lastName: string
) {
cy.get('#searchText').clear()
cy.get('#searchText').type('E2E REFRESHING')
cy.get('#searchText').type('{enter}')
cy.get('#searchText').clear()
cy.get('#searchText').type(trackingId)
cy.get('#searchText').type('{enter}')

cy.get('#row_0')
.invoke('text')
.then((text) => {
if (!text.includes(`${firstName} ${lastName}`)) {
cy.wait(1000)
refreshTrackingIdSearchUntilNameIsFound(trackingId, firstName, lastName)
}
})
}

context('Correct Record Integration Test', () => {
beforeEach(() => {
indexedDB.deleteDatabase('OpenCRVS')
})

it("declaration can be found with child's name", () => {
let firstName = faker.name.firstName()
let familyName = faker.name.lastName()
const originalFirstName = faker.name.firstName()
const originalLastName = faker.name.lastName()

cy.createBirthRegistrationAs('registrar', {
firstName,
familyName
firstName: originalFirstName,
familyName: originalLastName
})

cy.login('registrar')
Expand All @@ -42,27 +64,27 @@ context('Correct Record Integration Test', () => {
.click()
cy.get('#confirm_form').click()
cy.get('#btn_change_child_familyNameEng').click()
cy.get('#firstNamesEng').clear().type('Jonas')
cy.get('#familyNameEng').clear().type('Kahnwald')
firstName = 'Jonas'
familyName = 'Kahnwald'
const newFirstName = faker.name.firstName()
const newLastName = faker.name.lastName()
cy.get('#firstNamesEng').clear().type(newFirstName)
cy.get('#familyNameEng').clear().type(newLastName)
cy.get('#back-to-review-button').click()
cy.get('#continue_button').click()
cy.get('#supportDocumentRequiredForCorrection_false').click()
cy.get('#confirm_form').click()
// we need to figure out a way to remove these waits
cy.wait(5000)
cy.get('#type_CLERICAL_ERROR').click()
cy.get('#type_CLERICAL_ERROR', { timeout: 10000 }).click()
cy.get('#confirm_form').click()
cy.wait(5000)
cy.get('#correctionFees_NOT_REQUIRED').click()
cy.get('#correctionFees_NOT_REQUIRED', { timeout: 10000 }).click()
cy.get('#make_correction').click()
cy.wait(10000)
cy.get('#searchType').click()

cy.get('#searchType', { timeout: 10000 }).click()
cy.get('#tracking-id').click()
cy.get('#searchText').type(trackingId)
cy.get('#searchText').type('{enter}')
cy.get(`:contains("${firstName} ${familyName}")`).should('be.visible')

refreshTrackingIdSearchUntilNameIsFound(
trackingId,
newFirstName,
newLastName
)
})
})
})
File renamed without changes.
5 changes: 5 additions & 0 deletions cypress/e2e/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cypress/fixtures/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"country-data": "^0.0.31",
"cross-env": "^6.0.3",
"csv2json": "^1.4.2",
"cypress": "9.6.1",
"cypress": "13.5.0",
"date-fns": "^2.28.0",
"esbuild": "^0.18.9",
"google-libphonenumber": "^3.2.32",
Expand Down
Loading

0 comments on commit dc0ea0a

Please sign in to comment.