No caller can open India's withheld poster: posterWithheld()/largeSheet() read the DEV-only preview themselves (no opener argument). The open preview is proved under Vite (check:poster-section C2, DEV true as on the pilot's dev server); check:country-sheet-one-path fails if an opener argument comes back.
This commit is contained in:
parent
249e69f2a5
commit
02b44a7343
3 changed files with 23 additions and 7 deletions
|
|
@ -99,11 +99,12 @@ const largeOf = (item) => (item && LARGE_SHEETS[String(item.iso3 || '').toUpperC
|
|||
export const WITHHELD = { IND: { poster: true, rows: true, preview: true } }
|
||||
export const previewUnreleased = () => Boolean(import.meta.env && import.meta.env.DEV && globalThis.DXM_PREVIEW_UNRELEASED === true)
|
||||
const withheldOf = (item) => (item && !item.indiaState && WITHHELD[String(item.iso3 || '').toUpperCase()]) || null
|
||||
export function posterWithheld(item, open = previewUnreleased()) { const w = withheldOf(item); return Boolean(w?.poster) && !(w.preview && open) }
|
||||
// No caller can open it: the preview state is read HERE, never passed in (so a built bundle cannot print it).
|
||||
export function posterWithheld(item) { const w = withheldOf(item); return Boolean(w?.poster) && !(w.preview && previewUnreleased()) }
|
||||
export function rowsWithheld(item) { return Boolean(withheldOf(item)?.rows) }
|
||||
/** The poster's withholding (the name Poster Design reads). */
|
||||
export function sheetWithheld(item) { return posterWithheld(item) }
|
||||
export function largeSheet(item, open = previewUnreleased()) { return posterWithheld(item, open) ? null : largeOf(item) }
|
||||
export function largeSheet(item) { return posterWithheld(item) ? null : largeOf(item) }
|
||||
// The sheet format a request gets: a large-sheet country prints at the large size ASKED FOR when it has one (66x66,
|
||||
// 36x60), else at its default (60x96); a packet's page 1 stays a page; every other country gets exactly what it asked.
|
||||
export function sheetFormatFor(item, format) {
|
||||
|
|
|
|||
|
|
@ -197,8 +197,10 @@ export async function armG(cs, srcs, mfeSrc = '') {
|
|||
if (!cs.posterWithheld(ind) || cs.largeSheet(ind)) fails.push("(a) India's whole-country poster is NOT withheld by default: it would ship to every host")
|
||||
} finally { if (was === undefined) delete globalThis.DXM_PREVIEW_UNRELEASED; else globalThis.DXM_PREVIEW_UNRELEASED = was }
|
||||
if (!cs.rowsWithheld(ind)) fails.push("India's rows are not withheld: its list/packet/cards (~1,000 pages) would print")
|
||||
const big = cs.largeSheet(ind, true)
|
||||
if (cs.posterWithheld(ind, true) || !big || big.format !== '60x96' || big.formats.join() !== '60x96') fails.push(`(b) an open preview does not print India's poster at 60x96 only (${big && big.formats})`)
|
||||
// (b) the open preview itself is proved under Vite (import.meta.env.DEV true) by check:poster-section; here, the size:
|
||||
const big = cs.LARGE_SHEETS && cs.LARGE_SHEETS.IND
|
||||
if (!big || big.format !== '60x96' || big.formats.join() !== '60x96') fails.push(`India's whole-country poster is not 60x96 ONLY (${big && big.formats})`)
|
||||
if (cs.posterWithheld.length > 1 || cs.largeSheet.length > 1) fails.push('posterWithheld()/largeSheet() take a second argument again: a production caller could open the withheld poster')
|
||||
if (cs.sheetWithheld(ind) !== cs.posterWithheld(ind)) fails.push('sheetWithheld() no longer means the poster')
|
||||
if (cs.rowsWithheld({ iso3: 'IND', indiaState: true, id: 'india-state-gujarat' })) fails.push('an India STATE card has withheld rows (only the whole country may)')
|
||||
for (const [name, src] of Object.entries(srcs)) {
|
||||
|
|
@ -275,7 +277,7 @@ async function main() {
|
|||
['a locale loses a state name', () => armD(states, { ...areas, ro: { ...areas.ro, stateNames: Object.fromEntries(Object.entries(areas.ro.stateNames).filter(([k]) => k !== 'IN-GJ')) } }, meta)],
|
||||
['the names lose their licence line', () => armD(states, areas, { ...meta, licence: '' })],
|
||||
['India\'s poster released by default', async () => armG({ ...CS, posterWithheld: () => false, largeSheet: () => CS.LARGE_SHEETS.IND }, { wall: files[wall], regions: REG }, MFE)],
|
||||
['the preview flag ignored', async () => armG({ ...CS, posterWithheld: () => true, largeSheet: () => null }, { wall: files[wall], regions: REG }, MFE)],
|
||||
['an opener argument comes back', async () => armG({ ...CS, posterWithheld: (it, open) => CS.posterWithheld(it) }, { wall: files[wall], regions: REG }, MFE)],
|
||||
['the preview read without DEV (a global opens production)', async () => armG({ ...CS, previewUnreleased: () => globalThis.DXM_PREVIEW_UNRELEASED === true }, { wall: files[wall], regions: REG }, MFE)],
|
||||
['India\'s rows un-withheld', async () => armG({ ...CS, rowsWithheld: () => false }, { wall: files[wall], regions: REG }, MFE)],
|
||||
['the India tab shown without the preview flag', async () => armG(CS, { wall: files[wall], regions: REG }, MFE.replace('...(import.meta.env && import.meta.env.DEV && globalThis.DXM_PREVIEW_UNRELEASED === true ? [INDIA_PANE] : []),', 'INDIA_PANE,'))],
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import { fileURLToPath } from 'node:url'
|
|||
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..')
|
||||
const DXL = ['africa', 'asia', 'europe', 'latin-america-and-caribbean', 'middle-east', 'north-america-and-non-spanish-caribbean', 'oceania', 'other']
|
||||
|
||||
async function arms({ types, country, element, sectionSrc }) {
|
||||
async function arms({ types, country, element, sectionSrc, cs }) {
|
||||
const fails = []
|
||||
// A
|
||||
if (!types.posterTypeNames().includes('country')) fails.push("A: the registry has no 'country' type")
|
||||
|
|
@ -49,6 +49,17 @@ async function arms({ types, country, element, sectionSrc }) {
|
|||
if (!/countryPosterTooMany/.test(String(why))) fails.push(`C: withheld India's rows are not withheld (${why})`)
|
||||
if (fetched) fails.push('C: withheld India fetched records')
|
||||
}
|
||||
// C2. THE PREVIEW, under Vite (import.meta.env.DEV is true here, as on the pilot's dev server): only with the global
|
||||
// set does India's whole-country poster open, at 60x96; its rows stay withheld; without it, withheld.
|
||||
const was = globalThis.DXM_PREVIEW_UNRELEASED
|
||||
try {
|
||||
globalThis.DXM_PREVIEW_UNRELEASED = true
|
||||
const big = cs.largeSheet({ iso3: 'IND' })
|
||||
if (cs.posterWithheld({ iso3: 'IND' }) || !big || big.format !== '60x96') fails.push(`C2: in a DEV preview India's poster does not open at 60x96 (${big && big.format})`)
|
||||
if (!cs.rowsWithheld({ iso3: 'IND' })) fails.push("C2: the preview also released India's rows")
|
||||
delete globalThis.DXM_PREVIEW_UNRELEASED
|
||||
if (!cs.posterWithheld({ iso3: 'IND' })) fails.push('C2: without the preview global India is not withheld')
|
||||
} finally { if (was === undefined) delete globalThis.DXM_PREVIEW_UNRELEASED; else globalThis.DXM_PREVIEW_UNRELEASED = was }
|
||||
// D
|
||||
const fake = (attrs) => ({ getAttribute: (n) => (n in attrs ? attrs[n] : null), hasAttribute: (n) => n in attrs })
|
||||
const d0 = element.posterSectionConfig(fake({ scope: 'africa' }))
|
||||
|
|
@ -78,11 +89,13 @@ try {
|
|||
const country = (await load('library/components/poster/types/countryPosterType.js')).default
|
||||
const element = await load('library/elements/posterSectionConfig.js')
|
||||
const sectionSrc = readFileSync(join(ROOT, 'library/components/poster/PosterSection.vue'), 'utf8')
|
||||
const real = { types, country, element, sectionSrc }
|
||||
const cs = await load('library/packet/countrySheet.js')
|
||||
const real = { types, country, element, sectionSrc, cs }
|
||||
if (process.argv.includes('--self-test')) {
|
||||
const poisons = [
|
||||
["a registry without 'country'", { ...real, types: { ...types, posterTypeNames: () => [] } }, /^A:/],
|
||||
['a region key without "&" → "and"', { ...real, country: { ...country, items: (s, l) => (/-and-/.test(String(s)) ? [] : country.items(s, l)) } }, /^B:/],
|
||||
['the preview ignored under DEV', { ...real, cs: { ...cs, posterWithheld: () => true, largeSheet: () => null } }, /^C2:/],
|
||||
['a section that uses a name it does not inject', { ...real, sectionSrc: sectionSrc.replace('</template>', '{{ notProvided }}</template>') }, /^E:/],
|
||||
]
|
||||
for (const [name, inp, rx] of poisons) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue