Skip to content

Commit 319fd2f

Browse files
4manasamashm
andauthored
Updated and Fixed the playwright tests in react-SDK (#534)
Co-authored-by: mashm <[email protected]>
1 parent b3d010d commit 319fd2f

File tree

13 files changed

+51
-63
lines changed

13 files changed

+51
-63
lines changed

tests/e2e/Digv2/ComplexFields/CaseView.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ test.describe('E2E test', () => {
6666
/** Wait until newly created case loads */
6767
await expect(page.locator('div[id="Assignment"]')).toBeVisible();
6868

69-
await page.locator('button >> span:has-text("Cancel")').click();
69+
await page.locator('button:has-text("Cancel")').click();
7070

7171
await page.locator('button[id="go-btn"]').click();
7272

tests/e2e/Digv2/ComplexFields/DataReference.spec.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ test.describe('E2E test', () => {
3939
await selectedTestName.click();
4040
await page.locator('li:has-text("Autocomplete")').click();
4141

42-
let selectedProduct = page.locator('div[role="combobox"]');
42+
let selectedProduct = page.locator('input[role="combobox"]');
4343
await selectedProduct.click();
4444
await page.locator('li:has-text("Basic Product")').click();
4545

@@ -66,7 +66,7 @@ test.describe('E2E test', () => {
6666
await selectedTestName.click();
6767
await page.locator('li:has-text("Dropdown")').click();
6868

69-
selectedProduct = page.locator('div[role="button"]:has-text("Basic Product")');
69+
selectedProduct = page.locator('div[role="combobox"]:has-text("Basic Product")');
7070
await selectedProduct.click();
7171
await page.locator('li:has-text("Basic Product")').click();
7272

@@ -121,7 +121,7 @@ test.describe('E2E test', () => {
121121
await selectedTestName.click();
122122
await page.locator('li:has-text("SingleRecord")').click();
123123

124-
selectedProduct = page.locator('div[role="combobox"]');
124+
selectedProduct = page.locator('input[role="combobox"]');
125125
await selectedProduct.click();
126126
await page.locator('li:has-text("Basic Product")').click();
127127

@@ -183,7 +183,7 @@ test.describe('E2E test', () => {
183183
await selectedTestName.click();
184184
await page.locator('li:has-text("SingleSelect")').click();
185185

186-
selectedProduct = page.locator('div[role="combobox"]');
186+
selectedProduct = page.locator('input[role="combobox"]');
187187
await selectedProduct.click();
188188
await page.locator('li:has-text("Basic Product")').click();
189189
await expect(selectedProduct).toBeVisible();
@@ -213,34 +213,34 @@ test.describe('E2E test', () => {
213213
await displayAs.click();
214214
await page.locator('li:has-text("Combo-Box")').click();
215215

216-
const selectProducts = page.locator('div[role="combobox"]');
216+
const selectProducts = page.locator('input[role="combobox"]');
217217
await selectProducts.click();
218218
await page.locator('li:has-text("Mobile")').click();
219-
await page.locator('li:has-text("Telivision")').click();
219+
await page.locator('li:has-text("Television")').click();
220220
await selectProducts.click();
221221

222222
await page.locator('button:has-text("Next")').click();
223223

224224
assignment = page.locator('div[id="Assignment"]');
225225

226226
await expect(assignment.locator('td >> text="Mobile"')).toBeVisible();
227-
await expect(assignment.locator('td >> text="Telivision"')).toBeVisible();
227+
await expect(assignment.locator('td >> text="Television"')).toBeVisible();
228228

229229
await page.locator('button:has-text("Previous")').click();
230230

231-
await expect(selectProducts.locator('div[role="button"]:has-text("Mobile")')).toBeVisible();
232-
await expect(selectProducts.locator('div[role="button"]:has-text("Telivision")')).toBeVisible();
231+
await expect(assignment.locator('div[role="button"]:has-text("Mobile")')).toBeVisible();
232+
await expect(assignment.locator('div[role="button"]:has-text("Television")')).toBeVisible();
233233

234-
let deleteProduct = await selectProducts.locator('div[role="button"]:has-text("Mobile")');
234+
let deleteProduct = await assignment.locator('div[role="button"]:has-text("Mobile")');
235235
await deleteProduct.locator('svg[focusable="false"]').click();
236236

237237
await page.locator('button:has-text("Next")').click();
238238

239-
await expect(selectProducts.locator('div[role="button"]:has-text("Mobile")')).not.toBeVisible();
239+
await expect(assignment.locator('div[role="button"]:has-text("Mobile")')).not.toBeVisible();
240240

241241
await page.locator('button:has-text("Previous")').click();
242242

243-
deleteProduct = await selectProducts.locator('div[role="button"]:has-text("Telivision")');
243+
deleteProduct = await assignment.locator('div[role="button"]:has-text("Television")');
244244
await deleteProduct.locator('svg[focusable="false"]').click();
245245

246246
/** Checkbox group mode type test */

tests/e2e/Digv2/FormFields/Attachment.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ test.describe('E2E test', () => {
114114
/** Testing error case by uploading empty file */
115115
await page.setInputFiles(`#AttachmentList`, [zeroBytesFile]);
116116
await expect(page.locator('div >> text="Error with one or more files"')).toBeVisible();
117-
await expect(page.locator(`div >> text="Empty file can't be uploaded."`)).toBeVisible();
117+
await expect(page.locator(`div >> text="Empty file can't be uploaded." >> nth=0`)).toBeVisible();
118118

119119
const errorFile = await page.locator('div[class="psdk-utility-card"]:has-text("Unable to upload file")');
120120
await errorFile.locator('button[aria-label="Delete Attachment"]').click();

tests/e2e/Digv2/FormFields/Date.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test.describe('E2E test', () => {
4646
const requiredDateInput = requiredDate.locator('input');
4747
await requiredDateInput.click();
4848
const futureDate = common.getFutureDate();
49-
await requiredDateInput.fill(futureDate);
49+
await requiredDateInput.pressSequentially(futureDate);
5050

5151
await expect(page.locator('p.Mui-error.Mui-required')).toBeHidden();
5252

@@ -96,7 +96,7 @@ test.describe('E2E test', () => {
9696
const editableDate = page.locator('div[data-test-id="80f5dcc587f457378158bb305ec858a8"]');
9797
const editableDateInput = editableDate.locator('input');
9898
await editableDateInput.click();
99-
await editableDateInput.fill(futureDate);
99+
await editableDateInput.pressSequentially(futureDate);
100100
attributes = await common.getAttributes(editableDateInput);
101101
await expect(attributes.includes('readonly')).toBeFalsy();
102102

tests/e2e/Digv2/FormFields/DateTime.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ test.describe('E2E test', () => {
4848
const formattedDate = `${(date.getMonth() + 1).toString().padStart(2, '0')}${date
4949
.getDate()
5050
.toString()
51-
.padStart(2, '0')}${date.getFullYear()}${date.getHours()}${date.getMinutes()}`;
51+
.padStart(2, '0')}${date.getFullYear()}${date.getHours()}${date.getMinutes()}${date.getHours() >= 12 ? 'pm' : 'am'}`;
5252
await requiredDateTimeInput.click();
53-
await requiredDateTimeInput.fill(formattedDate);
53+
await requiredDateTimeInput.pressSequentially(formattedDate);
5454

5555
await expect(page.locator('p.Mui-error.Mui-required')).toBeHidden();
5656

@@ -100,7 +100,7 @@ test.describe('E2E test', () => {
100100
const editableDateTime = page.locator('div[data-test-id="4e5110fbcaf65441b3e4c763907b5eb8"]');
101101
const editableDateTimeInput = editableDateTime.locator('input');
102102
await editableDateTimeInput.click();
103-
await editableDateTimeInput.fill(formattedDate);
103+
await editableDateTimeInput.pressSequentially(formattedDate);
104104
attributes = await common.getAttributes(editableDateTimeInput);
105105
await expect(attributes.includes('readonly')).toBeFalsy();
106106

tests/e2e/Digv2/FormFields/Email.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ test.describe('E2E test', () => {
4343

4444
/** Required tests */
4545
const requiredEmail = page.locator('input[data-test-id="96fa7548c363cdd5adb29c2c2749e436"]');
46-
requiredEmail.fill('[email protected]');
46+
await requiredEmail.fill('[email protected]');
47+
await requiredEmail.blur();
4748
await expect(page.locator('p.Mui-error.Mui-required')).toBeHidden();
4849

4950
/** Checking 'field label', 'placeholder', and 'helper text' */

tests/e2e/Digv2/FormFields/FieldGroup.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test.describe('E2E test', () => {
6262
// Collapsible Tests
6363
await expect(page.getByText('Collapsible Field Group')).toBeVisible();
6464
await expect(page.locator('input[data-test-id="861d2d04e52d59e8b85a27fd5b4aef28"]')).toHaveValue('John Doe');
65-
await expect(await page.locator('div[data-test-id="8e70e124867b68bec5cbf1f2f25da383"] >> div[role="button"]').textContent()).toBe(
65+
await expect(await page.locator('div[data-test-id="8e70e124867b68bec5cbf1f2f25da383"] >> div[role="combobox"]').textContent()).toBe(
6666
'United States'
6767
);
6868

tests/e2e/Digv2/FormFields/Integer.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ test.describe('E2E test', () => {
4141

4242
/** Required tests */
4343
const requiredInteger = page.locator('input[data-test-id="0658481a174254dded4a0c1ffe6b8380"]');
44-
requiredInteger.fill('10000');
44+
await requiredInteger.fill('10000');
45+
await requiredInteger.blur();
4546
attributes = await common.getAttributes(requiredInteger);
4647
await expect(attributes.includes('required')).toBeTruthy();
4748
await expect(await requiredInteger.getAttribute('placeholder')).toBe('Integer Placeholder');

tests/e2e/Digv2/FormFields/Phone.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,16 @@ test.describe('E2E test', () => {
9999
const validationMsg = 'Enter a valid phone number';
100100
await editablePhoneInput.clear();
101101
await countrySelector.click();
102-
await page.locator('text=United States+1 >> nth=0').click();
102+
await page.locator('text=United Kingdom+44 >> nth=0').click();
103103
/** Entering an invalid Phone number */
104104
await common.enterPhoneNumber(editablePhone, '61');
105105
await editablePhoneInput.blur();
106106
/** Expecting an error for Invalid phone number */
107+
107108
await expect(page.locator(`p:has-text("${validationMsg}")`)).toBeVisible();
108109

109110
/** Entering a valid Phone number */
111+
await editablePhoneInput.click();
110112
await editablePhoneInput.clear();
111113
await countrySelector.click();
112114
await page.locator('text=United States+1 >> nth=0').click();

tests/e2e/Digv2/FormFields/Time.spec.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ test.describe('E2E test', () => {
4242
await expect(page.locator('p.Mui-error.Mui-required')).toBeVisible();
4343

4444
/** Required tests */
45-
const requiredTime = page.locator('input[data-test-id="2a98fa391e3ce4e2a077bb71271eb2da"]');
45+
const requiredTime = page.locator('div[data-test-id="2a98fa391e3ce4e2a077bb71271eb2da"] >> input');
4646
const date = new Date();
47-
const time = `${date.getHours()}${date.getMinutes()}`;
48-
requiredTime.fill(time);
47+
const time = `${date.getHours()}${date.getMinutes()}${date.getHours() >= 12 ? 'pm' : 'am'}`;
48+
requiredTime.pressSequentially(time);
4949
attributes = await common.getAttributes(requiredTime);
5050
await expect(attributes.includes('required')).toBeTruthy();
5151

5252
await expect(page.locator('p.Mui-error.Mui-required')).toBeHidden();
5353

54-
const notRequiredTime = page.locator('input[data-test-id="921d625dba40a48cdcd006d6d17273fd"]');
54+
const notRequiredTime = page.locator('div[data-test-id="921d625dba40a48cdcd006d6d17273fd"] >> input');
5555
attributes = await common.getAttributes(notRequiredTime);
5656
await expect(attributes.includes('required')).toBeFalsy();
5757

@@ -61,19 +61,19 @@ test.describe('E2E test', () => {
6161
await page.getByRole('option', { name: 'Disable' }).click();
6262

6363
// /** Disable tests */
64-
const alwaysDisabledTime = page.locator('input[data-test-id="b5b2a2335304986a2aba011c0a2a464d"]');
64+
const alwaysDisabledTime = page.locator('div[data-test-id="b5b2a2335304986a2aba011c0a2a464d"] >> input');
6565
attributes = await common.getAttributes(alwaysDisabledTime);
6666
await expect(attributes.includes('disabled')).toBeTruthy();
6767

68-
const conditionallyDisabledTime = page.locator('input[data-test-id="9f7b7d5d8793642e0650a03f5f9dd991"]');
68+
const conditionallyDisabledTime = page.locator('div[data-test-id="9f7b7d5d8793642e0650a03f5f9dd991"] >> input');
6969
attributes = await common.getAttributes(conditionallyDisabledTime);
7070
if (isDisabled) {
7171
await expect(attributes.includes('disabled')).toBeTruthy();
7272
} else {
7373
await expect(attributes.includes('disabled')).toBeFalsy();
7474
}
7575

76-
const neverDisabledTime = page.locator('input[data-test-id="aeb770a579929bf10a1b301600da68ca"]');
76+
const neverDisabledTime = page.locator('div[data-test-id="aeb770a579929bf10a1b301600da68ca"] >> input');
7777
attributes = await common.getAttributes(neverDisabledTime);
7878
await expect(attributes.includes('disabled')).toBeFalsy();
7979

@@ -87,8 +87,8 @@ test.describe('E2E test', () => {
8787
attributes = await common.getAttributes(readonlyTime);
8888
await expect(attributes.includes('readonly')).toBeTruthy();
8989

90-
const editableTime = page.locator('input[data-test-id="9a43bbe34f0e3db5a53f8e89082c0770"]');
91-
editableTime.fill(time);
90+
const editableTime = page.locator('div[data-test-id="9a43bbe34f0e3db5a53f8e89082c0770"] >> input');
91+
editableTime.pressSequentially(time);
9292

9393
attributes = await common.getAttributes(editableTime);
9494
await expect(attributes.includes('readonly')).toBeFalsy();
@@ -99,12 +99,12 @@ test.describe('E2E test', () => {
9999
await page.getByRole('option', { name: 'Visibility' }).click();
100100

101101
/** Visibility tests */
102-
await expect(page.locator('input[data-test-id="1b5786591e69307188bb7bb6ed1d6007"]')).toBeVisible();
102+
await expect(page.locator('div[data-test-id="1b5786591e69307188bb7bb6ed1d6007"]')).toBeVisible();
103103

104-
const neverVisibleTime = await page.locator('input[data-test-id="971d3da425a39fac98652a85633db661"]');
104+
const neverVisibleTime = await page.locator('div[data-test-id="971d3da425a39fac98652a85633db661"] >> input');
105105
await expect(neverVisibleTime).not.toBeVisible();
106106

107-
const conditionallyVisibleTime = await page.locator('input[data-test-id="6e52133ee5d2aef2dab9a8e61511c030"]');
107+
const conditionallyVisibleTime = await page.locator('div[data-test-id="6e52133ee5d2aef2dab9a8e61511c030"] >> input');
108108

109109
if (isVisible) {
110110
await expect(conditionallyVisibleTime).toBeVisible();

0 commit comments

Comments
 (0)