Skip to content

Commit 790f315

Browse files
committed
test(rsc-mf): assert callback wiring stays in runtime modules
1 parent a86f3b5 commit 790f315

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/integration/rsc-mf/tests/index.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fs from 'fs';
12
import path from 'path';
23
import { isVersionAtLeast18 } from '@modern-js/utils';
34
import type { Browser, Page } from 'puppeteer';
@@ -435,6 +436,30 @@ function runTests({ mode }: TestConfig) {
435436
expect(exposedPaths).not.toContain('./registerServerCallback');
436437
});
437438

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+
438463
it('should not load callback helper expose chunk', () => {
439464
expect(registerCallbackExposeRequestUrls).toEqual([]);
440465
});

0 commit comments

Comments
 (0)