Files
MoviePilot-Frontend/tests/config/frontend-workflow.spec.ts
2026-07-18 16:48:25 +08:00

23 lines
1.1 KiB
TypeScript

import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { describe, expect, it } from 'vitest'
const workflowPath = resolve(process.cwd(), '.github/workflows/test.yml')
describe('前端 Pull Request workflow', () => {
it('使用只读的变更文件格式检查,并显式比较事件 base/head SHA', () => {
const workflow = readFileSync(workflowPath, 'utf8')
const formatJob = workflow.match(/\n {2}format:\n(?<job>[\s\S]*?)(?=\n {2}[\w-]+:\n|$)/)?.groups?.job
expect(workflow).toContain('permissions:\n contents: read')
expect(formatJob).toBeDefined()
expect(formatJob).toContain('fetch-depth: 0')
expect(formatJob).toContain("node-version: '24'")
expect(formatJob).toContain('run: yarn --frozen-lockfile')
expect(formatJob).toContain('BASE_SHA: ${{ github.event.pull_request.base.sha }}')
expect(formatJob).toContain('HEAD_SHA: ${{ github.event.pull_request.head.sha }}')
expect(formatJob).toContain('run: yarn format:check --base "$BASE_SHA" --head "$HEAD_SHA"')
expect(formatJob).not.toContain('--write')
})
})