Skip to content

Commit 7dde578

Browse files
committed
test(rsc-mf): validate manifest expose set is userland subset
1 parent 347d204 commit 7dde578

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ const HOST_RSC_URL = '/server-component-root';
2020
const EXPECTED_ACTION_POSTS_PER_MODE = 24;
2121
const EXPECTED_ACTION_POSTS_PER_FAMILY = 6;
2222
const EXPECTED_UNIQUE_ACTION_IDS_PER_MODE = 4;
23+
const EXPECTED_REMOTE_EXPOSE_PATHS = [
24+
'./RemoteClientCounter',
25+
'./RemoteClientBadge',
26+
'./RemoteServerCard',
27+
'./RemoteServerDefault',
28+
'./AsyncRemoteServerInfo',
29+
'./remoteServerOnly',
30+
'./remoteServerOnlyDefault',
31+
'./remoteMeta',
32+
'./actions',
33+
'./nestedActions',
34+
'./defaultAction',
35+
'./actionBundle',
36+
'./infoBundle',
37+
].sort();
2338

2439
type Mode = 'dev' | 'build';
2540

@@ -433,10 +448,24 @@ function runTests({ mode }: TestConfig) {
433448
const exposedPaths = (manifest.exposes || [])
434449
.map(item => item.path)
435450
.filter((path): path is string => Boolean(path));
451+
const uniqueExposedPaths = Array.from(new Set(exposedPaths)).sort();
436452
expect(exposedPaths).not.toContain('./registerServerCallback');
453+
expect(uniqueExposedPaths.length).toBeGreaterThan(0);
454+
expect(uniqueExposedPaths).toContain('./RemoteClientCounter');
455+
expect(
456+
uniqueExposedPaths.every(path =>
457+
EXPECTED_REMOTE_EXPOSE_PATHS.includes(path),
458+
),
459+
).toBe(true);
460+
expect(uniqueExposedPaths.length).toBeLessThanOrEqual(
461+
EXPECTED_REMOTE_EXPOSE_PATHS.length,
462+
);
437463
expect(
438464
exposedPaths.every(path => !path.startsWith('./src/components/')),
439465
).toBe(true);
466+
expect(
467+
exposedPaths.every(path => !path.includes('initServerCallback')),
468+
).toBe(true);
440469
});
441470

442471
it('should keep callback runtime wiring out of component sources', () => {

0 commit comments

Comments
 (0)