|
1 | 1 | import { expect } from '@playwright/test';
|
2 | 2 | import { test } from '../../../fixtures/testFixture';
|
| 3 | +import { controlUnicode } from '../../../utils/unicodeConstants'; |
| 4 | +import { |
| 5 | + assertTextInput, |
| 6 | + assertSelectInput, |
| 7 | +} from '../../../utils/inputValidators'; |
| 8 | +import { |
| 9 | + DefaultInputCharLimit, |
| 10 | + PhoneInputCharLimit, |
| 11 | + EmailInputCharLimit, |
| 12 | + ZipInputCharLimit, |
| 13 | +} from 'utils/constants'; |
3 | 14 |
|
4 | 15 | test('Point of Contact: Checking for form errors based on user input', async ({
|
5 | 16 | page,
|
@@ -37,3 +48,133 @@ test('Point of Contact: Checking for form errors based on user input', async ({
|
37 | 48 | );
|
38 | 49 | });
|
39 | 50 | });
|
| 51 | + |
| 52 | +test('Point of Contact: Checking for unicode tolerance based on user input', async ({ |
| 53 | + page, |
| 54 | + navigateToProvidePointOfContact, |
| 55 | +}) => { |
| 56 | + test.slow(); |
| 57 | + |
| 58 | + navigateToProvidePointOfContact; |
| 59 | + |
| 60 | + await test.step('Point of Contact: Check that the error header render when no input is filled', async () => { |
| 61 | + await page.getByRole('button', { name: 'Continue to next step' }).click(); |
| 62 | + await expect( |
| 63 | + page.locator('#PointOfContactFormErrors div').first(), |
| 64 | + ).toBeVisible(); |
| 65 | + }); |
| 66 | + |
| 67 | + await test.step('Point of Contact: Check the first and last names for invalid input', async () => { |
| 68 | + const expectedValues = { |
| 69 | + firstField: controlUnicode.slice(0, DefaultInputCharLimit), |
| 70 | + lastField: controlUnicode.slice(0, DefaultInputCharLimit), |
| 71 | + phoneField: controlUnicode.slice(0, PhoneInputCharLimit), |
| 72 | + extensionField: controlUnicode.slice(0, DefaultInputCharLimit), |
| 73 | + emailField: controlUnicode.slice(0, EmailInputCharLimit), |
| 74 | + addressField1: controlUnicode.slice(0, DefaultInputCharLimit), |
| 75 | + addressField2: controlUnicode.slice(0, DefaultInputCharLimit), |
| 76 | + addressField3: controlUnicode.slice(0, DefaultInputCharLimit), |
| 77 | + addressField4: controlUnicode.slice(0, DefaultInputCharLimit), |
| 78 | + cityField: controlUnicode.slice(0, DefaultInputCharLimit), |
| 79 | + stateField: 'TX', |
| 80 | + zipField: controlUnicode.slice(0, ZipInputCharLimit), |
| 81 | + }; |
| 82 | + const unexpectedValues = { |
| 83 | + firstField: controlUnicode, |
| 84 | + lastField: controlUnicode, |
| 85 | + phoneField: controlUnicode, |
| 86 | + extensionField: controlUnicode, |
| 87 | + emailField: controlUnicode, |
| 88 | + addressField1: controlUnicode, |
| 89 | + addressField2: controlUnicode, |
| 90 | + addressField3: controlUnicode, |
| 91 | + addressField4: controlUnicode, |
| 92 | + cityField: controlUnicode, |
| 93 | + stateField: '', |
| 94 | + zipField: controlUnicode, |
| 95 | + }; |
| 96 | + |
| 97 | + await assertTextInput(page, 'First name', { |
| 98 | + fill: controlUnicode, |
| 99 | + expected: expectedValues.firstField, |
| 100 | + unexpected: unexpectedValues.firstField, |
| 101 | + }); |
| 102 | + await assertTextInput(page, 'Last name', { |
| 103 | + fill: controlUnicode, |
| 104 | + expected: expectedValues.lastField, |
| 105 | + unexpected: unexpectedValues.lastField, |
| 106 | + }); |
| 107 | + await assertTextInput(page, 'Phone number', { |
| 108 | + fill: controlUnicode, |
| 109 | + expected: expectedValues.phoneField, |
| 110 | + unexpected: unexpectedValues.phoneField, |
| 111 | + }); |
| 112 | + await assertTextInput(page, 'Extension', { |
| 113 | + fill: controlUnicode, |
| 114 | + expected: expectedValues.extensionField, |
| 115 | + unexpected: unexpectedValues.extensionField, |
| 116 | + }); |
| 117 | + await assertTextInput(page, 'Email address', { |
| 118 | + fill: controlUnicode, |
| 119 | + expected: expectedValues.emailField, |
| 120 | + unexpected: unexpectedValues.emailField, |
| 121 | + }); |
| 122 | + await assertTextInput(page, 'Street address line 1', { |
| 123 | + fill: controlUnicode, |
| 124 | + expected: expectedValues.addressField1, |
| 125 | + unexpected: unexpectedValues.addressField1, |
| 126 | + }); |
| 127 | + await assertTextInput(page, 'Street address line 2', { |
| 128 | + fill: controlUnicode, |
| 129 | + expected: expectedValues.addressField2, |
| 130 | + unexpected: unexpectedValues.addressField2, |
| 131 | + }); |
| 132 | + await assertTextInput(page, 'Street address line 3', { |
| 133 | + fill: controlUnicode, |
| 134 | + expected: expectedValues.addressField3, |
| 135 | + unexpected: unexpectedValues.addressField3, |
| 136 | + }); |
| 137 | + await assertTextInput(page, 'Street address line 4', { |
| 138 | + fill: controlUnicode, |
| 139 | + expected: expectedValues.addressField4, |
| 140 | + unexpected: unexpectedValues.addressField4, |
| 141 | + }); |
| 142 | + await assertTextInput(page, 'City', { |
| 143 | + fill: controlUnicode, |
| 144 | + expected: expectedValues.cityField, |
| 145 | + unexpected: unexpectedValues.cityField, |
| 146 | + }); |
| 147 | + await assertSelectInput(page, 'State or territory', { |
| 148 | + fill: { label: 'Texas (TX)' }, |
| 149 | + expected: expectedValues.stateField, |
| 150 | + unexpected: unexpectedValues.stateField, |
| 151 | + }); |
| 152 | + await assertTextInput(page, 'Zip code', { |
| 153 | + fill: controlUnicode, |
| 154 | + expected: expectedValues.zipField, |
| 155 | + unexpected: unexpectedValues.zipField, |
| 156 | + }); |
| 157 | + |
| 158 | + await page.getByRole('button', { name: 'Continue to next step' }).click(); |
| 159 | + |
| 160 | + await expect(page.locator('#PointOfContactFormErrors')).toContainText( |
| 161 | + 'Enter a valid phone number', |
| 162 | + ); |
| 163 | + await expect(page.locator('#PointOfContactFormErrors')).toContainText( |
| 164 | + 'Enter a valid email address', |
| 165 | + ); |
| 166 | + await expect(page.locator('#PointOfContactFormErrors')).toContainText( |
| 167 | + 'Enter a valid ZIP code', |
| 168 | + ); |
| 169 | + |
| 170 | + await expect(page.locator('form')).toContainText( |
| 171 | + 'You must enter a valid phone number.', |
| 172 | + ); |
| 173 | + await expect(page.locator('form')).toContainText( |
| 174 | + 'You must enter a valid email address.', |
| 175 | + ); |
| 176 | + await expect(page.locator('form')).toContainText( |
| 177 | + 'You must enter a valid ZIP code.', |
| 178 | + ); |
| 179 | + }); |
| 180 | +}); |
0 commit comments