Skip to content

Commit

Permalink
refactor: test files to match new pattern names and labels TCKT-464
Browse files Browse the repository at this point in the history
  • Loading branch information
kalasgarov committed Feb 26, 2025
1 parent 2433592 commit 98fc973
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions e2e/src/create.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const addQuestions = async (page: Page) => {
await menuButton.click();
await page.getByRole('button', { name: 'Short Answer' }).click();
await menuButton.click();
await page.getByRole('button', { name: 'Radio Buttons' }).click();
await page.getByRole('button', { name: 'Multiple choice' }).click();
}

test('Create form from scratch', async ({ page }) => {
Expand Down Expand Up @@ -41,7 +41,7 @@ test('Add questions', async ({ page }) => {
// Create locators for both elements
const fields = page.locator('.usa-label');
const element1 = fields.filter({ hasText: 'Field label' });
const element2 = fields.filter({ hasText: 'Radio group label' });
const element2 = fields.filter({ hasText: 'Multiple choice question label' });
expect(element1.first()).toBeTruthy();
expect(element2.first()).toBeTruthy();

Expand Down
26 changes: 13 additions & 13 deletions packages/forms/src/builder/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ describe('form builder', () => {
type: 'fieldset',
id: 'fieldset-1',
data: {
legend: 'Fieldset pattern description',
legend: 'Question set pattern description',
patterns: ['element-2'],
},
},
'radio-group-1': {
type: 'radio-group',
id: 'radio-group-1',
data: {
label: 'Radio group label',
label: 'Multiple choice question label',
options: [
{ id: 'option-1', label: 'Option 1' },
{ id: 'option-2', label: 'Option 2' },
Expand Down Expand Up @@ -373,15 +373,15 @@ describe('form builder', () => {
type: 'fieldset',
id: 'fieldset-1',
data: {
legend: 'Fieldset pattern description',
legend: 'Question set pattern description',
patterns: ['element-2'],
},
},
'radio-group-1': {
type: 'radio-group',
id: 'radio-group-1',
data: {
label: 'Radio group label',
label: 'Multiple choice question label',
options: [
{ id: 'option-1', label: 'Option 1' },
{ id: 'option-2', label: 'Option 2' },
Expand Down Expand Up @@ -456,15 +456,15 @@ describe('form builder', () => {
type: 'fieldset',
id: 'fieldset-1',
data: {
legend: 'Fieldset pattern description',
legend: 'Question set pattern description',
patterns: ['element-2'],
},
},
'radio-group-1': {
type: 'radio-group',
id: 'radio-group-1',
data: {
label: 'Radio group label',
label: 'Multiple choice question label',
options: [
{ id: 'option-1', label: 'Option 1' },
{ id: 'option-2', label: 'Option 2' },
Expand All @@ -476,7 +476,7 @@ describe('form builder', () => {
id: newPattern.id,
data: {
legend: expect.stringMatching(
/^\(\s*Copy\s+\d{1,2}\/\d{1,2}\/\d{4},\s+\d{1,2}:\d{2}:\d{2}\s+[AP]M\)\s*Fieldset pattern description/
/^\(\s*Copy\s+\d{1,2}\/\d{1,2}\/\d{4},\s+\d{1,2}:\d{2}:\d{2}\s+[AP]M\)\s*Question set pattern description/
),
patterns: ['element-2'],
},
Expand All @@ -486,7 +486,7 @@ describe('form builder', () => {
});
});

it('copy radio group pattern', () => {
it('copy multiple choice pattern', () => {
const initial = createTestBlueprintMultipleFieldsets();
const builder = new BlueprintBuilder(defaultFormConfig, initial);
const parentPattern = getPattern<PagePattern>(initial, 'page-1');
Expand Down Expand Up @@ -535,15 +535,15 @@ describe('form builder', () => {
type: 'fieldset',
id: 'fieldset-1',
data: {
legend: 'Fieldset pattern description',
legend: 'Question set pattern description',
patterns: ['element-2'],
},
},
'radio-group-1': {
type: 'radio-group',
id: 'radio-group-1',
data: {
label: 'Radio group label',
label: 'Multiple choice question label',
options: [
{ id: 'option-1', label: 'Option 1' },
{ id: 'option-2', label: 'Option 2' },
Expand All @@ -555,7 +555,7 @@ describe('form builder', () => {
id: newPattern.id,
data: {
label: expect.stringMatching(
/^\(\s*Copy\s+\d{1,2}\/\d{1,2}\/\d{4},\s+\d{1,2}:\d{2}:\d{2}\s+[AP]M\)\s*Radio group label/
/^\(\s*Copy\s+\d{1,2}\/\d{1,2}\/\d{4},\s+\d{1,2}:\d{2}:\d{2}\s+[AP]M\)\s*Multiple choice question label/
),
options: [
{ id: 'option-1', label: 'Option 1' },
Expand Down Expand Up @@ -767,15 +767,15 @@ export const createTestBlueprintMultipleFieldsets = () => {
type: 'fieldset',
id: 'fieldset-1',
data: {
legend: 'Fieldset pattern description',
legend: 'Question set pattern description',
patterns: ['element-2'],
},
} satisfies FieldsetPattern,
{
type: 'radio-group',
id: 'radio-group-1',
data: {
label: 'Radio group label',
label: 'Multiple choice question label',
options: [
{ id: 'option-1', label: 'Option 1' },
{ id: 'option-2', label: 'Option 2' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('DateOfBirthPattern tests', () => {
type: 'date-of-birth',
id: 'test',
data: {
label: 'Test Date of Birth',
label: 'Test Date of birth',
required: true,
hint: 'Enter your date of birth',
},
Expand All @@ -67,7 +67,7 @@ describe('DateOfBirthPattern tests', () => {
type: 'date-of-birth',
id: 'test',
data: {
label: 'Test Date of Birth',
label: 'Test Date of birth',
required: true,
hint: 'Enter your date of birth',
},
Expand All @@ -87,7 +87,7 @@ describe('DateOfBirthPattern tests', () => {

it('should parse config data correctly', () => {
const obj = {
label: 'Test Date of Birth',
label: 'Test Date of birth',
required: true,
hint: 'Enter your date of birth',
};
Expand All @@ -97,7 +97,7 @@ describe('DateOfBirthPattern tests', () => {
}
const result = dateOfBirthConfig.parseConfigData(obj);
if (result.success) {
expect(result.data.label).toBe('Test Date of Birth');
expect(result.data.label).toBe('Test Date of birth');
expect(result.data.required).toBe(true);
expect(result.data.hint).toBe('Enter your date of birth');
} else {
Expand Down
12 changes: 6 additions & 6 deletions packages/forms/src/patterns/email-input/email-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('EmailInputPattern tests', () => {
describe('createEmailSchema', () => {
it('should create schema for required email input', () => {
const data: EmailInputPattern['data'] = {
label: 'Test Email Input Label',
label: 'Test Email Label',
required: true,
};

Expand All @@ -27,7 +27,7 @@ describe('EmailInputPattern tests', () => {

it('should create schema for optional email input', () => {
const data: EmailInputPattern['data'] = {
label: 'Test Email Input Label',
label: 'Test Email Label',
required: false,
};

Expand All @@ -46,7 +46,7 @@ describe('EmailInputPattern tests', () => {
type: 'email-input',
id: 'test',
data: {
label: 'Test Email Input Label',
label: 'Test Email Label',
required: true,
},
};
Expand All @@ -68,7 +68,7 @@ describe('EmailInputPattern tests', () => {
type: 'email-input',
id: 'test',
data: {
label: 'Test Email Input Label',
label: 'Test Email Label',
required: true,
},
};
Expand All @@ -87,7 +87,7 @@ describe('EmailInputPattern tests', () => {

it('should parse config data correctly', () => {
const obj = {
label: 'Test Email Input Label',
label: 'Test Email Label',
required: true,
};

Expand All @@ -96,7 +96,7 @@ describe('EmailInputPattern tests', () => {
}
const result = emailInputConfig.parseConfigData(obj);
if (result.success) {
expect(result.data.label).toBe('Test Email Input Label');
expect(result.data.label).toBe('Test Email Label');
expect(result.data.required).toBe(true);
} else {
expect.fail('Unexpected validation failure');
Expand Down
12 changes: 6 additions & 6 deletions packages/forms/src/patterns/gender-id/gender-id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('GenderIdPattern tests', () => {
describe('createGenderIdSchema', () => {
it('should create schema for required gender identity input', () => {
const data: GenderIdPattern['data'] = {
label: 'Test Gender Identity Label',
label: 'Test Gender identity Label',
required: true,
preferNotToAnswerText: 'Prefer not to share my gender identity',
};
Expand All @@ -29,7 +29,7 @@ describe('GenderIdPattern tests', () => {

it('should create schema for optional gender identity input', () => {
const data: GenderIdPattern['data'] = {
label: 'Test Gender Identity Label',
label: 'Test Gender identity Label',
required: false,
};

Expand All @@ -48,7 +48,7 @@ describe('GenderIdPattern tests', () => {
id: 'gender-identity-1',
type: 'gender-id',
data: {
label: 'Test Gender Identity Label',
label: 'Test Gender identity Label',
required: true,
preferNotToAnswerText: 'Prefer not to share my gender identity',
},
Expand All @@ -71,7 +71,7 @@ describe('GenderIdPattern tests', () => {
id: 'gender-identity-1',
type: 'gender-id',
data: {
label: 'Test Gender Identity Label',
label: 'Test Gender identity Label',
required: true,
preferNotToAnswerText: 'Prefer not to share my gender identity',
},
Expand All @@ -91,7 +91,7 @@ describe('GenderIdPattern tests', () => {

it('should parse config data correctly', () => {
const obj = {
label: 'Test Gender Identity Label',
label: 'Test Gender identity Label',
required: true,
hint: 'For example, man, woman, non-binary',
preferNotToAnswerText: 'Prefer not to share my gender identity',
Expand All @@ -102,7 +102,7 @@ describe('GenderIdPattern tests', () => {
}
const result = genderIdConfig.parseConfigData(obj);
if (result.success) {
expect(result.data.label).toBe('Test Gender Identity Label');
expect(result.data.label).toBe('Test Gender identity Label');
expect(result.data.required).toBe(true);
expect(result.data.hint).toBe('For example, man, woman, non-binary');
expect(result.data.preferNotToAnswerText).toBe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('SocialSecurityNumberPattern tests', () => {
const invalidResult = schema.safeParse(invalidInput);
expect(invalidResult.success).toBe(false);
expect(invalidResult.error?.issues[0].message).toBe(
'Social Security Number must have exactly 9 digits'
'Social Security number must have exactly 9 digits'
);
});

Expand All @@ -43,7 +43,7 @@ describe('SocialSecurityNumberPattern tests', () => {
const invalidResult = schema.safeParse(invalidInput);
expect(invalidResult.success).toBe(false);
expect(invalidResult.error?.issues[0].message).toBe(
'Social Security Number must have exactly 9 digits'
'Social Security number must have exactly 9 digits'
);
});

Expand All @@ -59,7 +59,7 @@ describe('SocialSecurityNumberPattern tests', () => {
const shortInputResult = schema.safeParse(shortInput);
expect(shortInputResult.success).toBe(false);
expect(shortInputResult.error?.issues[0].message).toBe(
'Social Security Number must have exactly 9 digits'
'Social Security number must have exactly 9 digits'
);
});

Expand All @@ -76,7 +76,7 @@ describe('SocialSecurityNumberPattern tests', () => {
const result = schema.safeParse(ssn);
expect(result.success).toBe(false);
expect(result.error?.issues[0].message).toBe(
'Social Security Number must start with a valid prefix (not 9, 666, or 000)'
'Social Security number must start with a valid prefix (not 9, 666, or 000)'
);
});
});
Expand All @@ -96,11 +96,11 @@ describe('SocialSecurityNumberPattern tests', () => {
const errorMessage = result.error?.issues[0].message;
if (ssn === '555-00-6789') {
expect(errorMessage).toBe(
'Social Security Number must have a valid middle segment (not 00)'
'Social Security number must have a valid middle segment (not 00)'
);
} else if (ssn === '555-12-0000') {
expect(errorMessage).toBe(
'Social Security Number must have a valid suffix (not 0000)'
'Social Security number must have a valid suffix (not 0000)'
);
}
});
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('SocialSecurityNumberPattern tests', () => {
if (!result.success) {
expect(result.error).toBeDefined();
expect(result.error?.message).toContain(
'Social Security Number must have exactly 9 digits'
'Social Security number must have exactly 9 digits'
);
} else {
expect.fail('Unexpected validation success');
Expand Down

0 comments on commit 98fc973

Please sign in to comment.