Skip to content

Commit 7483029

Browse files
committed
test(rsc-mf): assert request coverage across action families
1 parent ee24d53 commit 7483029

2 files changed

Lines changed: 128 additions & 0 deletions

File tree

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ const App = () => {
5656
new Set(hostProxyActionIds),
5757
).sort();
5858
const uniqueHostProxyActionIdsCount = uniqueHostProxyActionIds.length;
59+
const incrementProxyActionIds = Array.from(
60+
new Set(
61+
[proxyIncrementRemoteCount, proxyBundledIncrementRemoteCount]
62+
.map(action => getServerActionId(action))
63+
.filter((actionId): actionId is string => Boolean(actionId)),
64+
),
65+
).sort();
66+
const echoProxyActionIds = Array.from(
67+
new Set(
68+
[proxyRemoteActionEcho, proxyBundledRemoteActionEcho]
69+
.map(action => getServerActionId(action))
70+
.filter((actionId): actionId is string => Boolean(actionId)),
71+
),
72+
).sort();
73+
const nestedProxyActionIds = Array.from(
74+
new Set(
75+
[proxyNestedRemoteAction, proxyBundledNestedRemoteAction]
76+
.map(action => getServerActionId(action))
77+
.filter((actionId): actionId is string => Boolean(actionId)),
78+
),
79+
).sort();
80+
const defaultProxyActionIds = Array.from(
81+
new Set(
82+
[proxyDefaultRemoteAction, proxyBundledDefaultRemoteAction]
83+
.map(action => getServerActionId(action))
84+
.filter((actionId): actionId is string => Boolean(actionId)),
85+
),
86+
).sort();
5987

6088
// Map remote action IDs to host-local proxy action IDs so client-side
6189
// callbacks can always post a host-resolvable action id. This keeps
@@ -177,6 +205,18 @@ const App = () => {
177205
<p className="host-bundled-proxy-action-ids">
178206
{bundledHostProxyActionIds.join(',')}
179207
</p>
208+
<p className="host-increment-proxy-action-ids">
209+
{incrementProxyActionIds.join(',')}
210+
</p>
211+
<p className="host-echo-proxy-action-ids">
212+
{echoProxyActionIds.join(',')}
213+
</p>
214+
<p className="host-nested-proxy-action-ids">
215+
{nestedProxyActionIds.join(',')}
216+
</p>
217+
<p className="host-default-proxy-action-ids">
218+
{defaultProxyActionIds.join(',')}
219+
</p>
180220
<Suspense fallback={<div>Loading Remote Async Server Info...</div>}>
181221
<AsyncRemoteServerInfo />
182222
</Suspense>

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

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ async function renderRemoteRscIntoHost({ hostPort, page }: TestContext) {
7474
expect(html).toContain('host-proxy-action-ids');
7575
expect(html).toContain('host-direct-proxy-action-ids');
7676
expect(html).toContain('host-bundled-proxy-action-ids');
77+
expect(html).toContain('host-increment-proxy-action-ids');
78+
expect(html).toContain('host-echo-proxy-action-ids');
79+
expect(html).toContain('host-nested-proxy-action-ids');
80+
expect(html).toContain('host-default-proxy-action-ids');
7781

7882
await page.goto(`http://127.0.0.1:${hostPort}${HOST_RSC_URL}`, {
7983
waitUntil: ['networkidle0', 'domcontentloaded'],
@@ -201,6 +205,38 @@ async function renderRemoteRscIntoHost({ hostPort, page }: TestContext) {
201205
?.split(',')
202206
.filter(Boolean) as string[];
203207
expect(hostBundledProxyActionIdList.length).toBe(4);
208+
const hostIncrementProxyActionIds = await page.$eval(
209+
'.host-increment-proxy-action-ids',
210+
el => el.textContent?.trim(),
211+
);
212+
const hostIncrementProxyActionIdList = hostIncrementProxyActionIds
213+
?.split(',')
214+
.filter(Boolean) as string[];
215+
expect(hostIncrementProxyActionIdList.length).toBeGreaterThan(0);
216+
const hostEchoProxyActionIds = await page.$eval(
217+
'.host-echo-proxy-action-ids',
218+
el => el.textContent?.trim(),
219+
);
220+
const hostEchoProxyActionIdList = hostEchoProxyActionIds
221+
?.split(',')
222+
.filter(Boolean) as string[];
223+
expect(hostEchoProxyActionIdList.length).toBeGreaterThan(0);
224+
const hostNestedProxyActionIds = await page.$eval(
225+
'.host-nested-proxy-action-ids',
226+
el => el.textContent?.trim(),
227+
);
228+
const hostNestedProxyActionIdList = hostNestedProxyActionIds
229+
?.split(',')
230+
.filter(Boolean) as string[];
231+
expect(hostNestedProxyActionIdList.length).toBeGreaterThan(0);
232+
const hostDefaultProxyActionIds = await page.$eval(
233+
'.host-default-proxy-action-ids',
234+
el => el.textContent?.trim(),
235+
);
236+
const hostDefaultProxyActionIdList = hostDefaultProxyActionIds
237+
?.split(',')
238+
.filter(Boolean) as string[];
239+
expect(hostDefaultProxyActionIdList.length).toBeGreaterThan(0);
204240
const groupedProxyActionIdUnion = new Set([
205241
...hostDirectProxyActionIdList,
206242
...hostBundledProxyActionIdList,
@@ -515,10 +551,62 @@ function runTests({ mode }: TestConfig) {
515551
const usesBundledProxyIds = actionRequestIds.some(id =>
516552
bundledProxyActionIdSet.has(id),
517553
);
554+
const incrementProxyActionIdSet = new Set(
555+
(
556+
await page.$eval(
557+
'.host-increment-proxy-action-ids',
558+
el => el.textContent || '',
559+
)
560+
)
561+
.split(',')
562+
.filter(Boolean),
563+
);
564+
const echoProxyActionIdSet = new Set(
565+
(
566+
await page.$eval(
567+
'.host-echo-proxy-action-ids',
568+
el => el.textContent || '',
569+
)
570+
)
571+
.split(',')
572+
.filter(Boolean),
573+
);
574+
const nestedProxyActionIdSet = new Set(
575+
(
576+
await page.$eval(
577+
'.host-nested-proxy-action-ids',
578+
el => el.textContent || '',
579+
)
580+
)
581+
.split(',')
582+
.filter(Boolean),
583+
);
584+
const defaultProxyActionIdSet = new Set(
585+
(
586+
await page.$eval(
587+
'.host-default-proxy-action-ids',
588+
el => el.textContent || '',
589+
)
590+
)
591+
.split(',')
592+
.filter(Boolean),
593+
);
518594
expect(usesDirectProxyIds || usesBundledProxyIds).toBe(true);
519595
if (!usesDirectProxyIds || !usesBundledProxyIds) {
520596
expect(hostProxyMapCollisionCount).toBeGreaterThan(0);
521597
}
598+
expect(
599+
actionRequestIds.some(id => incrementProxyActionIdSet.has(id)),
600+
).toBe(true);
601+
expect(actionRequestIds.some(id => echoProxyActionIdSet.has(id))).toBe(
602+
true,
603+
);
604+
expect(actionRequestIds.some(id => nestedProxyActionIdSet.has(id))).toBe(
605+
true,
606+
);
607+
expect(actionRequestIds.some(id => defaultProxyActionIdSet.has(id))).toBe(
608+
true,
609+
);
522610
expect(
523611
actionRequestIds.every(
524612
id =>

0 commit comments

Comments
 (0)