Skip to content

Commit

Permalink
fix: increase randomness of names
Browse files Browse the repository at this point in the history
  • Loading branch information
jamil314 committed Sep 18, 2024
1 parent 6719a92 commit 10ee128
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
13 changes: 13 additions & 0 deletions e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,16 @@ export const expectOutboxToBeEmpty = async (page: Page) => {
timeout: SAFE_OUTBOX_TIMEOUT_MS
})
}

// This suffix increases randomness of a name
export const generateRandomSuffix = () => {
const vowels = 'aeiou'
const consonants = 'bcdfghjklmnpqrstvwxyz'

const randomVowel = vowels.charAt(Math.floor(Math.random() * vowels.length))
const randomConsonant = consonants.charAt(
Math.floor(Math.random() * consonants.length)
)

return randomConsonant + randomVowel
}
5 changes: 3 additions & 2 deletions e2e/testcases/birth/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
REGISTER_BIRTH_DECLARATION
} from './queries'
import { random } from 'lodash'
import { generateRandomSuffix } from '../../helpers'

export type BirthDetails = {
informant: {
Expand Down Expand Up @@ -99,8 +100,8 @@ export async function createDeclaration(token: string, details: BirthDetails) {
name: [
{
use: 'en',
firstNames: details.child.firstNames,
familyName: details.child.familyName
firstNames: details.child.firstNames + generateRandomSuffix(),
familyName: details.child.familyName + generateRandomSuffix()
}
],
gender: details.child.gender,
Expand Down
10 changes: 7 additions & 3 deletions e2e/testcases/death/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import faker from '@faker-js/faker'
import { readFileSync } from 'fs'
import uuid from 'uuid'
import { join } from 'path'
import { formatDateObjectTo_yyyyMMdd, getRandomDate } from '../../helpers'
import {
formatDateObjectTo_yyyyMMdd,
generateRandomSuffix,
getRandomDate
} from '../../helpers'
import {
CREATE_DEATH_REGISTRATION,
GET_DEATH_REGISTRATION_FOR_REVIEW
Expand All @@ -31,8 +35,8 @@ export type DeathDeclarationInput = {
const declaration = {
deceased: {
name: {
firstNames: faker.name.firstName('male'),
familyName: faker.name.lastName('male')
firstNames: faker.name.firstName('male') + generateRandomSuffix(),
familyName: faker.name.lastName('male') + generateRandomSuffix()
},
gender: 'male',
age: random(20, 100),
Expand Down

0 comments on commit 10ee128

Please sign in to comment.