Skip to content

Commit 7b7be59

Browse files
fix: resolve all Playwright test failures in advanced-api examples
- Fix Playwright test import conflicts across all examples - Use standard @playwright/test imports instead of custom extended test - Export BasePage class and instantiate it properly in tests - Prevents "test.describe() called in unexpected place" errors - Update test expectations to match modernized app content: - automatic-vendor-sharing: Update header text to match actual app content - dynamic-remotes-synchronous-imports: Include emoji in header text - Update app names to match full displayed text - All tests now properly handle the BasePage pattern - Test content expectations now match the actual modernized applications 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 0ccedc0 commit 7b7be59

File tree

7 files changed

+41
-24
lines changed

7 files changed

+41
-24
lines changed

advanced-api/automatic-vendor-sharing/e2e/checkAutomaticVendorApps.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { test, expect } from './utils/base-test';
1+
import { test, expect } from '@playwright/test';
2+
import { BasePage } from './utils/base-test';
23
import { selectors } from './utils/selectors';
34
import { Constants } from './utils/constants';
45

@@ -29,7 +30,8 @@ test.describe('Automatic Vendor Sharing E2E Tests', () => {
2930
const { host, appNameText, headerText, buttonColor } = appData;
3031

3132
test.describe(`Check ${appNameText}`, () => {
32-
test(`should display ${appNameText} header and subheader correctly`, async ({ basePage }) => {
33+
test(`should display ${appNameText} header and subheader correctly`, async ({ page }) => {
34+
const basePage = new BasePage(page);
3335
const consoleErrors: string[] = [];
3436
basePage.page.on('console', (msg) => {
3537
if (msg.type() === 'error') {
@@ -59,7 +61,8 @@ test.describe('Automatic Vendor Sharing E2E Tests', () => {
5961
expect(criticalErrors).toHaveLength(0);
6062
});
6163

62-
test(`should display ${appNameText} button correctly`, async ({ basePage }) => {
64+
test(`should display ${appNameText} button correctly`, async ({ page }) => {
65+
const basePage = new BasePage(page);
6366
await basePage.openLocalhost(host);
6467

6568
const buttonText = `${appNameText} ${Constants.commonConstantsData.button}`;
@@ -71,7 +74,8 @@ test.describe('Automatic Vendor Sharing E2E Tests', () => {
7174
);
7275
});
7376

74-
test(`should have correct button styling in ${appNameText}`, async ({ basePage }) => {
77+
test(`should have correct button styling in ${appNameText}`, async ({ page }) => {
78+
const basePage = new BasePage(page);
7579
await basePage.openLocalhost(host);
7680

7781
const buttonText = `${appNameText} ${Constants.commonConstantsData.button}`;
@@ -82,7 +86,8 @@ test.describe('Automatic Vendor Sharing E2E Tests', () => {
8286
await basePage.checkElementBackgroundColor(buttonSelector, buttonColor);
8387
});
8488

85-
test(`should handle ${appNameText} button interactions`, async ({ basePage }) => {
89+
test(`should handle ${appNameText} button interactions`, async ({ page }) => {
90+
const basePage = new BasePage(page);
8691
await basePage.openLocalhost(host);
8792

8893
const buttonText = `${appNameText} ${Constants.commonConstantsData.button}`;

advanced-api/automatic-vendor-sharing/e2e/utils/base-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test as base, Page } from '@playwright/test';
22

3-
class BasePage {
3+
export class BasePage {
44
constructor(public page: Page) {}
55

66
async openLocalhost(port: number) {

advanced-api/automatic-vendor-sharing/e2e/utils/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
export const Constants = {
22
commonConstantsData: {
3-
biDirectional: 'Bi-Directional',
3+
biDirectional: 'Module Federation with Automatic Vendor Sharing',
44
button: 'Button',
55
commonCountAppNames: {
6-
app1: 'App 1',
7-
app2: 'App 2',
6+
app1: 'App 1 (Host & Remote)',
7+
app2: 'App 2 (Host & Remote)',
88
},
99
},
1010
color: {

advanced-api/dynamic-remotes-synchronous-imports/e2e/checkDynamicRemotesSynchImportApps.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { test, expect } from './utils/base-test';
1+
import { test, expect } from '@playwright/test';
2+
import { BasePage } from './utils/base-test';
23
import { selectors } from './utils/selectors';
34
import { Constants } from './utils/constants';
45

@@ -35,7 +36,8 @@ test.describe('Dynamic Remotes Synchronous Imports E2E Tests', () => {
3536
const { host, appNameText, headerText, widgetName, widgetParagraph, widgetColor, widgetIndexNumber, isTwoWidgets } = appData;
3637

3738
test.describe(`Check ${appNameText}`, () => {
38-
test(`should display ${appNameText} elements correctly`, async ({ basePage }) => {
39+
test(`should display ${appNameText} elements correctly`, async ({ page }) => {
40+
const basePage = new BasePage(page);
3941
const consoleErrors: string[] = [];
4042
basePage.page.on('console', (msg) => {
4143
if (msg.type() === 'error') {
@@ -65,7 +67,8 @@ test.describe('Dynamic Remotes Synchronous Imports E2E Tests', () => {
6567
expect(criticalErrors).toHaveLength(0);
6668
});
6769

68-
test(`should display widgets correctly in ${appNameText}`, async ({ basePage }) => {
70+
test(`should display widgets correctly in ${appNameText}`, async ({ page }) => {
71+
const basePage = new BasePage(page);
6972
await basePage.openLocalhost(host);
7073

7174
if (isTwoWidgets) {
@@ -230,7 +233,8 @@ test.describe('Dynamic Remotes Synchronous Imports E2E Tests', () => {
230233
expect(corsErrors).toHaveLength(0);
231234
});
232235

233-
test('should demonstrate moment.js sharing', async ({ basePage }) => {
236+
test('should demonstrate moment.js sharing', async ({ page }) => {
237+
const basePage = new BasePage(page);
234238
await basePage.openLocalhost(3001);
235239

236240
// Check that moment.js date is formatted correctly in both widgets

advanced-api/dynamic-remotes-synchronous-imports/e2e/utils/base-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test as base, Page } from '@playwright/test';
22

3-
class BasePage {
3+
export class BasePage {
44
constructor(public page: Page) {}
55

66
async openLocalhost(port: number) {

advanced-api/dynamic-remotes-synchronous-imports/e2e/utils/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
export const Constants = {
22
elementsText: {
33
dynamicRemotesApp: {
4-
header: 'Dynamic System Host',
4+
header: '🌐 Dynamic System Host',
55
synchronousImportWidgetsNames: ['App 1 Widget', 'App 2 Widget'],
66
},
77
},
88
commonConstantsData: {
99
commonCountAppNames: {
10-
app1: 'App 1',
10+
app1: 'App 1 - Demonstrating Synchronous Imports with Dynamic Remotes',
1111
app2: 'App 2',
1212
},
1313
},

advanced-api/dynamic-remotes/e2e/checkDynamicRemotesApps.spec.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { test, expect } from './utils/base-test';
1+
import { test, expect } from '@playwright/test';
2+
import { BasePage } from './utils/base-test';
23
import { selectors } from './utils/selectors';
34
import { Constants } from './utils/constants';
45

56
test.describe('Dynamic Remotes E2E Tests', () => {
67

78
test.describe('Host Application (App 1)', () => {
8-
test('should display host application elements correctly', async ({ basePage }) => {
9+
test('should display host application elements correctly', async ({ page }) => {
10+
const basePage = new BasePage(page);
911
const consoleErrors: string[] = [];
1012
basePage.page.on('console', (msg) => {
1113
if (msg.type() === 'error') {
@@ -33,7 +35,8 @@ test.describe('Dynamic Remotes E2E Tests', () => {
3335
expect(criticalErrors).toHaveLength(0);
3436
});
3537

36-
test('should dynamically load App 2 widget successfully', async ({ basePage }) => {
38+
test('should dynamically load App 2 widget successfully', async ({ page }) => {
39+
const basePage = new BasePage(page);
3740
const consoleErrors: string[] = [];
3841
basePage.page.on('console', (msg) => {
3942
if (msg.type() === 'error') {
@@ -63,7 +66,8 @@ test.describe('Dynamic Remotes E2E Tests', () => {
6366
expect(moduleErrors).toHaveLength(0);
6467
});
6568

66-
test('should dynamically load App 3 widget successfully', async ({ basePage }) => {
69+
test('should dynamically load App 3 widget successfully', async ({ page }) => {
70+
const basePage = new BasePage(page);
6771
const consoleErrors: string[] = [];
6872
basePage.page.on('console', (msg) => {
6973
if (msg.type() === 'error') {
@@ -93,7 +97,8 @@ test.describe('Dynamic Remotes E2E Tests', () => {
9397
expect(moduleErrors).toHaveLength(0);
9498
});
9599

96-
test('should handle sequential loading of both widgets', async ({ basePage }) => {
100+
test('should handle sequential loading of both widgets', async ({ page }) => {
101+
const basePage = new BasePage(page);
97102
await basePage.openLocalhost(3001);
98103

99104
// Load App 2 widget first
@@ -116,7 +121,8 @@ test.describe('Dynamic Remotes E2E Tests', () => {
116121
// rather than accumulating, so we verify the latest widget is visible
117122
});
118123

119-
test('should show loading states and handle errors gracefully', async ({ basePage }) => {
124+
test('should show loading states and handle errors gracefully', async ({ page }) => {
125+
const basePage = new BasePage(page);
120126
await basePage.openLocalhost(3001);
121127

122128
// Check that buttons are initially enabled
@@ -130,7 +136,8 @@ test.describe('Dynamic Remotes E2E Tests', () => {
130136
});
131137

132138
test.describe('Remote Application - App 2', () => {
133-
test('should display App 2 standalone correctly', async ({ basePage }) => {
139+
test('should display App 2 standalone correctly', async ({ page }) => {
140+
const basePage = new BasePage(page);
134141
const consoleErrors: string[] = [];
135142
basePage.page.on('console', (msg) => {
136143
if (msg.type() === 'error') {
@@ -161,7 +168,8 @@ test.describe('Dynamic Remotes E2E Tests', () => {
161168
});
162169

163170
test.describe('Remote Application - App 3', () => {
164-
test('should display App 3 standalone correctly', async ({ basePage }) => {
171+
test('should display App 3 standalone correctly', async ({ page }) => {
172+
const basePage = new BasePage(page);
165173
const consoleErrors: string[] = [];
166174
basePage.page.on('console', (msg) => {
167175
if (msg.type() === 'error') {

0 commit comments

Comments
 (0)