Skip to content

Commit d806ec0

Browse files
committed
test(rsc-mf): assert proxy map entry count aligns with ids
1 parent 225df15 commit d806ec0

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

tests/integration/rsc-mf/host/src/server-component-root/App.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ const App = () => {
101101
);
102102
const remoteActionIdMapEntryCount =
103103
remoteActionIdToHostProxyActionEntries.length;
104+
const mappedHostProxyActionIds = Array.from(
105+
new Set(remoteActionIdToHostProxyActionEntries.map(([, hostId]) => hostId)),
106+
).sort();
107+
const doesMappingCoverAllHostProxyActions =
108+
mappedHostProxyActionIds.length === uniqueHostProxyActionIds.length &&
109+
mappedHostProxyActionIds.every(
110+
(actionId, index) => actionId === uniqueHostProxyActionIds[index],
111+
);
104112

105113
const remoteServerOnlyInfo = getServerOnlyInfo();
106114
const remoteServerOnlyDefaultInfo = getServerOnlyDefaultInfo();
@@ -133,6 +141,12 @@ const App = () => {
133141
<p className="host-proxy-map-entry-count">
134142
{remoteActionIdMapEntryCount}
135143
</p>
144+
<p className="host-mapped-proxy-action-ids">
145+
{mappedHostProxyActionIds.join(',')}
146+
</p>
147+
<p className="host-proxy-map-covers-all">
148+
{String(doesMappingCoverAllHostProxyActions)}
149+
</p>
136150
<p className="host-proxy-action-ids">
137151
{uniqueHostProxyActionIds.join(',')}
138152
</p>

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ async function renderRemoteRscIntoHost({ hostPort, page }: TestContext) {
6666
expect(html).toContain('host-remote-bundled-meta-kind');
6767
expect(html).toContain('host-proxy-action-id-count');
6868
expect(html).toContain('host-proxy-map-entry-count');
69+
expect(html).toContain('host-mapped-proxy-action-ids');
70+
expect(html).toContain('host-proxy-map-covers-all');
6971
expect(html).toContain('host-proxy-action-ids');
7072
expect(html).toContain('host-direct-proxy-action-ids');
7173
expect(html).toContain('host-bundled-proxy-action-ids');
@@ -123,6 +125,19 @@ async function renderRemoteRscIntoHost({ hostPort, page }: TestContext) {
123125
el => el.textContent?.trim(),
124126
);
125127
expect(hostProxyMapEntryCount).toBe('8');
128+
const hostMappedProxyActionIds = await page.$eval(
129+
'.host-mapped-proxy-action-ids',
130+
el => el.textContent?.trim(),
131+
);
132+
const hostMappedProxyActionIdList = hostMappedProxyActionIds
133+
?.split(',')
134+
.filter(Boolean) as string[];
135+
expect(hostMappedProxyActionIdList.length).toBe(8);
136+
const hostProxyMapCoversAll = await page.$eval(
137+
'.host-proxy-map-covers-all',
138+
el => el.textContent?.trim(),
139+
);
140+
expect(hostProxyMapCoversAll).toBe('true');
126141
const hostProxyActionIds = await page.$eval('.host-proxy-action-ids', el =>
127142
el.textContent?.trim(),
128143
);
@@ -135,6 +150,9 @@ async function renderRemoteRscIntoHost({ hostPort, page }: TestContext) {
135150
expect(hostProxyActionIdList.every(id => /^[a-f0-9]{64,}$/i.test(id))).toBe(
136151
true,
137152
);
153+
expect(
154+
hostMappedProxyActionIdList.every(id => hostProxyActionIdList.includes(id)),
155+
).toBe(true);
138156
const hostDirectProxyActionIds = await page.$eval(
139157
'.host-direct-proxy-action-ids',
140158
el => el.textContent?.trim(),
@@ -397,6 +415,19 @@ function runTests({ mode }: TestConfig) {
397415
expect(actionRequestIds.every(id => hostProxyActionIdSet.has(id))).toBe(
398416
true,
399417
);
418+
const mappedProxyActionIdSet = new Set(
419+
(
420+
await page.$eval(
421+
'.host-mapped-proxy-action-ids',
422+
el => el.textContent || '',
423+
)
424+
)
425+
.split(',')
426+
.filter(Boolean),
427+
);
428+
expect(actionRequestIds.every(id => mappedProxyActionIdSet.has(id))).toBe(
429+
true,
430+
);
400431
const directProxyActionIdSet = new Set(
401432
(
402433
await page.$eval(

0 commit comments

Comments
 (0)