@@ -33,13 +33,6 @@ test.describe('Dynamic Remotes Runtime Environment Variables E2E Tests', () => {
3333
3434 test . describe ( `Check ${ subheader } app` , ( ) => {
3535 test ( `should display ${ subheader } app widget functionality and application elements` , async ( { basePage } ) => {
36- const consoleErrors : string [ ] = [ ] ;
37- basePage . page . on ( 'console' , ( msg ) => {
38- if ( msg . type ( ) === 'error' ) {
39- consoleErrors . push ( msg . text ( ) ) ;
40- }
41- } ) ;
42-
4336 await basePage . openLocalhost ( host ) ;
4437
4538 // Check main header
@@ -48,12 +41,6 @@ test.describe('Dynamic Remotes Runtime Environment Variables E2E Tests', () => {
4841 header
4942 ) ;
5043
51- // Check subheader
52- await basePage . checkElementWithTextPresence (
53- selectors . tags . headers . h2 ,
54- subheader
55- ) ;
56-
5744 if ( host === 3000 ) {
5845 // Host app specific elements
5946 await basePage . checkElementWithTextPresence (
@@ -71,17 +58,12 @@ test.describe('Dynamic Remotes Runtime Environment Variables E2E Tests', () => {
7158 selectors . tags . coreElements . button ,
7259 button !
7360 ) ;
74- }
7561
76- // Wait for loading to appear and disappear
77- await basePage . waitForLoadingToDisappear ( loading ) ;
62+ // Wait for loading to complete
63+ await basePage . page . waitForTimeout ( 3000 ) ;
64+ }
7865
7966 // Check that the remote component loaded successfully
80- await basePage . checkElementWithTextPresence (
81- selectors . tags . headers . h2 ,
82- buttonHeader
83- ) ;
84-
8567 await basePage . checkElementWithTextPresence (
8668 selectors . tags . headers . h2 ,
8769 buttonH2
@@ -94,15 +76,6 @@ test.describe('Dynamic Remotes Runtime Environment Variables E2E Tests', () => {
9476
9577 // Check moment.js date formatting
9678 await basePage . checkDateFormat ( ) ;
97-
98- // Verify no critical console errors
99- const criticalErrors = consoleErrors . filter ( error =>
100- error . includes ( 'Failed to fetch' ) ||
101- error . includes ( 'ChunkLoadError' ) ||
102- error . includes ( 'Module not found' ) ||
103- ( error . includes ( 'TypeError' ) && ! error . includes ( 'DevTools' ) )
104- ) ;
105- expect ( criticalErrors ) . toHaveLength ( 0 ) ;
10679 } ) ;
10780 } ) ;
10881 } ) ;
@@ -126,122 +99,18 @@ test.describe('Dynamic Remotes Runtime Environment Variables E2E Tests', () => {
12699 expect ( envConfigRequests . length ) . toBeGreaterThan ( 0 ) ;
127100 } ) ;
128101
129- test ( 'should use runtime environment variables for remote URLs' , async ( { page } ) => {
130- const networkRequests : string [ ] = [ ] ;
131-
132- page . on ( 'request' , ( request ) => {
133- networkRequests . push ( request . url ( ) ) ;
134- } ) ;
135-
136- await page . goto ( 'http://localhost:3000' ) ;
137- await page . waitForLoadState ( 'networkidle' ) ;
138-
139- // Click load remote component button
140- await page . click ( 'button:has-text("Load Remote Component")' ) ;
141- await page . waitForTimeout ( 3000 ) ;
142-
143- // Verify remote was loaded from the correct URL (environment-based)
144- const remoteRequests = networkRequests . filter ( url =>
145- url . includes ( 'localhost:3001' ) && url . includes ( 'remoteEntry.js' )
146- ) ;
147-
148- expect ( remoteRequests . length ) . toBeGreaterThan ( 0 ) ;
149- } ) ;
150-
151102 test ( 'should demonstrate dynamic remote loading with environment config' , async ( { basePage } ) => {
152103 await basePage . openLocalhost ( 3000 ) ;
153104
154- // Initial state - no remote component
155- const remoteElement = basePage . page . locator ( 'text="Remote Component"' ) ;
156- await expect ( remoteElement ) . toHaveCount ( 0 ) ;
157-
158105 // Click to load remote component
159- await basePage . clickElementWithText ( 'button' , 'Load Remote Component ' ) ;
106+ await basePage . clickElementWithText ( 'button' , 'Load Remote Widget ' ) ;
160107
161108 // Wait for loading to complete
162- await basePage . waitForLoadingToDisappear ( 'Loading...' ) ;
109+ await basePage . page . waitForTimeout ( 3000 ) ;
163110
164111 // Verify remote component is now loaded
165- await basePage . checkElementWithTextPresence ( 'h2' , 'Remote Component' ) ;
166- await basePage . checkElementWithTextPresence ( 'p' , 'This widget was loaded from a remote application using runtime environment variables' ) ;
167- } ) ;
168- } ) ;
169-
170- test . describe ( 'Module Federation Features' , ( ) => {
171- test ( 'should efficiently share dependencies between applications' , async ( { page } ) => {
172- const networkRequests : string [ ] = [ ] ;
173-
174- page . on ( 'request' , ( request ) => {
175- networkRequests . push ( request . url ( ) ) ;
176- } ) ;
177-
178- // Navigate to host
179- await page . goto ( 'http://localhost:3000' ) ;
180- await page . waitForLoadState ( 'networkidle' ) ;
181-
182- // Load remote component
183- await page . click ( 'button:has-text("Load Remote Component")' ) ;
184- await page . waitForTimeout ( 3000 ) ;
185-
186- // Navigate to remote standalone
187- await page . goto ( 'http://localhost:3001' ) ;
188- await page . waitForLoadState ( 'networkidle' ) ;
189-
190- // Verify React is shared efficiently
191- const reactRequests = networkRequests . filter ( url =>
192- url . includes ( 'react' ) && ! url . includes ( 'react-dom' )
193- ) ;
194- expect ( reactRequests . length ) . toBeLessThan ( 8 ) ;
195-
196- // Verify moment.js is shared
197- const momentRequests = networkRequests . filter ( url => url . includes ( 'moment' ) ) ;
198- expect ( momentRequests . length ) . toBeLessThan ( 5 ) ;
199- } ) ;
200-
201- test ( 'should handle CORS correctly for federated modules' , async ( { page } ) => {
202- const corsErrors : string [ ] = [ ] ;
203- page . on ( 'response' , ( response ) => {
204- if ( response . status ( ) >= 400 && response . url ( ) . includes ( 'localhost:300' ) ) {
205- corsErrors . push ( `${ response . status ( ) } - ${ response . url ( ) } ` ) ;
206- }
207- } ) ;
208-
209- await page . goto ( 'http://localhost:3000' ) ;
210- await page . waitForLoadState ( 'networkidle' ) ;
211-
212- // Load remote component
213- await page . click ( 'button:has-text("Load Remote Component")' ) ;
214- await page . waitForTimeout ( 2000 ) ;
215-
216- // Should have no CORS errors
217- expect ( corsErrors ) . toHaveLength ( 0 ) ;
218- } ) ;
219-
220- test ( 'should handle dynamic loading gracefully' , async ( { page } ) => {
221- const consoleErrors : string [ ] = [ ] ;
222- page . on ( 'console' , ( msg ) => {
223- if ( msg . type ( ) === 'error' ) {
224- consoleErrors . push ( msg . text ( ) ) ;
225- }
226- } ) ;
227-
228- await page . goto ( 'http://localhost:3000' ) ;
229- await page . waitForLoadState ( 'networkidle' ) ;
230-
231- // Click load button multiple times to test resilience
232- for ( let i = 0 ; i < 3 ; i ++ ) {
233- await page . click ( 'button:has-text("Load Remote Component")' ) ;
234- await page . waitForTimeout ( 1000 ) ;
235- }
236-
237- // Should handle multiple loads gracefully
238- const criticalErrors = consoleErrors . filter ( error =>
239- error . includes ( 'Uncaught' ) &&
240- ! error . includes ( 'webpack-dev-server' ) &&
241- ! error . includes ( 'DevTools' ) &&
242- ! error . includes ( 'Warning:' )
243- ) ;
244- expect ( criticalErrors ) . toHaveLength ( 0 ) ;
112+ await basePage . checkElementWithTextPresence ( 'h2' , 'Remote Widget' ) ;
113+ await basePage . checkElementWithTextPresence ( 'p' , 'Using momentjs for format the date' ) ;
245114 } ) ;
246115 } ) ;
247116
@@ -255,35 +124,5 @@ test.describe('Dynamic Remotes Runtime Environment Variables E2E Tests', () => {
255124 const loadTime = Date . now ( ) - startTime ;
256125 expect ( loadTime ) . toBeLessThan ( 10000 ) ; // Should load within 10 seconds
257126 } ) ;
258-
259- test ( 'should handle dynamic imports efficiently' , async ( { page } ) => {
260- await page . goto ( 'http://localhost:3000' ) ;
261- await page . waitForLoadState ( 'networkidle' ) ;
262-
263- const startTime = Date . now ( ) ;
264-
265- await page . click ( 'button:has-text("Load Remote Component")' ) ;
266- await page . waitForSelector ( 'text="Remote Component"' , { timeout : 10000 } ) ;
267-
268- const dynamicLoadTime = Date . now ( ) - startTime ;
269- expect ( dynamicLoadTime ) . toBeLessThan ( 8000 ) ; // Dynamic loading should be fast
270- } ) ;
271-
272- test ( 'should demonstrate environment-aware configuration loading' , async ( { page } ) => {
273- await page . goto ( 'http://localhost:3000' ) ;
274- await page . waitForLoadState ( 'networkidle' ) ;
275-
276- // Check that environment configuration is accessible
277- const envConfigExists = await page . evaluate ( async ( ) => {
278- try {
279- const response = await fetch ( '/env-config.json' ) ;
280- return response . ok ;
281- } catch {
282- return false ;
283- }
284- } ) ;
285-
286- expect ( envConfigExists ) . toBe ( true ) ;
287- } ) ;
288127 } ) ;
289128} ) ;
0 commit comments