Skip to content

Commit cf1e7fb

Browse files
committed
test(rsc-mf): cover bundled nested and increment host actions
1 parent 99989e1 commit cf1e7fb

2 files changed

Lines changed: 44 additions & 12 deletions

File tree

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

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export default function HostRemoteActionRunner({
2020
const [echoResult, setEchoResult] = useState('');
2121
const [bundledDefaultResult, setBundledDefaultResult] = useState('');
2222
const [bundledEchoResult, setBundledEchoResult] = useState('');
23+
const [bundledNestedResult, setBundledNestedResult] = useState('');
24+
const [bundledIncrementResult, setBundledIncrementResult] = useState('');
2325
const [isPending, setIsPending] = useState(false);
2426

2527
useEffect(() => {
@@ -35,21 +37,36 @@ export default function HostRemoteActionRunner({
3537
const runActions = async () => {
3638
setIsPending(true);
3739
try {
38-
const [defaultValue, echoValue, bundledDefaultValue, bundledEchoValue] =
39-
await Promise.all([
40-
defaultRemoteAction('from-host-client'),
41-
remoteActionEcho('from-host-client'),
42-
remoteActionBundle.bundledDefaultRemoteAction(
43-
'from-host-client-bundled',
44-
),
45-
remoteActionBundle.bundledRemoteActionEcho(
46-
'from-host-client-bundled',
47-
),
48-
]);
40+
const bundledIncrementFormData = new FormData();
41+
bundledIncrementFormData.set('count', '1');
42+
const [
43+
defaultValue,
44+
echoValue,
45+
bundledDefaultValue,
46+
bundledEchoValue,
47+
bundledNestedValue,
48+
bundledIncrementValue,
49+
] = await Promise.all([
50+
defaultRemoteAction('from-host-client'),
51+
remoteActionEcho('from-host-client'),
52+
remoteActionBundle.bundledDefaultRemoteAction(
53+
'from-host-client-bundled',
54+
),
55+
remoteActionBundle.bundledRemoteActionEcho('from-host-client-bundled'),
56+
remoteActionBundle.bundledNestedRemoteAction(
57+
'from-host-client-bundled',
58+
),
59+
remoteActionBundle.bundledIncrementRemoteCount(
60+
0,
61+
bundledIncrementFormData,
62+
),
63+
]);
4964
setDefaultResult(defaultValue);
5065
setEchoResult(echoValue);
5166
setBundledDefaultResult(bundledDefaultValue);
5267
setBundledEchoResult(bundledEchoValue);
68+
setBundledNestedResult(bundledNestedValue);
69+
setBundledIncrementResult(String(bundledIncrementValue));
5370
} finally {
5471
setIsPending(false);
5572
}
@@ -74,6 +91,12 @@ export default function HostRemoteActionRunner({
7491
<p className="host-remote-bundled-echo-action-result">
7592
{bundledEchoResult}
7693
</p>
94+
<p className="host-remote-bundled-nested-action-result">
95+
{bundledNestedResult}
96+
</p>
97+
<p className="host-remote-bundled-increment-action-result">
98+
{bundledIncrementResult}
99+
</p>
77100
</div>
78101
);
79102
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ async function supportRemoteClientAndServerActions({
207207
const bundledEchoActionResult = document.querySelector(
208208
'.host-remote-bundled-echo-action-result',
209209
);
210+
const bundledNestedActionResult = document.querySelector(
211+
'.host-remote-bundled-nested-action-result',
212+
);
213+
const bundledIncrementActionResult = document.querySelector(
214+
'.host-remote-bundled-increment-action-result',
215+
);
210216
return (
211217
defaultActionResult?.textContent?.trim() ===
212218
'default-action:from-host-client' &&
@@ -215,7 +221,10 @@ async function supportRemoteClientAndServerActions({
215221
bundledDefaultActionResult?.textContent?.trim() ===
216222
'default-action:from-host-client-bundled' &&
217223
bundledEchoActionResult?.textContent?.trim() ===
218-
'remote-action:from-host-client-bundled'
224+
'remote-action:from-host-client-bundled' &&
225+
bundledNestedActionResult?.textContent?.trim() ===
226+
'nested-action:from-host-client-bundled' &&
227+
bundledIncrementActionResult?.textContent?.trim() === '2'
219228
);
220229
});
221230
}

0 commit comments

Comments
 (0)