Skip to content

Commit f071c8d

Browse files
committed
test(rsc-mf): lock runtime callback initialization contract
1 parent 114deee commit f071c8d

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,25 +584,36 @@ function runTests({ mode }: TestConfig) {
584584
expect(runtimeInitSource).toContain('registerRemoteServerCallback');
585585
expect(runtimeInitSource).toContain('bootstrapServerCallback');
586586
expect(runtimeInitSource).toContain('callbackBootstrapPromise');
587+
expect(runtimeInitSource).toContain("if (typeof window !== 'undefined')");
587588
expect(runtimeInitSource).toContain("import('./registerServerCallback')");
589+
expect(runtimeInitSource).toContain('void bootstrapServerCallback()');
588590
expect(runtimeInitSource).toContain('window.location.origin');
589591
expect(runtimeInitSource).toContain('window.location.pathname');
590592
expect(runtimeInitSource).toContain('callbackBootstrapPromise.catch');
591593
expect(runtimeInitSource).toContain(
592594
'callbackBootstrapPromise = undefined',
593595
);
596+
expect(runtimeInitSource).not.toContain('setServerCallback(');
594597
expect(runtimeInitSource).not.toContain('RSC_MF_REMOTE_PORT');
595598
expect(runtimeInitSource).not.toContain('127.0.0.1:');
596599
expect(runtimeInitSource).not.toContain(
597600
"from './registerServerCallback'",
598601
);
599602
expect(runtimeRegisterSource).toContain('setServerCallback');
603+
expect(runtimeRegisterSource).toContain('createTemporaryReferenceSet');
604+
expect(runtimeRegisterSource).toContain(
605+
'encodeReply(args, { temporaryReferences })',
606+
);
607+
expect(runtimeRegisterSource).toContain(
608+
'createFromFetch(response, { temporaryReferences })',
609+
);
600610
expect(runtimeRegisterSource).toContain(
601611
"from 'rsc-mf-react-server-dom-client-browser'",
602612
);
603613
expect(runtimeRegisterSource).not.toContain(
604614
"from 'react-server-dom-rspack/client.browser'",
605615
);
616+
expect(runtimeRegisterSource).not.toContain('window.location');
606617
expect(runtimeRegisterSource).toContain("remoteAlias = 'rscRemote'");
607618
expect(runtimeRegisterSource).toContain(
608619
"if (rawActionId.startsWith('remote:'))",
@@ -681,6 +692,7 @@ function runTests({ mode }: TestConfig) {
681692
expect(hostModuleFederationConfigSource).toContain(
682693
'/static/mf-manifest.json',
683694
);
695+
expect(hostModuleFederationConfigSource).toContain('RSC_MF_REMOTE_PORT');
684696
expect(hostModuleFederationConfigSource).toContain('rscRemote:');
685697
expect(hostModuleFederationConfigSource).toContain('asyncStartup: true');
686698
expect(hostModuleFederationConfigSource).toContain('rsc: true');

0 commit comments

Comments
 (0)