Skip to content

Commit e182c6d

Browse files
4manasamanasa
andauthored
added tests for Currency Field (#115)
Co-authored-by: manasa <[email protected]>
1 parent d26d7f3 commit e182c6d

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/* eslint-disable no-template-curly-in-string */
2+
/* eslint-disable no-undef */
3+
4+
const { test, expect } = require('@playwright/test');
5+
const config = require('../../../config');
6+
const common = require('../../../common');
7+
8+
// These values represent the data values used for the conditions and are initialised in pyDefault DT
9+
const isDisabled = true;
10+
const isVisible = true;
11+
12+
test.beforeEach(async ({ page }) => {
13+
await page.setViewportSize({ width: 1720, height: 1080 });
14+
await page.goto('http://localhost:3502/portal');
15+
});
16+
17+
test.describe('E2E test', () => {
18+
let attributes;
19+
20+
test('should login, create case and run the Currency tests', async ({ page }) => {
21+
await common.Login(
22+
config.config.apps.digv2.user.username,
23+
config.config.apps.digv2.user.password,
24+
page
25+
);
26+
27+
/** Testing announcement banner presence */
28+
const announcementBanner = page.locator('h6:has-text("Announcements")');
29+
await expect(announcementBanner).toBeVisible();
30+
31+
/** Testing worklist presence */
32+
const worklist = page.locator('h6:has-text("My Worklist")');
33+
await expect(worklist).toBeVisible();
34+
35+
/** Creating a Form Field case-type */
36+
const complexFieldsCase = page.locator('div[role="button"]:has-text("Form Field")');
37+
await complexFieldsCase.click();
38+
39+
/** Selecting Currency from the Category dropdown */
40+
const selectedCategory = page.locator('div[data-test-id="76729937a5eb6b0fd88c42581161facd"]');
41+
await selectedCategory.click();
42+
await page.getByRole('option', { name: 'Currency' }).click();
43+
44+
/** Selecting Required from the Sub Category dropdown */
45+
let selectedSubCategory = page.locator('div[data-test-id="9463d5f18a8924b3200b56efaad63bda"]');
46+
await selectedSubCategory.click();
47+
await page.getByRole('option', { name: 'Required' }).click();
48+
49+
/** Required tests */
50+
const requiredCurrency = page.locator(
51+
'input[data-test-id="cab671a0ad307780a2de423a3d19924e"]'
52+
);
53+
attributes = await common.getAttributes(requiredCurrency);
54+
await expect(attributes.includes('required')).toBeFalsy();
55+
56+
const notRequiredCurrency = page.locator(
57+
'input[data-test-id="77af0bd660f2e0276e23a7db7d48235a"]'
58+
);
59+
attributes = await common.getAttributes(notRequiredCurrency);
60+
await expect(attributes.includes('required')).toBeTruthy();
61+
62+
/** Selecting Disable from the Sub Category dropdown */
63+
selectedSubCategory = page.locator('div[data-test-id="9463d5f18a8924b3200b56efaad63bda"]');
64+
await selectedSubCategory.click();
65+
await page.getByRole('option', { name: 'Disable' }).click();
66+
67+
// /** Disable tests */
68+
const alwaysDisabledCurrency = page.locator(
69+
'input[data-test-id="0d14f3717305e0238966749e6a853dad"]'
70+
);
71+
attributes = await common.getAttributes(alwaysDisabledCurrency);
72+
await expect(attributes.includes('disabled')).toBeTruthy();
73+
74+
const conditionallyDisabledCurrency = page.locator(
75+
'input[data-test-id="d5e33df8e1d99971f69b7c0015a5ea58"]'
76+
);
77+
attributes = await common.getAttributes(conditionallyDisabledCurrency);
78+
if (isDisabled) {
79+
await expect(attributes.includes('disabled')).toBeTruthy();
80+
} else {
81+
await expect(attributes.includes('disabled')).toBeFalsy();
82+
}
83+
84+
const neverDisabledCurrency = page.locator(
85+
'input[data-test-id="40fba95f48961ac8ead17beca7535294"]'
86+
);
87+
attributes = await common.getAttributes(neverDisabledCurrency);
88+
await expect(attributes.includes('disabled')).toBeFalsy();
89+
90+
/** Selecting Update from the Sub Category dropdown */
91+
selectedSubCategory = page.locator('div[data-test-id="9463d5f18a8924b3200b56efaad63bda"]');
92+
await selectedSubCategory.click();
93+
await page.getByRole('option', { name: 'Update' }).click();
94+
95+
/** Update tests */
96+
const readonlyCurrency = page.locator(
97+
'input[data-test-id="32bc05c9bac42b8d76ea72511afa89d0"]'
98+
);
99+
attributes = await common.getAttributes(readonlyCurrency);
100+
await expect(attributes.includes('readonly')).toBeTruthy();
101+
102+
const editableCurrency = page.locator(
103+
'input[data-test-id="837e53069fc48e63debdee7fa61fbc1a"]'
104+
);
105+
106+
editableCurrency.type("120");
107+
108+
attributes = await common.getAttributes(editableCurrency);
109+
await expect(attributes.includes('readonly')).toBeFalsy();
110+
111+
/** Selecting Visibility from the Sub Category dropdown */
112+
selectedSubCategory = page.locator('div[data-test-id="9463d5f18a8924b3200b56efaad63bda"]');
113+
await selectedSubCategory.click();
114+
await page.getByRole('option', { name: 'Visibility' }).click();
115+
116+
/** Visibility tests */
117+
await expect(
118+
page.locator('input[data-test-id="756f918704ee7dcd859928f068d02633"]')
119+
).toBeVisible();
120+
121+
const neverVisibleCurrency = await page.locator(
122+
'input[data-test-id="5aa7a927ac4876abf1fcff6187ce5d76"]'
123+
);
124+
await expect(neverVisibleCurrency).not.toBeVisible();
125+
126+
const conditionallyVisibleCurrency = await page.locator(
127+
'input[data-test-id="730a18d88ac68c9cc5f89bf5f6a5caea"]'
128+
);
129+
130+
if (isVisible) {
131+
await expect(conditionallyVisibleCurrency).toBeVisible();
132+
} else {
133+
await expect(conditionallyVisibleCurrency).not.toBeVisible();
134+
}
135+
}, 10000);
136+
});
137+
138+
test.afterEach(async ({ page }) => {
139+
await page.close();
140+
});

0 commit comments

Comments
 (0)