|
10 | 10 | // |
11 | 11 | // FROM (`main` d947a93cf8), a bundle with no canonical member: |
12 | 12 | // - shipped in `fr-FR` only: the plain read and `/layers` served the `fr-FR` |
13 | | -// member (200) and the execution read returned it, while `?member=en-US` |
14 | | -// and `/published` answered 404; |
| 13 | +// member (200) and the execution read returned it, naming no package and |
| 14 | +// naming the shipping package (`?package=`), while `?member=en-US` and |
| 15 | +// `/published` answered 404; |
15 | 16 | // - stored in `fr-FR` only (a package-less row): 404 before a restart, then |
16 | 17 | // 200 with the `fr-FR` row after it (the hydrated bare slot), while |
17 | 18 | // `?member=en-US` and `/published` answered 404 on both sides. |
@@ -94,12 +95,14 @@ const shape = (answer: Answer, pick: (served: any) => unknown): unknown[] => |
94 | 95 | answer.status === 200 ? [200, pick(unwrap(answer.body))] : [answer.status, codeOf(answer.body)]; |
95 | 96 | const doc = (d: any) => (d == null ? d : { name: d.name, locale: d.locale, subject: d.subject, label: d.label }); |
96 | 97 |
|
97 | | -async function doors(b: Booted, type: string, name: string, member?: string) { |
98 | | - const query: Record<string, string> = member === undefined ? {} : { member }; |
| 98 | +async function doors(b: Booted, type: string, name: string, member?: string, pkg?: string) { |
| 99 | + const query: Record<string, string> = { ...(member === undefined ? {} : { member }), ...(pkg === undefined ? {} : { package: pkg }) }; |
99 | 100 | const protocol = b.kernel.getService('protocol') as any; |
100 | 101 | let executed: unknown; |
101 | 102 | try { |
102 | | - executed = doc((await protocol.getMetaItemForExecution({ type, name, ...query }))?.item ?? null); |
| 103 | + executed = doc((await protocol.getMetaItemForExecution({ |
| 104 | + type, name, ...(member === undefined ? {} : { member }), ...(pkg === undefined ? {} : { packageId: pkg }), |
| 105 | + }))?.item ?? null); |
103 | 106 | } catch (e) { |
104 | 107 | executed = ['threw', (e as { status?: unknown }).status, (e as { code?: unknown }).code]; |
105 | 108 | } |
@@ -144,6 +147,14 @@ describe('[#34682] naming no member and naming the canonical member are one requ |
144 | 147 | expect({ leg, name, read: bare.read, effective: (bare.layers[1] as unknown[] | undefined)?.[0], executed: bare.executed }) |
145 | 148 | .toEqual({ leg, name, read: [200, served], effective: served, executed: served }); |
146 | 149 | } |
| 150 | + // …and at the shipping package's own address (`?package=`), for a shipped bundle. |
| 151 | + if (name.startsWith('ship_')) { |
| 152 | + const atBase = await doors(b, 'email_template', name, undefined, A); |
| 153 | + const atBaseNamed = await doors(b, 'email_template', name, CANONICAL, A); |
| 154 | + expect({ leg, name, ...atBaseNamed }, JSON.stringify(atBaseNamed)).toEqual({ leg, name, ...atBase }); |
| 155 | + expect({ leg, name, read: atBase.read, executed: atBase.executed }) |
| 156 | + .toEqual({ leg, name, read: served === undefined ? [404, 'RESOURCE_NOT_FOUND'] : [200, served], executed: served ?? null }); |
| 157 | + } |
147 | 158 | // `/published` takes no member selector: it reads the canonical member alone. |
148 | 159 | const named400 = await get(b.kernel, `/meta/email_template/${name}/published`, { member: CANONICAL }); |
149 | 160 | expect([leg, name, named400.status, codeOf(named400.body)]).toEqual([leg, name, 400, 'VALIDATION_ERROR']); |
|
0 commit comments