Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import test from 'node:test'
const workflowPath = new URL(
'../.github/workflows/deploy-ftp.yml',
import.meta.url
)
/**
* Verifies the FTP workflow deploys the PHP metadata directory used by LIVE.
*/
test('ftp workflow deploys the api directory', async () => {
const workflow = await readFile(workflowPath, 'utf8')
assert.match(workflow, /api:\s*\n\s*- 'api\/\*\*'/)
assert.match(workflow, /name: Deploy api to \.\/api\//)
assert.match(workflow, /local-dir: \.\/api\//)
assert.match(workflow, /server-dir: \.\/api\//)
})
/**
* Verifies the API deploy skips `.htaccess` so FTP hosts that reset dotfile
* uploads can still publish the PHP metadata fallback.
*/
test('ftp workflow excludes api htaccess from FTP sync', async () => {
const workflow = await readFile(workflowPath, 'utf8')
assert.match(
workflow,
/name: Deploy api to \.\/api\/[\s\S]*?exclude: \|[\s\S]*?\*\*\/\.htaccess/
)
})
/**
* Verifies the FTP workflow deploys the package manifest to the LIVE document
* root so the PHP metadata endpoint can read the current app version.
*/
test('ftp workflow deploys package.json to the live root on frontend or dependency changes', async () => {
const workflow = await readFile(workflowPath, 'utf8')
const stageManifestBlock = workflow.match(
/name: Stage package manifest for LIVE[\s\S]*?cp package\.json \.deploy-root\/package\.json/
)?.[0]
const deployManifestBlock = workflow.match(
/name: Deploy package manifest to \.\/[\s\S]*?state-name: \.ftp-deploy-root-meta-state\.json/
)?.[0]
const manifestDeployCondition =
/if: steps\.changes\.outputs\.src == 'true' \|\| steps\.changes\.outputs\.deps == 'true'/
assert.match(workflow, /name: Stage package manifest for LIVE/)
assert.match(stageManifestBlock ?? '', manifestDeployCondition)
assert.match(workflow, /mkdir -p \.deploy-root/)
assert.match(workflow, /cp package\.json \.deploy-root\/package\.json/)
assert.match(deployManifestBlock ?? '', manifestDeployCondition)
assert.match(
workflow,
/name: Deploy package manifest to \.\/[\s\S]*?local-dir: \.\/\.deploy-root\/[\s\S]*?server-dir: \.\//
)
})
/**
* Verifies the FTP workflow deploys the static frontend artifact produced for
* Apache/shared-hosting instead of raw source files that rely on the Node
* server's runtime rewrite hooks.
*/
test('ftp workflow deploys the static frontend build artifact', async () => {
const workflow = await readFile(workflowPath, 'utf8')
assert.match(workflow, /name: Build static frontend deployment/)
assert.match(workflow, /run: npm run build:static/)
assert.match(
workflow,
/name: Deploy static frontend to \.\/[\s\S]*?local-dir: \.\/\.deploy-src\/[\s\S]*?server-dir: \.\//
)
assert.match(
workflow,
/name: Retry deploy static frontend to \.\/[\s\S]*?local-dir: \.\/\.deploy-src\/[\s\S]*?server-dir: \.\//
)
})
/**
* Verifies the FTP workflow installs npm package dependencies before the
* static deploy builder copies browser toolkit modules out of node_modules.
*/
test('ftp workflow installs browser build dependencies before static build', async () => {
const workflow = await readFile(workflowPath, 'utf8')
const installIndex = workflow.indexOf(
'name: Install frontend build dependencies'
)
const structuredDataCheckIndex = workflow.indexOf(
'name: Check structured data freshness'
)
const buildIndex = workflow.indexOf(
'name: Build static frontend deployment'
)
assert.ok(installIndex > -1)
assert.ok(structuredDataCheckIndex > installIndex)
assert.ok(buildIndex > structuredDataCheckIndex)
assert.ok(buildIndex > installIndex)
assert.doesNotMatch(workflow, /Checkout local toolkit dependencies/)
assert.doesNotMatch(workflow, /git clone --depth 1/)
assert.match(
workflow,
/name: Install frontend build dependencies[\s\S]*?run: npm ci/
)
assert.match(
workflow,
/name: Check structured data freshness[\s\S]*?run: npm run check:structured-data/
)
})
/**
* Verifies the static artifact upload includes the curated browser dependency
* files emitted under `.deploy-src/node_modules`.
*/
test('ftp workflow includes static browser node_modules in frontend deploy', async () => {
const workflow = await readFile(workflowPath, 'utf8')
const deployBlock = workflow.match(
/name: Deploy static frontend to \.\/[\s\S]*?state-name: \.ftp-deploy-src-state\.json/
)?.[0]
const retryBlock = workflow.match(
/name: Retry deploy static frontend to \.\/[\s\S]*?state-name: \.ftp-deploy-src-state\.json/
)?.[0]
assert.ok(deployBlock)
assert.ok(retryBlock)
assert.doesNotMatch(deployBlock, /\*\*\/node_modules\/\*\*/)
assert.doesNotMatch(retryBlock, /\*\*\/node_modules\/\*\*/)
})
/**
* Verifies dependency refreshes rely on the static artifact upload for
* rewritten browser modules instead of running a second node_modules sync.
*/
test('ftp workflow avoids a separate browser node_modules deploy', async () => {
const workflow = await readFile(workflowPath, 'utf8')
assert.doesNotMatch(workflow, /Deploy node_modules to \.\/node_modules\//)
assert.doesNotMatch(
workflow,
/Retry deploy node_modules to \.\/node_modules\//
)
assert.doesNotMatch(workflow, /server-dir: \.\/node_modules\//)
assert.doesNotMatch(workflow, /\.ftp-deploy-nm-state\.json/)
assert.doesNotMatch(workflow, /run: npm ci --omit=dev/)
})
/**
* Verifies dependency metadata stays aligned for the FTP deployment workflow.
*/
test('package lock root dependencies match package manifest', async () => {
const packageRaw = await readFile(
new URL('../package.json', import.meta.url),
'utf8'
)
const lockRaw = await readFile(
new URL('../package-lock.json', import.meta.url),
'utf8'
)
const pkg = JSON.parse(packageRaw)
const lock = JSON.parse(lockRaw)
assert.deepEqual(lock.packages?.['']?.dependencies, pkg.dependencies)
})
5f635a4c0This file is pinned to the selected release. Download the original to open it in your design tool.