Files
orca/config/scripts/orcad-mobile-web-bundle.test.mjs
T
Jinwoo Hong cf13e0cf9d fix(sidebar): phone feed list leftovers before the flip (dark) (#30631)
* fix(sidebar): phone feed list leftovers before the flip (dark)

Bump the feed's semantics version for P11's desktop facts; mark switch-on phone page bundles so packaging and orcad staging refuse them; show the page's last-listed rows before the first feed read; draw the host's pending creations; pass the listed host's own label into host sections instead of the running device's platform.

* fix(sidebar): review fixes for the phone feed leftovers (dark)

A dark orcad may stage the dark page (only a marker of an off switch is refused); the bundle tree writer leaves the marker; the pre-feed list keeps the view's filters; a creation names its project only outside that project's header and survives search when its project matches; the feed view and row labels read one resolved desktop platform.

* fix(sidebar): second review fixes for the phone feed leftovers (dark)

Test the off-switch marker check across switches; resolve the desktop platform once for rows and headers; a section search narrows keeps only matching rows.
2026-10-19 04:27:09 -04:00

73 lines
2.9 KiB
JavaScript

import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { parse } from 'yaml'
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
import { ORCAD_MOBILE_WEB_MANIFEST } from '../../src/shared/orcad-artifacts.ts'
import { writeMobileWebBundleFixtureTree } from './mobile-web-bundle-fixture-tree.mjs'
import {
readOrcadMobileWebAssetFilenames,
stageOrcadMobileWebBundle
} from './orcad-mobile-web-bundle.mjs'
let scratch
let bundleDir
let outputDir
beforeEach(() => {
scratch = mkdtempSync(join(tmpdir(), 'orcad-mobile-web-'))
bundleDir = join(scratch, 'mobile-web')
outputDir = join(scratch, 'orcad')
vi.spyOn(console, 'log').mockImplementation(() => {})
})
afterEach(() => {
vi.restoreAllMocks()
vi.unstubAllEnvs()
rmSync(scratch, { recursive: true, force: true })
})
it('stages the manifest and every asset it lists, byte for byte', async () => {
const { manifest } = await writeMobileWebBundleFixtureTree({ outDir: bundleDir })
stageOrcadMobileWebBundle(outputDir, bundleDir)
const staged = readOrcadMobileWebAssetFilenames(outputDir)
expect(staged).toHaveLength(manifest.assets.length)
for (const asset of manifest.assets) {
expect(readFileSync(join(outputDir, 'out', 'mobile-web', asset.path))).toEqual(
readFileSync(join(bundleDir, asset.path))
)
}
expect(readFileSync(join(outputDir, ORCAD_MOBILE_WEB_MANIFEST))).toEqual(
readFileSync(join(bundleDir, 'manifest.json'))
)
})
it('stages a dark page into a dark orcad, and refuses it in any other', async () => {
vi.stubEnv('ORCA_SIDEBAR_INPUTS', 'main')
await writeMobileWebBundleFixtureTree({ outDir: bundleDir })
stageOrcadMobileWebBundle(outputDir, bundleDir)
expect(existsSync(join(outputDir, ORCAD_MOBILE_WEB_MANIFEST))).toBe(true)
vi.unstubAllEnvs()
rmSync(outputDir, { recursive: true, force: true })
expect(() => stageOrcadMobileWebBundle(outputDir, bundleDir)).toThrow('ORCA_SIDEBAR_INPUTS=main')
expect(existsSync(join(outputDir, ORCAD_MOBILE_WEB_MANIFEST))).toBe(false)
})
it('fails the build when the page was never built', () => {
expect(() => stageOrcadMobileWebBundle(outputDir, bundleDir)).toThrow('pnpm build:mobile-web')
expect(existsSync(join(outputDir, ORCAD_MOBILE_WEB_MANIFEST))).toBe(false)
})
it('ships the page the qualification lanes tested in the release template', () => {
const workflow = parse(
readFileSync(new URL('../../.github/workflows/node-server-tests.yml', import.meta.url), 'utf8')
)
const template = workflow.jobs.desktop_template
expect(template.needs).toContain('mobile_web_bundle')
expect(template.if).toContain("needs.mobile_web_bundle.result == 'success'")
expect(template.steps.some((step) => step.with?.name === 'orcad-mobile-web-bundle')).toBe(true)
expect(template.steps.some((step) => step.uses?.includes('build-mobile-web-bundle'))).toBe(false)
})