-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexHtmFunction.spec.ts
47 lines (38 loc) · 1.89 KB
/
indexHtmFunction.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { test } from "@playwright/test";
import { indexHtmPageFunction } from "@pages/indexHtmPageFunction";
import { faker } from '@faker-js/faker/locale/en_US';
import { testIdGenerator } from '@scripts/testIdGenerator';
import { feedbackWidgetData, indexHtmData } from "@test-data/testData.json";
const feedbackWidgetLoremIpsum = faker.lorem.paragraph({ min: 2, max: 7 });
//Run the test 2 times
for (let i = 0; i <= 1; i++) {
test.describe('Test the index htm page', () => {
test.beforeEach(async ({ page }) => {
console.log(`Running ${test.info().title}`);
await indexHtmPageFunction(page).goto();
});
test(`page copy run:${i}`, async ({ page }) => {
//Verify title of index.htm
await indexHtmPageFunction(page).verifyPageTitle(indexHtmData.pageTitle);
//Verify index htm page copy
await indexHtmPageFunction(page).verifyIndexPageCopyIntro(indexHtmData.pageCopy);
});
//Avoid testing third-party dependencies
//I know I'm violating best practice here, by testing Sentry's feedback widget but this is all about learning
//and exploration, so I'm disregarding best practice!
test(`feedback widget run:${i}`, async ({ page }) => {
//Open the feedback widget
await indexHtmPageFunction(page).clickFeedbackWidget();
//Fill in name field
await indexHtmPageFunction(page).fillFeedbackWidgetNameField(feedbackWidgetData.fullName);
//Fill in email field
await indexHtmPageFunction(page).fillFeedbackWidgetEmailField(feedbackWidgetData.email);
//Fill in message field
await indexHtmPageFunction(page).fillFeedbackWidgetMessageField(`${feedbackWidgetData.message} ${feedbackWidgetLoremIpsum} TestID:${testIdGenerator}`);
//Click Send Now button
await indexHtmPageFunction(page).clickFeedbackWidgetSendNowButton();
//Verify message sent successfully
await indexHtmPageFunction(page).verifyFeedbackWidgetMessageSent(feedbackWidgetData.confirmMessageSent, { ignoreCase: true });
});
});
}