Skip to content

Commit 587ab25

Browse files
committed
test(rsc-mf): assert callback rebind when endpoint path changes
1 parent 34dc442 commit 587ab25

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ describe('registerRemoteServerCallback runtime behavior', () => {
9595
await expect(callback('abc 123', [])).rejects.toThrow(
9696
'Remote action id must be a non-empty token without whitespace',
9797
);
98+
await expect(callback(' ', [])).rejects.toThrow(
99+
'Remote action id must be a non-empty token without whitespace',
100+
);
98101
});
99102

100103
it('preserves already-prefixed action ids and dedupes normalized callback registrations', async () => {
@@ -202,6 +205,25 @@ describe('registerRemoteServerCallback runtime behavior', () => {
202205
);
203206
});
204207

208+
it('accepts token aliases with dot, underscore, and dash characters', async () => {
209+
const { registerRemoteServerCallback } = await importRegisterHelper();
210+
registerRemoteServerCallback(
211+
'http://127.0.0.1:3008/server-component-root',
212+
'remote.alias_v2-test',
213+
);
214+
215+
const callback = getRegisteredCallback();
216+
await callback('token-alias-action', []);
217+
expect(global.fetch).toHaveBeenCalledWith(
218+
'http://127.0.0.1:3008/server-component-root',
219+
expect.objectContaining({
220+
headers: expect.objectContaining({
221+
'x-rsc-action': 'remote:remote.alias_v2-test:token-alias-action',
222+
}),
223+
}),
224+
);
225+
});
226+
205227
it('ignores empty callback origins after trimming', async () => {
206228
const { registerRemoteServerCallback } = await importRegisterHelper();
207229
registerRemoteServerCallback(' ');

0 commit comments

Comments
 (0)