Skip to content

Commit

Permalink
Updated and Fixed the playwright tests in react-SDK (#534)
Browse files Browse the repository at this point in the history
Co-authored-by: mashm <[email protected]>
  • Loading branch information
4manasa and mashm authored Nov 14, 2024
1 parent b3d010d commit 319fd2f
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 63 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/Digv2/ComplexFields/CaseView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test.describe('E2E test', () => {
/** Wait until newly created case loads */
await expect(page.locator('div[id="Assignment"]')).toBeVisible();

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

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

Expand Down
24 changes: 12 additions & 12 deletions tests/e2e/Digv2/ComplexFields/DataReference.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test.describe('E2E test', () => {
await selectedTestName.click();
await page.locator('li:has-text("Autocomplete")').click();

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

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

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

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

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

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

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

const selectProducts = page.locator('div[role="combobox"]');
const selectProducts = page.locator('input[role="combobox"]');
await selectProducts.click();
await page.locator('li:has-text("Mobile")').click();
await page.locator('li:has-text("Telivision")').click();
await page.locator('li:has-text("Television")').click();
await selectProducts.click();

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

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

await expect(assignment.locator('td >> text="Mobile"')).toBeVisible();
await expect(assignment.locator('td >> text="Telivision"')).toBeVisible();
await expect(assignment.locator('td >> text="Television"')).toBeVisible();

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

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

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

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

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

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

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

/** Checkbox group mode type test */
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Digv2/FormFields/Attachment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ test.describe('E2E test', () => {
/** Testing error case by uploading empty file */
await page.setInputFiles(`#AttachmentList`, [zeroBytesFile]);
await expect(page.locator('div >> text="Error with one or more files"')).toBeVisible();
await expect(page.locator(`div >> text="Empty file can't be uploaded."`)).toBeVisible();
await expect(page.locator(`div >> text="Empty file can't be uploaded." >> nth=0`)).toBeVisible();

const errorFile = await page.locator('div[class="psdk-utility-card"]:has-text("Unable to upload file")');
await errorFile.locator('button[aria-label="Delete Attachment"]').click();
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/Digv2/FormFields/Date.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test.describe('E2E test', () => {
const requiredDateInput = requiredDate.locator('input');
await requiredDateInput.click();
const futureDate = common.getFutureDate();
await requiredDateInput.fill(futureDate);
await requiredDateInput.pressSequentially(futureDate);

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

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

Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/Digv2/FormFields/DateTime.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ test.describe('E2E test', () => {
const formattedDate = `${(date.getMonth() + 1).toString().padStart(2, '0')}${date
.getDate()
.toString()
.padStart(2, '0')}${date.getFullYear()}${date.getHours()}${date.getMinutes()}`;
.padStart(2, '0')}${date.getFullYear()}${date.getHours()}${date.getMinutes()}${date.getHours() >= 12 ? 'pm' : 'am'}`;
await requiredDateTimeInput.click();
await requiredDateTimeInput.fill(formattedDate);
await requiredDateTimeInput.pressSequentially(formattedDate);

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

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

Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/Digv2/FormFields/Email.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ test.describe('E2E test', () => {

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

/** Checking 'field label', 'placeholder', and 'helper text' */
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Digv2/FormFields/FieldGroup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ test.describe('E2E test', () => {
// Collapsible Tests
await expect(page.getByText('Collapsible Field Group')).toBeVisible();
await expect(page.locator('input[data-test-id="861d2d04e52d59e8b85a27fd5b4aef28"]')).toHaveValue('John Doe');
await expect(await page.locator('div[data-test-id="8e70e124867b68bec5cbf1f2f25da383"] >> div[role="button"]').textContent()).toBe(
await expect(await page.locator('div[data-test-id="8e70e124867b68bec5cbf1f2f25da383"] >> div[role="combobox"]').textContent()).toBe(
'United States'
);

Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/Digv2/FormFields/Integer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ test.describe('E2E test', () => {

/** Required tests */
const requiredInteger = page.locator('input[data-test-id="0658481a174254dded4a0c1ffe6b8380"]');
requiredInteger.fill('10000');
await requiredInteger.fill('10000');
await requiredInteger.blur();
attributes = await common.getAttributes(requiredInteger);
await expect(attributes.includes('required')).toBeTruthy();
await expect(await requiredInteger.getAttribute('placeholder')).toBe('Integer Placeholder');
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/Digv2/FormFields/Phone.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ test.describe('E2E test', () => {
const validationMsg = 'Enter a valid phone number';
await editablePhoneInput.clear();
await countrySelector.click();
await page.locator('text=United States+1 >> nth=0').click();
await page.locator('text=United Kingdom+44 >> nth=0').click();
/** Entering an invalid Phone number */
await common.enterPhoneNumber(editablePhone, '61');
await editablePhoneInput.blur();
/** Expecting an error for Invalid phone number */

await expect(page.locator(`p:has-text("${validationMsg}")`)).toBeVisible();

/** Entering a valid Phone number */
await editablePhoneInput.click();
await editablePhoneInput.clear();
await countrySelector.click();
await page.locator('text=United States+1 >> nth=0').click();
Expand Down
24 changes: 12 additions & 12 deletions tests/e2e/Digv2/FormFields/Time.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ test.describe('E2E test', () => {
await expect(page.locator('p.Mui-error.Mui-required')).toBeVisible();

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

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

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

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

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

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

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

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

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

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

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

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

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

if (isVisible) {
await expect(conditionallyVisibleTime).toBeVisible();
Expand Down
11 changes: 4 additions & 7 deletions tests/e2e/Digv2/LandingPages/InlineDashboard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ test.describe('E2E test', () => {
const caseIdFilter = filters.locator('div:has-text("Case ID")');
caseIdFilter.locator('input').fill(caseID);

await page.waitForResponse('**/data_views/D_ComplexFieldsList');
const pagination = page.locator('div[id="pagination"]');
await expect(pagination.locator('p:has-text("1–1 of 1")')).toBeVisible();

await expect(table.locator(`td >> text=${caseID}`)).toBeVisible();
await expect(table.locator('td >> text="Complex Fields"')).toBeVisible();
Expand All @@ -67,12 +68,8 @@ test.describe('E2E test', () => {
await currentMonthSelector.locator(`text="${day.getDate().toString()}"`).click();
await currentMonthSelector.locator(`text="${nextDay.getDate().toString()}"`).click();

const complexTable = page.locator('div[id="list-view"] >> nth=0');

await expect(complexTable.locator(`td:has-text("${day.getDate().toString().padStart(2, '0')}")`)).toBeVisible();

const pagination = page.locator('div[id="pagination"]');
await expect(pagination.locator('p:has-text("1-1 of 1")')).toBeVisible();
const dateCol = await table.locator('td >> nth=2');
await expect(dateCol.getByText(`${new Date().getDate().toString().padStart(2, '0')}`)).toBeVisible();

await page.locator('a:has-text("Clear All")').click();

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/MediaCo/embedded.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test.describe('E2E test', () => {
await cityInput.fill('Cambridge');

const state = page.locator('div[data-test-id="46A2A41CC6E552044816A2D04634545D"]');
const stateSelector = state.locator('div[role="button"]');
const stateSelector = state.locator('div[role="combobox"]');
await stateSelector.click();
await page.locator('li[data-value="MA"]').click();

Expand All @@ -68,7 +68,7 @@ test.describe('E2E test', () => {
const dataServiceBeginDateInput = dataServiceBeginDate.locator('input');
await dataServiceBeginDateInput.click();
const futureDate = common.getFutureDate();
await dataServiceBeginDateInput.fill(futureDate);
await dataServiceBeginDateInput.pressSequentially(futureDate);

await page.locator('button:has-text("next")').click();

Expand Down
25 changes: 6 additions & 19 deletions tests/e2e/MediaCo/portal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test.describe('E2E test', () => {
const serviceDateInput = serviceDate.locator('input');
await serviceDateInput.click();
const futureDate = common.getFutureDate();
await serviceDateInput.fill(futureDate);
await serviceDateInput.pressSequentially(futureDate);

await page.locator('button:has-text("submit")').click();

Expand All @@ -60,7 +60,7 @@ test.describe('E2E test', () => {
await cityInput.fill('Cambridge');

const state = page.locator('div[data-test-id="46A2A41CC6E552044816A2D04634545D"]');
const stateSelector = state.locator('div[role="button"]');
const stateSelector = state.locator('div[role="combobox"]');
await stateSelector.click();
await page.locator('li[data-value="MA"]').click();

Expand Down Expand Up @@ -100,30 +100,17 @@ test.describe('E2E test', () => {
const sendToMgr = page.locator('label[data-test-id="C3B43E79AEC2D689F0CF97BD6AFB7DC4"]');
await sendToMgr.check();

const currentCaseID = await page.locator('div[id="current-caseID"]').textContent();
const filePath = path.join(__dirname, '../../../assets/img/cableinfo.jpg');
const filePath = path.join(__dirname, '../../../../../assets/img/cableinfo.jpg');

const attachmentID = await page.locator('div[id="attachment-ID"]').textContent();
await page.setInputFiles(`#${attachmentID}`, filePath);

await Promise.all([
page.waitForResponse(
`${endpoints.serverConfig.infinityRestServerUrl}${
endpoints.serverConfig.appAlias ? `/app/${endpoints.serverConfig.appAlias}` : ''
}/api/application/v2/attachments/upload`
)
]);
await expect(page.locator('CircularProgress')).not.toBeVisible();
await page.waitForTimeout(5000);

await page.locator('button:has-text("submit")').click();

await Promise.all([
page.waitForResponse(
`${endpoints.serverConfig.infinityRestServerUrl}${
endpoints.serverConfig.appAlias ? `/app/${endpoints.serverConfig.appAlias}` : ''
}/api/application/v2/cases/${currentCaseID}/attachments?includeThumbnail=false`
)
]);

await page.waitForTimeout(5000);
const attachmentCount = await page.locator('div[id="attachments-count"]').textContent();
await expect(Number(attachmentCount)).toBeGreaterThan(0);
}, 10000);
Expand Down

0 comments on commit 319fd2f

Please sign in to comment.