Skip to content

Commit aed00b3

Browse files
Migrate remaining E2E tests from Cypress to Playwright
Completes the migration of all example projects to use Playwright for E2E testing, ensuring consistent testing infrastructure across the monorepo and leveraging Playwright's improved performance and debugging capabilities.
1 parent c3990db commit aed00b3

File tree

262 files changed

+9302
-5551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+9302
-5551
lines changed

.vscode/launch.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": []
4+
}

angular-universal-ssr/cypress.env.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

angular-universal-ssr/e2e/methods/methods.ts

Lines changed: 76 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,113 @@
1-
import { BaseMethods } from '../../../cypress-e2e/common/base';
1+
import { expect, Page } from '@playwright/test';
2+
3+
import { BaseMethods } from '../../../playwright-e2e/common/base';
24
import { baseSelectors, selectors, updatedSelectors } from '../../../cypress-e2e/common/selectors';
35
import { Constants } from '../../../cypress-e2e/fixtures/constants';
46

57
export class AngularUniversalSsrMethods extends BaseMethods {
6-
public checkActiveTabNameConnection(activeTabName: string, componentName: string): void {
7-
cy.get(selectors.angularUniversalSsrApp.activeTab)
8-
.invoke('text')
9-
.then((text: string) => {
10-
if (text === activeTabName) {
11-
this.checkElementWithTextPresence({
12-
selector: baseSelectors.tags.appRoot,
13-
text: componentName,
14-
visibilityState: 'be.visible',
15-
});
16-
}
8+
constructor(protected readonly page: Page) {
9+
super(page);
10+
}
11+
12+
async checkActiveTabNameConnection(activeTabName: string, componentName: string): Promise<void> {
13+
const text = (await this.page.locator(selectors.angularUniversalSsrApp.activeTab).innerText()).trim();
14+
15+
if (text === activeTabName) {
16+
await this.checkElementWithTextPresence({
17+
selector: baseSelectors.tags.appRoot,
18+
text: componentName,
19+
visibilityState: 'be.visible',
1720
});
21+
}
1822
}
1923

20-
public checkAddedCitiesBlockFunctionalityForMultipleHosts(
24+
async checkAddedCitiesBlockFunctionalityForMultipleHosts(
2125
extraHost: number,
2226
addedCities: string[],
2327
addedCitySelector: string,
2428
selectedCityInfo: string[],
2529
selectedCityInfoSelector: string,
26-
): void {
27-
this.clickElementWithText({
30+
): Promise<void> {
31+
await this.clickElementWithText({
2832
selector: updatedSelectors.angularUniversalSsrApp.tab,
2933
text: Constants.elementsText.angularUniversalSsrApp.tabsNames[2],
3034
});
31-
this.checkCitiesBlockFunctionality();
32-
cy.origin(
33-
Cypress.env(`localhost${extraHost}`),
34-
{ args: { addedCities, addedCitySelector, selectedCityInfoSelector, selectedCityInfo } },
35-
({ addedCities, addedCitySelector, selectedCityInfoSelector, selectedCityInfo }) => {
36-
cy.visit('/');
37-
addedCities.forEach((city: string, counter: number) => {
38-
cy.get(addedCitySelector).contains(city).click();
39-
cy.get(selectedCityInfoSelector).contains(selectedCityInfo[counter]).should('be.visible');
40-
cy.reload(true);
41-
cy.get(selectedCityInfoSelector).should('not.exist');
42-
});
43-
},
44-
);
35+
36+
await this.checkCitiesBlockFunctionality();
37+
38+
const remotePage = await this.page.context().newPage();
39+
40+
try {
41+
await remotePage.goto(`http://localhost:${extraHost}/`, { waitUntil: 'networkidle' });
42+
43+
for (let index = 0; index < addedCities.length; index++) {
44+
const city = addedCities[index];
45+
const expectedInfo = selectedCityInfo[index];
46+
47+
await remotePage.locator(addedCitySelector).filter({ hasText: city }).first().click();
48+
await expect(remotePage.locator(selectedCityInfoSelector).filter({ hasText: expectedInfo })).toBeVisible();
49+
50+
await remotePage.reload({ waitUntil: 'networkidle' });
51+
await expect(remotePage.locator(selectedCityInfoSelector).filter({ hasText: expectedInfo })).toHaveCount(0);
52+
}
53+
} finally {
54+
await remotePage.close();
55+
}
4556
}
4657

47-
public checkCitiesBlockFunctionality(): void {
48-
Constants.elementsText.angularUniversalSsrApp.addedCities.forEach(
49-
(city: string, counter: number) => {
50-
this.clickElementWithText({
51-
selector: updatedSelectors.angularUniversalSsrApp.addedCity,
52-
text: city,
53-
});
54-
this.checkElementWithTextPresence({
55-
selector: selectors.angularUniversalSsrApp.selectedCityInfo,
56-
text: Constants.commonPhrases.angularUniversalSsrApp.selectedCityInfo[counter],
57-
visibilityState: 'be.visible',
58-
});
59-
this.reloadWindow();
60-
this.checkElementVisibility({
61-
selector: selectors.angularUniversalSsrApp.selectedCityInfo,
62-
isVisible: false,
63-
});
64-
},
65-
);
58+
async checkCitiesBlockFunctionality(): Promise<void> {
59+
for (let index = 0; index < Constants.elementsText.angularUniversalSsrApp.addedCities.length; index++) {
60+
const city = Constants.elementsText.angularUniversalSsrApp.addedCities[index];
61+
const expectedInfo = Constants.commonPhrases.angularUniversalSsrApp.selectedCityInfo[index];
62+
63+
await this.clickElementWithText({
64+
selector: updatedSelectors.angularUniversalSsrApp.addedCity,
65+
text: city,
66+
});
67+
68+
await this.checkElementWithTextPresence({
69+
selector: selectors.angularUniversalSsrApp.selectedCityInfo,
70+
text: expectedInfo,
71+
visibilityState: 'be.visible',
72+
});
73+
74+
await this.reloadWindow();
75+
await this.checkElementVisibility({
76+
selector: selectors.angularUniversalSsrApp.selectedCityInfo,
77+
isVisible: false,
78+
});
79+
}
6680
}
6781

68-
public checkTextedElementsVisibility(elementsArray: string[], elementSelector: string): void {
69-
elementsArray.forEach((element: string) => {
70-
this.checkElementWithTextPresence({
82+
async checkTextedElementsVisibility(elementsArray: string[], elementSelector: string): Promise<void> {
83+
for (const element of elementsArray) {
84+
await this.checkElementWithTextPresence({
7185
selector: elementSelector,
7286
text: element,
7387
visibilityState: 'be.visible',
7488
});
75-
});
89+
}
7690
}
7791

78-
public addNewListValue(): void {
79-
this.checkElementQuantity({
92+
async addNewListValue(): Promise<void> {
93+
await this.checkElementQuantity({
8094
selector: baseSelectors.tags.coreElements.list,
8195
quantity: 3,
8296
});
83-
this.fillField({
97+
98+
await this.fillField({
8499
selector: baseSelectors.tags.inputs.input,
85100
text: Constants.commonConstantsData.standardPhrase,
86101
});
87-
this.checkInputValue(Constants.commonConstantsData.standardPhrase);
88-
this.clickElementWithText({
102+
103+
await this.checkInputValue(Constants.commonConstantsData.standardPhrase);
104+
105+
await this.clickElementWithText({
89106
selector: baseSelectors.tags.coreElements.button,
90107
text: Constants.elementsText.angularUniversalSsrApp.inputButtonText,
91108
});
92-
this.checkElementQuantity({
109+
110+
await this.checkElementQuantity({
93111
selector: baseSelectors.tags.coreElements.list,
94112
quantity: 4,
95113
});

angular-universal-ssr/e2e/tests/clientChecks.cy.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
import { BaseMethods } from '../../../playwright-e2e/common/base';
4+
import { baseSelectors, selectors, updatedSelectors } from '../../../cypress-e2e/common/selectors';
5+
import { Constants } from '../../../cypress-e2e/fixtures/constants';
6+
import { AngularUniversalSsrMethods } from '../methods/methods';
7+
8+
test.describe('Angular Universal SSR - Client App', () => {
9+
let basePage: BaseMethods;
10+
let methodsPage: AngularUniversalSsrMethods;
11+
12+
test.beforeEach(async ({ page }) => {
13+
basePage = new BaseMethods(page);
14+
methodsPage = new AngularUniversalSsrMethods(page);
15+
16+
await basePage.openLocalhost({ number: 3000 });
17+
});
18+
19+
test('Checks cities block visibility', async () => {
20+
await basePage.checkElementVisibility({
21+
selector: selectors.angularUniversalSsrApp.citiesBlock,
22+
});
23+
});
24+
25+
test('Checks cities block header visibility', async () => {
26+
await basePage.checkElementWithTextPresence({
27+
parentSelector: selectors.angularUniversalSsrApp.citiesBlock,
28+
selector: baseSelectors.tags.coreElements.div,
29+
text: Constants.commonPhrases.angularUniversalSsrApp.blockHeaderText,
30+
visibilityState: 'be.visible',
31+
});
32+
});
33+
34+
test('Checks base cities names visibility', async () => {
35+
await methodsPage.checkTextedElementsVisibility(
36+
Constants.elementsText.angularUniversalSsrApp.addedCities,
37+
updatedSelectors.angularUniversalSsrApp.addedCity,
38+
);
39+
});
40+
41+
test('Checks that both cities links can be clicked', async ({ page }) => {
42+
const locator = page.locator(updatedSelectors.angularUniversalSsrApp.addedCity);
43+
const count = await locator.count();
44+
expect(count).toBeGreaterThan(0);
45+
46+
for (let index = 0; index < count; index++) {
47+
await expect(locator.nth(index)).toBeEnabled();
48+
}
49+
});
50+
51+
test('Clicks on city by name and checks description with text appear', async () => {
52+
const cities = Constants.elementsText.angularUniversalSsrApp.addedCities;
53+
54+
for (let index = 0; index < cities.length; index++) {
55+
const city = cities[index];
56+
const expected = Constants.commonPhrases.angularUniversalSsrApp.selectedCityInfo[index];
57+
58+
await basePage.clickElementWithText({
59+
selector: updatedSelectors.angularUniversalSsrApp.addedCity,
60+
text: city,
61+
});
62+
63+
await basePage.checkElementWithTextPresence({
64+
selector: selectors.angularUniversalSsrApp.selectedCityInfo,
65+
text: expected,
66+
visibilityState: 'be.visible',
67+
});
68+
}
69+
});
70+
71+
test('Checks that selection of city info can be reverted after reload', async () => {
72+
await methodsPage.checkCitiesBlockFunctionality();
73+
});
74+
});

0 commit comments

Comments
 (0)