Skip to content

Commit 6638c75

Browse files
committed
test(rsc-mf): cover action-id normalization and empty-origin skip
1 parent 9cd4ad0 commit 6638c75

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,26 @@ describe('registerRemoteServerCallback runtime behavior', () => {
7777
expect(mockCreateFromFetch).toHaveBeenCalledTimes(1);
7878
});
7979

80+
it('normalizes action ids and rejects whitespace-delimited ids', async () => {
81+
const { registerRemoteServerCallback } = await importRegisterHelper();
82+
registerRemoteServerCallback('http://127.0.0.1:3008/server-component-root');
83+
84+
const callback = getRegisteredCallback();
85+
await callback(' abc123 ', []);
86+
expect(global.fetch).toHaveBeenCalledWith(
87+
'http://127.0.0.1:3008/server-component-root',
88+
expect.objectContaining({
89+
headers: expect.objectContaining({
90+
'x-rsc-action': 'remote:rscRemote:abc123',
91+
}),
92+
}),
93+
);
94+
95+
await expect(callback('abc 123', [])).rejects.toThrow(
96+
'Remote action id must be a non-empty token without whitespace',
97+
);
98+
});
99+
80100
it('preserves already-prefixed action ids and dedupes normalized callback registrations', async () => {
81101
const { registerRemoteServerCallback } = await importRegisterHelper();
82102
registerRemoteServerCallback(
@@ -102,6 +122,12 @@ describe('registerRemoteServerCallback runtime behavior', () => {
102122
);
103123
});
104124

125+
it('ignores empty callback origins after trimming', async () => {
126+
const { registerRemoteServerCallback } = await importRegisterHelper();
127+
registerRemoteServerCallback(' ');
128+
expect(mockSetServerCallback).not.toHaveBeenCalled();
129+
});
130+
105131
it('rejects invalid aliases and callback URLs', async () => {
106132
const { registerRemoteServerCallback } = await importRegisterHelper();
107133

0 commit comments

Comments
 (0)