|
| 1 | +import fs from 'fs'; |
1 | 2 | import path from 'path'; |
2 | 3 | import { isVersionAtLeast18 } from '@modern-js/utils'; |
3 | 4 | import type { Browser, Page } from 'puppeteer'; |
@@ -435,6 +436,30 @@ function runTests({ mode }: TestConfig) { |
435 | 436 | expect(exposedPaths).not.toContain('./registerServerCallback'); |
436 | 437 | }); |
437 | 438 |
|
| 439 | + it('should keep callback runtime wiring out of component sources', () => { |
| 440 | + const remoteClientCounterSource = fs.readFileSync( |
| 441 | + path.join(remoteDir, 'src/components/RemoteClientCounter.tsx'), |
| 442 | + 'utf-8', |
| 443 | + ); |
| 444 | + const remoteClientBadgeSource = fs.readFileSync( |
| 445 | + path.join(remoteDir, 'src/components/RemoteClientBadge.tsx'), |
| 446 | + 'utf-8', |
| 447 | + ); |
| 448 | + const runtimeInitSource = fs.readFileSync( |
| 449 | + path.join(remoteDir, 'src/runtime/initServerCallback.ts'), |
| 450 | + 'utf-8', |
| 451 | + ); |
| 452 | + expect(remoteClientCounterSource).not.toContain('initServerCallback'); |
| 453 | + expect(remoteClientCounterSource).not.toContain( |
| 454 | + 'registerRemoteServerCallback', |
| 455 | + ); |
| 456 | + expect(remoteClientBadgeSource).not.toContain('initServerCallback'); |
| 457 | + expect(remoteClientBadgeSource).not.toContain( |
| 458 | + 'registerRemoteServerCallback', |
| 459 | + ); |
| 460 | + expect(runtimeInitSource).toContain('registerRemoteServerCallback'); |
| 461 | + }); |
| 462 | + |
438 | 463 | it('should not load callback helper expose chunk', () => { |
439 | 464 | expect(registerCallbackExposeRequestUrls).toEqual([]); |
440 | 465 | }); |
|
0 commit comments