@@ -4,18 +4,19 @@ import { expect, test } from '@playwright/test';
44
55// The `db.test.ts` runtime assertions prove orchestrion spans appear, but spans alone
66// don't prove they came from the BUILD-time transform: if the Vite plugin silently
7- // failed to load, the deps would stay external and the runtime `--import ` hook would
7+ // failed to load, the deps would stay external and the runtime `--require ` hook would
88// inject the channels at runtime instead - the span tests would still pass. These
99// assertions inspect the built server bundle directly so a broken plugin can't hide
10- // behind that runtime fallback.
10+ // behind that runtime fallback. Only relevant in the orchestrion variant.
1111test . describe ( 'orchestrion build-time injection' , ( ) => {
12+ test . skip ( process . env . INJECT_ORCHESTRION !== 'true' , 'Only runs in the orchestrion variant' ) ;
13+
1214 const serverBundle = readFileSync ( path . join ( process . cwd ( ) , 'build/server/index.js' ) , 'utf8' ) ;
1315
1416 test ( 'force-bundles the instrumented deps instead of externalizing them' , ( ) => {
1517 // The plugin adds mysql/ioredis to `ssr.noExternal` so the transform sees their
16- // source. Without it they'd be left as bare imports (this is an ESM server build)
17- // or `require(...)` calls resolved from node_modules at runtime - untouched, with
18- // no channels injected.
18+ // source. Without it they'd be left as bare imports or `require(...)` calls resolved
19+ // from node_modules at runtime - untouched, with no channels injected.
1920 expect ( serverBundle ) . not . toMatch ( / ( f r o m \s * [ " ' ] m y s q l [ " ' ] | r e q u i r e \( [ " ' ] m y s q l [ " ' ] \) ) / ) ;
2021 expect ( serverBundle ) . not . toMatch ( / ( f r o m \s * [ " ' ] i o r e d i s [ " ' ] | r e q u i r e \( [ " ' ] i o r e d i s [ " ' ] \) ) / ) ;
2122 } ) ;
@@ -25,8 +26,20 @@ test.describe('orchestrion build-time injection', () => {
2526 // publisher whose channel name is a string literal. The subscriber side passes the
2627 // channel name as a variable, so a literal-arg match is unique to the injected
2728 // publisher and proves the build-time transform ran.
28- expect ( serverBundle ) . toMatch ( / t r a c i n g C h a n n e l \( [ " ' ] o r c h e s t r i o n : m y s q l : q u e r y [ " ' ] \) / ) ;
29- expect ( serverBundle ) . toMatch ( / t r a c i n g C h a n n e l \( [ " ' ] o r c h e s t r i o n : i o r e d i s : c o m m a n d [ " ' ] \) / ) ;
30- expect ( serverBundle ) . toMatch ( / t r a c i n g C h a n n e l \( [ " ' ] o r c h e s t r i o n : i o r e d i s : c o n n e c t [ " ' ] \) / ) ;
29+ expect ( serverBundle ) . toMatch ( / t r a c i n g C h a n n e l ( \$ ? \d ) ? \( [ " ' ] o r c h e s t r i o n : m y s q l : q u e r y [ " ' ] \) / ) ;
30+ expect ( serverBundle ) . toMatch ( / t r a c i n g C h a n n e l ( \$ ? \d ) ? \( [ " ' ] o r c h e s t r i o n : i o r e d i s : c o m m a n d [ " ' ] \) / ) ;
31+ expect ( serverBundle ) . toMatch ( / t r a c i n g C h a n n e l ( \$ ? \d ) ? \( [ " ' ] o r c h e s t r i o n : i o r e d i s : c o n n e c t [ " ' ] \) / ) ;
32+ } ) ;
33+
34+ test ( 'injects the diagnostics-channel publishers into @remix-run/server-runtime' , ( ) => {
35+ // Remix's own instrumentation is orchestrion-based too: the transform force-bundles
36+ // and injects channels into `@remix-run/server-runtime` (the subscriber is
37+ // `remixChannelIntegration`).
38+ expect ( serverBundle ) . toMatch (
39+ / t r a c i n g C h a n n e l ( \$ ? \d ) ? \( [ " ' ] o r c h e s t r i o n : @ r e m i x - r u n \/ s e r v e r - r u n t i m e : r e q u e s t H a n d l e r [ " ' ] \) / ,
40+ ) ;
41+ expect ( serverBundle ) . toMatch (
42+ / t r a c i n g C h a n n e l ( \$ ? \d ) ? \( [ " ' ] o r c h e s t r i o n : @ r e m i x - r u n \/ s e r v e r - r u n t i m e : c a l l R o u t e L o a d e r [ " ' ] \) / ,
43+ ) ;
3144 } ) ;
3245} ) ;
0 commit comments