Skip to content

Commit

Permalink
fix: bump up faker (#1191)
Browse files Browse the repository at this point in the history
* fix: update import from faker

* chore: update faker to 9.3.0

* chore: add e2e dir in tsconfig

* chore: udpate import from faker in data-generator

* fix: use faker.string.numeric

* fix: use faker.location instead of faker.address

* fix: update faker api calls

* fix: import node from node-fetch

* fix: type errors in e2e
  • Loading branch information
jamil314 authored Dec 20, 2024
1 parent 1efe318 commit c3f008f
Show file tree
Hide file tree
Showing 48 changed files with 684 additions and 664 deletions.
1 change: 1 addition & 0 deletions e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from './constants'
import { format, parseISO } from 'date-fns'
import { isArray, random } from 'lodash'
import fetch from 'node-fetch'

export async function login(page: Page, username: string, password: string) {
const token = await getToken(username, password)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getToken,
login
} from '../../helpers'
import faker from '@faker-js/faker'
import { faker } from '@faker-js/faker'
import { createDeclaration } from '../birth/helpers'
import TEST_DATA_1 from '../birth/data/1-both-mother-and-father.json'
import { CREDENTIALS } from '../../constants'
Expand All @@ -25,8 +25,8 @@ test.describe
const token = await getToken('k.mweene', 'test')
const res = await createDeclaration(token, {
child: {
firstNames: faker.name.firstName(),
familyName: faker.name.firstName(),
firstNames: faker.person.firstName(),
familyName: faker.person.firstName(),
gender: TEST_DATA_1['Child details'].Sex.toLowerCase() as 'male'
},
informant: {
Expand All @@ -40,12 +40,12 @@ test.describe
].toUpperCase() as 'PHYSICIAN'
},
mother: {
firstNames: faker.name.firstName(),
familyName: faker.name.firstName()
firstNames: faker.person.firstName(),
familyName: faker.person.firstName()
},
father: {
firstNames: faker.name.firstName(),
familyName: faker.name.firstName()
firstNames: faker.person.firstName(),
familyName: faker.person.firstName()
}
})
expect(res).toStrictEqual({
Expand Down
14 changes: 7 additions & 7 deletions e2e/testcases/birth/1-birth-event-declaration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createPIN, getToken, login } from '../../helpers'
import { createDeclaration } from './helpers'

import TEST_DATA_1 from './data/1-both-mother-and-father.json'
import faker from '@faker-js/faker'
import { faker } from '@faker-js/faker'
import { CREDENTIALS } from '../../constants'

test.describe('1. Birth event declaration', () => {
Expand Down Expand Up @@ -569,8 +569,8 @@ test.describe('1. Birth event declaration', () => {
const token = await getToken('k.mweene', 'test')
const res = await createDeclaration(token, {
child: {
firstNames: faker.name.firstName(),
familyName: faker.name.firstName(),
firstNames: faker.person.firstName(),
familyName: faker.person.firstName(),
gender: TEST_DATA_1['Child details'].Sex.toLowerCase() as 'male'
},
informant: {
Expand All @@ -584,12 +584,12 @@ test.describe('1. Birth event declaration', () => {
].toUpperCase() as 'PHYSICIAN'
},
mother: {
firstNames: faker.name.firstName(),
familyName: faker.name.firstName()
firstNames: faker.person.firstName(),
familyName: faker.person.firstName()
},
father: {
firstNames: faker.name.firstName(),
familyName: faker.name.firstName()
firstNames: faker.person.firstName(),
familyName: faker.person.firstName()
}
})
expect(res).toStrictEqual({
Expand Down
36 changes: 18 additions & 18 deletions e2e/testcases/birth/8-validate-declaration-review-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import {
getAction,
assignRecord
} from '../../helpers'
import faker from '@faker-js/faker'
import { faker } from '@faker-js/faker'
import { CREDENTIALS } from '../../constants'

test.describe.serial('8. Validate declaration review page', () => {
let page: Page
const declaration = {
child: {
name: {
firstNames: faker.name.firstName('male'),
familyName: faker.name.lastName('male')
firstNames: faker.person.firstName('male'),
familyName: faker.person.lastName('male')
},
gender: 'Male',
birthDate: getRandomDate(0, 200)
Expand All @@ -35,13 +35,13 @@ test.describe.serial('8. Validate declaration review page', () => {
informantEmail: faker.internet.email(),
mother: {
name: {
firstNames: faker.name.firstName('female'),
familyName: faker.name.lastName('female')
firstNames: faker.person.firstName('female'),
familyName: faker.person.lastName('female')
},
birthDate: getRandomDate(20, 200),
nationality: 'Farajaland',
identifier: {
id: faker.random.numeric(10),
id: faker.string.numeric(10),
type: 'National ID'
},
address: {
Expand All @@ -52,13 +52,13 @@ test.describe.serial('8. Validate declaration review page', () => {
},
father: {
name: {
firstNames: faker.name.firstName('male'),
familyName: faker.name.lastName('male')
firstNames: faker.person.firstName('male'),
familyName: faker.person.lastName('male')
},
birthDate: getRandomDate(22, 200),
nationality: 'Farajaland',
identifier: {
id: faker.random.numeric(10),
id: faker.string.numeric(10),
type: 'National ID'
},
address: 'Same as mother'
Expand Down Expand Up @@ -422,8 +422,8 @@ test.describe.serial('8. Validate declaration review page', () => {
await page.locator('#child-content #Full').getByText('Change').click()

declaration.child.name = {
firstNames: faker.name.firstName('male'),
familyName: faker.name.lastName('male')
firstNames: faker.person.firstName('male'),
familyName: faker.person.lastName('male')
}
await page
.locator('#firstNamesEng')
Expand Down Expand Up @@ -612,8 +612,8 @@ test.describe.serial('8. Validate declaration review page', () => {
test("8.1.2.10 Change mother's name", async () => {
await page.locator('#mother-content #Full').getByText('Change').click()

declaration.mother.name.firstNames = faker.name.firstName('female')
declaration.mother.name.familyName = faker.name.lastName('female')
declaration.mother.name.firstNames = faker.person.firstName('female')
declaration.mother.name.familyName = faker.person.lastName('female')
await page
.locator('#firstNamesEng')
.fill(declaration.mother.name.firstNames)
Expand Down Expand Up @@ -695,7 +695,7 @@ test.describe.serial('8. Validate declaration review page', () => {

test("8.1.2.14 Change mother's ID", async () => {
await page.locator('#mother-content #ID').getByText('Change').click()
declaration.mother.identifier.id = faker.random.numeric(10)
declaration.mother.identifier.id = faker.string.numeric(10)
await page
.locator('#motherPassport')
.fill(declaration.mother.identifier.id)
Expand Down Expand Up @@ -738,8 +738,8 @@ test.describe.serial('8. Validate declaration review page', () => {
test("8.1.2.16 Change father's name", async () => {
await page.locator('#father-content #Full').getByText('Change').click()

declaration.father.name.firstNames = faker.name.firstName('male')
declaration.father.name.familyName = faker.name.lastName('male')
declaration.father.name.firstNames = faker.person.firstName('male')
declaration.father.name.familyName = faker.person.lastName('male')
await page
.locator('#firstNamesEng')
.fill(declaration.father.name.firstNames)
Expand Down Expand Up @@ -821,7 +821,7 @@ test.describe.serial('8. Validate declaration review page', () => {

test("8.1.2.20 Change father's ID", async () => {
await page.locator('#father-content #ID').getByText('Change').click()
declaration.father.identifier.id = faker.random.numeric(10)
declaration.father.identifier.id = faker.string.numeric(10)
await page
.locator('#fatherPassport')
.fill(declaration.father.identifier.id)
Expand Down Expand Up @@ -1349,7 +1349,7 @@ test.describe.serial('8. Validate declaration review page', () => {
])
})

const newFamilyNameForChild = faker.name.lastName('male')
const newFamilyNameForChild = faker.person.lastName('male')

test("8.3.2.1 Update child's family name", async () => {
await page
Expand Down
16 changes: 8 additions & 8 deletions e2e/testcases/birth/declarations/birth-declaration-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
goToSection,
login
} from '../../../helpers'
import faker from '@faker-js/faker'
import { faker } from '@faker-js/faker'
import { CREDENTIALS } from '../../../constants'

test.describe.serial('1. Birth declaration case - 1', () => {
Expand Down Expand Up @@ -41,19 +41,19 @@ test.describe.serial('1. Birth declaration case - 1', () => {
birthDate: getRandomDate(20, 200),
nationality: 'Farajaland',
identifier: {
id: faker.random.numeric(10),
id: faker.string.numeric(10),
type: 'National ID'
},
address: {
country: 'Farajaland',
province: 'Sulaka',
district: 'Irundu',
urbanOrRural: 'Urban',
town: faker.address.city(),
residentialArea: faker.address.county(),
street: faker.address.streetName(),
number: faker.address.buildingNumber(),
postcodeOrZip: faker.address.zipCode()
town: faker.location.city(),
residentialArea: faker.location.county(),
street: faker.location.street(),
number: faker.location.buildingNumber(),
postcodeOrZip: faker.location.zipCode()
},
maritalStatus: 'Single',
levelOfEducation: 'No schooling'
Expand All @@ -66,7 +66,7 @@ test.describe.serial('1. Birth declaration case - 1', () => {
birthDate: getRandomDate(22, 200),
nationality: 'Gabon',
identifier: {
id: faker.random.numeric(10),
id: faker.string.numeric(10),
type: 'National ID'
},
maritalStatus: 'Single',
Expand Down
4 changes: 2 additions & 2 deletions e2e/testcases/birth/declarations/birth-declaration-10.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
goToSection,
login
} from '../../../helpers'
import faker from '@faker-js/faker'
import { faker } from '@faker-js/faker'
import { CREDENTIALS } from '../../../constants'

test.describe.serial('10. Birth declaration case - 10', () => {
Expand All @@ -18,7 +18,7 @@ test.describe.serial('10. Birth declaration case - 10', () => {
const declaration = {
child: {
name: {
firstNames: faker.name.lastName()
firstNames: faker.person.lastName()
}
},
informantType: 'Father',
Expand Down
40 changes: 20 additions & 20 deletions e2e/testcases/birth/declarations/birth-declaration-2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import {
joinValuesWith,
login
} from '../../../helpers'
import faker from '@faker-js/faker'
import { faker } from '@faker-js/faker'
import { CREDENTIALS } from '../../../constants'

test.describe.serial('2. Birth declaration case - 2', () => {
let page: Page
const declaration = {
child: {
name: {
firstNames: faker.name.firstName('female'),
familyName: faker.name.lastName('female')
firstNames: faker.person.firstName('female'),
familyName: faker.person.lastName('female')
},
gender: 'Female',
birthDate: getRandomDate(0, 200)
Expand All @@ -35,44 +35,44 @@ test.describe.serial('2. Birth declaration case - 2', () => {
province: 'Pualula',
district: 'Funabuli',
urbanOrRural: 'Urban',
town: faker.address.city(),
residentialArea: faker.address.county(),
street: faker.address.streetName(),
number: faker.address.buildingNumber(),
postcodeOrZip: faker.address.zipCode()
town: faker.location.city(),
residentialArea: faker.location.county(),
street: faker.location.street(),
number: faker.location.buildingNumber(),
postcodeOrZip: faker.location.zipCode()
},
informantType: 'Father',
informantEmail: faker.internet.email(),
mother: {
name: {
firstNames: faker.name.firstName('female'),
familyName: faker.name.lastName('female')
firstNames: faker.person.firstName('female'),
familyName: faker.person.lastName('female')
},
age: 21,
nationality: 'Fiji',
identifier: {
id: faker.random.numeric(12),
id: faker.string.numeric(12),
type: 'Passport'
},
address: {
country: 'Farajaland',
province: 'Sulaka',
district: 'Irundu',
urbanOrRural: 'Rural',
village: faker.address.county()
village: faker.location.county()
},
maritalStatus: 'Married',
levelOfEducation: 'Primary'
},
father: {
name: {
firstNames: faker.name.firstName('male'),
familyName: faker.name.lastName('male')
firstNames: faker.person.firstName('male'),
familyName: faker.person.lastName('male')
},
age: 25,
nationality: 'Farajaland',
identifier: {
id: faker.random.numeric(8),
id: faker.string.numeric(8),
type: 'Passport'
},
maritalStatus: 'Married',
Expand All @@ -83,11 +83,11 @@ test.describe.serial('2. Birth declaration case - 2', () => {
province: 'Sulaka',
district: 'Zobwe',
urbanOrRural: 'Urban',
town: faker.address.city(),
residentialArea: faker.address.county(),
street: faker.address.streetName(),
number: faker.address.buildingNumber(),
postcodeOrZip: faker.address.zipCode()
town: faker.location.city(),
residentialArea: faker.location.county(),
street: faker.location.street(),
number: faker.location.buildingNumber(),
postcodeOrZip: faker.location.zipCode()
}
}
}
Expand Down
Loading

0 comments on commit c3f008f

Please sign in to comment.