From 328a0ed68f2b0bcf54fc41e3919d850ce1d5121d Mon Sep 17 00:00:00 2001 From: ranxi2001 Date: Thu, 12 Nov 2026 15:46:41 +0800 Subject: [PATCH 1/8] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E9=B9=88?= =?UTF-8?q?=E9=B9=95=E7=9C=9F=E5=AE=9E=E5=BA=94=E7=94=A8=E9=9A=94=E7=A6=BB?= =?UTF-8?q?=20E2E=20=E9=A6=96=E4=B8=AA=E8=A1=A5=E8=AF=81=E5=A2=9E=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fixtures/pelican-question-e2e/Dockerfile | 20 + .../fixtures/pelican-question-e2e/README.md | 36 ++ .../pelican-question-e2e/acceptance.json | 31 ++ .../fixtures/pelican-question-e2e/compose.yml | 105 +++++ .../fixtures/pelican-question-e2e/config.yml | 15 + .../fixtures/pelican-question-e2e/seed.sql | 19 + .github/scripts/pelican-question-e2e.mjs | 385 ++++++++++++++++++ .../workflows/pelican-random-questions.yml | 127 +++++- 8 files changed, 737 insertions(+), 1 deletion(-) create mode 100644 .github/fixtures/pelican-question-e2e/Dockerfile create mode 100644 .github/fixtures/pelican-question-e2e/README.md create mode 100644 .github/fixtures/pelican-question-e2e/acceptance.json create mode 100644 .github/fixtures/pelican-question-e2e/compose.yml create mode 100644 .github/fixtures/pelican-question-e2e/config.yml create mode 100644 .github/fixtures/pelican-question-e2e/seed.sql create mode 100644 .github/scripts/pelican-question-e2e.mjs diff --git a/.github/fixtures/pelican-question-e2e/Dockerfile b/.github/fixtures/pelican-question-e2e/Dockerfile new file mode 100644 index 000000000000..e2da8800b636 --- /dev/null +++ b/.github/fixtures/pelican-question-e2e/Dockerfile @@ -0,0 +1,20 @@ +# Dependencies, Chromium and a fixture-only CA are prepared before isolation. +# Build context is .github, not the application tree (whose .dockerignore excludes it). +ARG APP_IMAGE=pelican-app-base:unset +FROM mcr.microsoft.com/playwright:v1.56.1-noble AS runner +WORKDIR /opt/fixture +RUN npm install --no-save --ignore-scripts playwright@1.56.1 pg@8.16.3 +RUN mkdir -p /opt/fixture/tls && \ + openssl req -x509 -newkey rsa:2048 -nodes -days 7 \ + -subj '/CN=fake-upstream' -addext 'subjectAltName=DNS:fake-upstream' \ + -addext 'basicConstraints=critical,CA:TRUE' \ + -keyout /opt/fixture/tls/key.pem -out /opt/fixture/tls/cert.pem +COPY scripts/pelican-question-e2e.mjs /opt/fixture/pelican-question-e2e.mjs +ENV NODE_EXTRA_CA_CERTS=/opt/fixture/tls/cert.pem +ENTRYPOINT ["node", "/opt/fixture/pelican-question-e2e.mjs"] + +# Only add trust for this disposable fake-upstream certificate. Keep the real +# application binary, embedded frontend, resources and normal entrypoint. +FROM ${APP_IMAGE} AS app +COPY --from=runner /opt/fixture/tls/cert.pem /fixture-ca.pem +RUN cat /fixture-ca.pem >> /etc/ssl/certs/ca-certificates.crt diff --git a/.github/fixtures/pelican-question-e2e/README.md b/.github/fixtures/pelican-question-e2e/README.md new file mode 100644 index 000000000000..43cf34fcd434 --- /dev/null +++ b/.github/fixtures/pelican-question-e2e/README.md @@ -0,0 +1,36 @@ +# Issue #795 隔离应用 E2E:首个待审增量 + +Refs #795。本目录只提供 CI fixture,不修改应用业务代码,不表示完整验收、真实模型兼容性或经验难度校准完成。逐场景状态由 `acceptance.json` 声明;脚本即使成功,也固定输出 `full_acceptance_complete: false`。 + +## 本增量的运行链 + +GitHub `pull_request`(base 为 `production`,包含 fixture/script/workflow 变动)即可触发本分支新工作流,Draft 不跳过。`workflow_dispatch` 只是工作流进入默认分支后的备用入口,不能假定新分支已经可 dispatch。父协调者负责 publication 和精确 head/check 回读。 + +`APP_SHA` 与 `HARNESS_SHA` 均显式取 PR head(dispatch 时取该事件 SHA),分别 checkout,记录 SHA/tree。`PARENT_BASE_SHA` 记录本轮父协调者提供的整合基线,绝不作为永久固定的被测旧应用 SHA。正常根 Dockerfile 构建嵌入前端的真实应用;浏览器/pg 依赖、镜像和 fixture CA 也全部在运行隔离前准备。运行期间 Compose 一次性内部网络上的应用、PostgreSQL、Redis、假上游和浏览器均无第二网络、host networking、宿主 Docker socket 或发布端口。宿主 CI 的 Docker inspect 只投影网络/端口/挂载/特权配置,不输出容器环境变量。 + +真实 AUTO_SETUP、迁移及虚构管理员正常登录后,SQL 只初始化两个 `anthropic/apikey` 账号和测试分组/关联,不插入题目、计划或结果。手动测试通过真实页面按钮、prepare API、handler/service 和上游 HTTP 请求执行,A/B 各两样本;输出唯一标记与上游去认证后的题面记录关联,再核真实 DOM 和 localStorage 刷新恢复。分组页面通过真实创建表单保存**禁用**计划并核对 API/PG,尚不执行调度。没有调用任何 `/run` 来代替 RunDue。 + +## HTTPS fixture 与原 HTTP 建议的差异 + +当前 `AccountTestService.validateUpstreamBaseURL` 在白名单启用时调用 `ValidateHTTPSURL`,不会读取 `allow_insecure_http` 来放行 HTTP。为保持真实校验启用,fixture 使用 `https://fake-upstream:4199`,临时生成仅含 fixture SAN 的证书,并仅在 CI fixture 镜像中加入该 CA。所有三类 URL host 白名单只列 `fake-upstream`,允许隔离私网,保持 HTTP 禁止。未关闭 TLS 校验、白名单或改动业务代码。该选择与 audit 中的 `http://` 提议不同,须在独审中确认;它不改变任何生产配置。 + +假上游只接受模型发现和 messages SSE,额外的健康、去认证 capture 读取及单次 refusal 控制端点仅供 fixture。可选 pricing 刷新明确返回 503,真实应用使用打包的 fallback 文件;未知路径/输入记录为拒绝并使浏览器验收失败。网页本身仅允许 app origin;provider 只能由应用调用,Node fixture 控制读取不伪装成浏览器请求。主防外呼边界是所有运行容器的 Docker internal 网络,虚构 key 不是防外呼措施。 + +## 未完成的完整验收范围 + +- [ ] A/B 账号随机定时计划由真实 UI 创建,各两个样本;只用限定 SQL 对齐同一 UTC 微秒 nominal time T,等待真正 runner/Claim。 +- [ ] 四个账号结果的 PG 投影、去认证 payload、history list/detail API 和真实展开 DOM/iframe 按同一 plan/result ID 对账。 +- [ ] 分组计划真实 RunDue/Claim、结果 PG → list/detail API → `PelicanTestsView` 同 ID 对账;不假设分组均匀路由 A/B。 +- [ ] 经真实浏览器编辑计划后,旧 PG/API/UI 快照保持不变。 +- [ ] 第二 nominal time T2 按现有哈希公式选到另一题,等待真实 tick,新旧记录共存;不能修改生产抽题算法。 +- [ ] arm 单次 refusal 后真正产生 failed 持久化结果、失败历史及 lease 释放;现有 refusal server 能力尚未被此增量测试。 +- [ ] 对结果/租约/到期字段进行限定 SQL 投影,与 API、capture 和场景 ID 关联。目前只有初始化实体与禁用分组计划投影,没有定时结果 SQL 证据。 +- [ ] 远程 Actions 首次运行、raw job log 定向修正、精确 head/check 回读。没有运行本地动态检查。 +- [ ] 隔离链路真实截图上传 PR 原生附件并回读;现有组件 job 截图仍只是组件证据,不能混同此 job。无 PNG 提交到源码。 +- [ ] 父协调者独审、完整技术验收与产品/经验难度证据。fixture 的简单 SVG 不代表题目作答合格或难度相当。 + +## 证据与清理 + +CI artifact 预期包含应用/harness SHA/tree、显式未完成清单、命名场景结果、网络结构投影、仅限 fixture 题面的 provider captures(无认证头/全量 body)、真实手动请求/题面投影、本轮 localStorage 结果投影、必要的实体/计划 PG 投影、浏览器错误/拒绝清单和截图。比较 `actual_prompt` 的边界是本 fixture 的 UTF-8 文本经过真实 service TrimSpace 后的发送值,不能外推任意输入。 + +不导出 auth token、Cookie、完整 HAR、数据库全表、凭据列、原始应用日志或真实用户数据。不把整个运行目录当附件。fixture 密码/key/CA 都是本轮自建假值,不能用到任何其他环境。失败时也留存上述受限产物,`always()` 销毁容器、网络和一次性卷,artifact 保留七天。父协调者首次远程运行前需审查此增量,发布后仍须按原 brief 继续同一 PR 的未完成范围。 diff --git a/.github/fixtures/pelican-question-e2e/acceptance.json b/.github/fixtures/pelican-question-e2e/acceptance.json new file mode 100644 index 000000000000..8e5729f91c81 --- /dev/null +++ b/.github/fixtures/pelican-question-e2e/acceptance.json @@ -0,0 +1,31 @@ +{ + "scope": "initial-reviewable-increment", + "full_acceptance_complete": false, + "implemented_not_remotely_verified": [ + "runtime internal Docker network for app, browser, fake provider, PostgreSQL and Redis", + "normal login and real accounts UI with original CSS", + "real prepare, account A and B with two samples each in one manual round", + "provider payload compared with API question and real DOM snapshot", + "manual localStorage recovery, history expansion and fixture iframe after reload", + "next manual round identity changes; repeated question selection is permitted", + "disabled group plan created through real browser form, create API and PG" + ], + "unimplemented": [ + "account scheduled plans created via UI, two samples per A and B", + "same nominal UTC time, actual account runner Claim and four PG results", + "account PG result IDs and payloads reconciled with history/detail APIs and expanded real DOM", + "group due time alignment, real RunDue/Claim and PG/list/detail/DOM reconciliation", + "plan UI edit followed by proof old stored/API/DOM snapshot is unchanged", + "second nominal time mapped to a different question, new and old scheduled records coexist", + "deterministic upstream refusal yields failed persisted history and released lease", + "restricted result/lease/due SQL projections linked to captures and API IDs" + ], + "pending_external_gates": [ + "all remote Actions execution and raw-log-driven corrections", + "screenshots from successful isolated chain uploaded as PR native attachments and read back", + "exact published PR head and check readback by parent", + "independent parent review and merge decision", + "product policy and empirical difficulty calibration; fixture output cannot prove either" + ], + "fixture_transport_difference": "Uses fixture-only HTTPS and an ephemeral fixture CA, because the enabled real account-test URL allowlist calls ValidateHTTPSURL. The audit's proposed HTTP URL is not accepted with that allowlist enabled. No application validation is disabled or modified." +} diff --git a/.github/fixtures/pelican-question-e2e/compose.yml b/.github/fixtures/pelican-question-e2e/compose.yml new file mode 100644 index 000000000000..db375de2075f --- /dev/null +++ b/.github/fixtures/pelican-question-e2e/compose.yml @@ -0,0 +1,105 @@ +# No service may gain a second network, host networking, published port, Docker +# socket, production config or persistent host data mount. Images are prebuilt. +x-runtime: &runtime + networks: [isolated] + restart: "no" + security_opt: [no-new-privileges:true] + cap_drop: [ALL] + +services: + postgres: + <<: *runtime + image: postgres:18-alpine + environment: + POSTGRES_USER: fixture + POSTGRES_PASSWORD: fixture-only-postgres + POSTGRES_DB: fixture + volumes: [pg-data:/var/lib/postgresql] + # The stock entrypoint changes ownership before dropping privileges. + cap_add: [CHOWN, DAC_OVERRIDE, FOWNER, SETGID, SETUID] + healthcheck: + test: [CMD-SHELL, "pg_isready -U fixture -d fixture"] + interval: 2s + timeout: 3s + retries: 30 + redis: + <<: *runtime + image: redis:7-alpine + command: [redis-server, --save, "", --appendonly, "no"] + tmpfs: [/data] + cap_add: [CHOWN, DAC_OVERRIDE, SETGID, SETUID] + healthcheck: + test: [CMD, redis-cli, ping] + interval: 2s + timeout: 3s + retries: 30 + fake-upstream: + <<: *runtime + image: pelican-runner:${HARNESS_SHA:?required} + command: [upstream] + read_only: true + volumes: ["${EVIDENCE_DIR:?required}:/evidence"] + healthcheck: + test: [CMD, node, /opt/fixture/pelican-question-e2e.mjs, upstream-health] + interval: 2s + timeout: 3s + retries: 30 + app: + <<: *runtime + image: pelican-app:${APP_SHA:?required} + cap_add: [CHOWN, DAC_OVERRIDE, SETGID, SETUID] + environment: + AUTO_SETUP: "true" + ADMIN_EMAIL: reviewer@example.invalid + ADMIN_PASSWORD: Fixture-Only-795-Password! + JWT_SECRET: fixture-only-jwt-795-not-a-real-secret-0123456789abcdef + DATABASE_HOST: postgres + DATABASE_PORT: "5432" + DATABASE_USER: fixture + DATABASE_PASSWORD: fixture-only-postgres + DATABASE_DBNAME: fixture + DATABASE_SSLMODE: disable + REDIS_HOST: redis + SERVER_HOST: 0.0.0.0 + SERVER_PORT: "8080" + SERVER_MODE: release + TZ: UTC + CONFIG_FILE: /fixture/config.yml + volumes: + - app-data:/app/data + - ./config.yml:/fixture/config.yml:ro + depends_on: + postgres: {condition: service_healthy} + redis: {condition: service_healthy} + fake-upstream: {condition: service_healthy} + healthcheck: + test: [CMD, wget, -q, -T, "3", -O, /dev/null, http://localhost:8080/health] + interval: 3s + timeout: 5s + retries: 60 + browser: + <<: *runtime + image: pelican-runner:${HARNESS_SHA:?required} + command: [browser] + read_only: true + shm_size: 1gb + tmpfs: [/tmp] + environment: + APP_ORIGIN: http://app:8080 + PGHOST: postgres + PGUSER: fixture + PGPASSWORD: fixture-only-postgres + PGDATABASE: fixture + volumes: + - "${EVIDENCE_DIR:?required}:/evidence" + - ./acceptance.json:/fixture/acceptance.json:ro + depends_on: + app: {condition: service_healthy} + +networks: + isolated: + internal: true + enable_ipv6: false +volumes: + pg-data: + app-data: diff --git a/.github/fixtures/pelican-question-e2e/config.yml b/.github/fixtures/pelican-question-e2e/config.yml new file mode 100644 index 000000000000..a3dc681ae6be --- /dev/null +++ b/.github/fixtures/pelican-question-e2e/config.yml @@ -0,0 +1,15 @@ +# Fixture only; AUTO_SETUP writes its own temporary /app/data/config.yaml. +# Environment supplies server/database/redis/JWT fields for normal config load. +security: + url_allowlist: + enabled: true + upstream_hosts: [fake-upstream] + pricing_hosts: [fake-upstream] + crs_hosts: [fake-upstream] + allow_private_hosts: true + allow_insecure_http: false +# No SMTP configuration. Background downloads fail closed on the internal network. +# Use the real packaged pricing fallback; no fake pricing endpoint is served. +pricing: + remote_url: https://fake-upstream:4199/disabled-pricing + hash_url: https://fake-upstream:4199/disabled-pricing-hash diff --git a/.github/fixtures/pelican-question-e2e/seed.sql b/.github/fixtures/pelican-question-e2e/seed.sql new file mode 100644 index 000000000000..599dd5900db2 --- /dev/null +++ b/.github/fixtures/pelican-question-e2e/seed.sql @@ -0,0 +1,19 @@ +-- Run only after the actual application has completed its normal migrations. +-- SQL initializes fictional entities only: no plans, questions or result rows. +BEGIN; +INSERT INTO groups (name, platform, status) +VALUES ('fixture-pelican-group', 'anthropic', 'active'); + +INSERT INTO accounts (name, platform, type, credentials, concurrency, priority, status, schedulable) +SELECT 'fixture-pelican-' || alias, 'anthropic', 'apikey', + jsonb_build_object('api_key', 'fixture-only-key-' || alias, + 'base_url', 'https://fake-upstream:4199'), + 4, 50, 'active', true +FROM (VALUES ('a'), ('b')) AS fixtures(alias); + +INSERT INTO account_groups (account_id, group_id) +SELECT a.id, g.id +FROM accounts a CROSS JOIN groups g +WHERE a.name IN ('fixture-pelican-a', 'fixture-pelican-b') + AND g.name = 'fixture-pelican-group'; +COMMIT; diff --git a/.github/scripts/pelican-question-e2e.mjs b/.github/scripts/pelican-question-e2e.mjs new file mode 100644 index 000000000000..70c826b792e0 --- /dev/null +++ b/.github/scripts/pelican-question-e2e.mjs @@ -0,0 +1,385 @@ +// Remote CI only. The sole provider substitute is the isolated HTTPS server. +// No application API fulfillment, auth-store replacement, injected questions, +// results, CSS changes, forced clicks, HAR, cookies or token exports. +import assert from 'node:assert/strict' +import { createServer } from 'node:https' +import { readFileSync, writeFileSync, appendFileSync, mkdirSync } from 'node:fs' +import { join } from 'node:path' +import { createRequire } from 'node:module' + +const evidence = process.env.EVIDENCE_DIR || '/evidence' +const upstreamOrigin = 'https://fake-upstream:4199' +const model = 'claude-opus-5-5' +const mode = process.argv[2] +const unwrap = value => value?.data ?? value +const save = (name, value) => writeFileSync(join(evidence, name), JSON.stringify(value, null, 2) + '\n') + +function topology() { + assert.equal(JSON.parse(readFileSync(join(evidence, 'network-internal.json'))), true) + const destinations = { + postgres: ['/var/lib/postgresql'], + redis: ['/data'], + app: ['/app/data', '/fixture/config.yml'], + 'fake-upstream': ['/evidence'], + browser: ['/evidence', '/fixture/acceptance.json', '/tmp'], + } + for (const [service, allowed] of Object.entries(destinations)) { + const actual = JSON.parse(readFileSync(join(evidence, `network-${service}.json`))) + assert.equal(actual.service, service) + assert.equal(actual.privileged, false) + assert.equal(Object.keys(actual.ports || {}).length, 0, 'no published ports') + assert.deepEqual(Object.keys(actual.networks), [`${process.env.COMPOSE_PROJECT_NAME}_isolated`]) + assert.equal(actual.networkMode, `${process.env.COMPOSE_PROJECT_NAME}_isolated`) + for (const mount of actual.mounts) { + assert.ok(allowed.includes(mount.Destination), `unexpected mount destination in ${service}`) + assert.ok(!(mount.Source || '').includes('docker.sock'), 'no Docker socket') + if (mount.Destination.startsWith('/fixture/')) assert.equal(mount.RW, false) + } + } + save('topology-result.json', { status: 'passed', services: Object.keys(destinations), internal: true }) +} + +function upstream() { + mkdirSync(evidence, { recursive: true }) + const captures = [] + const rejected = [] + let refuseNext = false + const json = (res, status, value) => { + res.writeHead(status, { 'content-type': 'application/json' }) + res.end(JSON.stringify(value)) + } + createServer({ + key: readFileSync('/opt/fixture/tls/key.pem'), + cert: readFileSync('/opt/fixture/tls/cert.pem'), + }, async (req, res) => { + // Deliberately never retain request headers, complete bodies or URL queries. + const path = new URL(req.url, upstreamOrigin).pathname + if (req.method === 'GET' && path === '/health') return json(res, 200, { status: 'fixture-only' }) + if (req.method === 'GET' && path === '/__fixture/captures') return json(res, 200, { captures, rejected }) + if (req.method === 'POST' && path === '/__fixture/refuse-next') { + refuseNext = true + return json(res, 200, { armed: true }) + } + // Explicitly reject the app's optional pricing refresh; this is not a fake + // pricing response. The packaged application fallback remains in use. + if (req.method === 'GET' && ['/disabled-pricing', '/disabled-pricing-hash'].includes(path)) { + return json(res, 503, { error: 'fixture pricing refresh disabled' }) + } + if (!((req.method === 'GET' && path === '/v1/models') || (req.method === 'POST' && path === '/v1/messages'))) { + rejected.push({ method: req.method, path }) + save('upstream-rejected.json', rejected) + return json(res, 404, { error: 'unexpected fixture path' }) + } + const alias = ({ 'fixture-only-key-a': 'a', 'fixture-only-key-b': 'b' })[req.headers['x-api-key']] + if (!alias) { + rejected.push({ method: req.method, path, reason: 'fixture credentials required' }) + save('upstream-rejected.json', rejected) + return json(res, 401, { error: 'fixture credentials required' }) + } + if (req.method === 'GET' && path === '/v1/models') { + return json(res, 200, { + data: [{ id: model, type: 'model', display_name: model, created_at: '2026-01-01T00:00:00Z' }], + has_more: false, first_id: model, last_id: model, + }) + } + try { + const chunks = [] + let size = 0 + for await (const chunk of req) { + size += chunk.length + assert.ok(size <= 256 * 1024, 'fixture input bound') + chunks.push(chunk) + } + const input = JSON.parse(Buffer.concat(chunks)) + assert.equal(input.model, model) + assert.equal(input.stream, true) + assert.equal(input.messages.length, 1) + assert.equal(input.messages[0].role, 'user') + const content = input.messages[0].content + const prompt = typeof content === 'string' ? content : content.filter(x => x.type === 'text').map(x => x.text).join('') + assert.ok(prompt.length > 0) + const sequence = captures.length + 1 + const marker = `fixture795-${sequence}` + const refused = refuseNext + refuseNext = false + const capture = { sequence, marker, alias, model: input.model, prompt, refused } + captures.push(capture) + appendFileSync(join(evidence, 'provider-captures.jsonl'), JSON.stringify(capture) + '\n') + res.writeHead(200, { 'content-type': 'text/event-stream', 'cache-control': 'no-cache' }) + const event = data => res.write(`event: ${data.type}\ndata: ${JSON.stringify(data)}\n\n`) + event({ type: 'message_start', message: { + id: `msg_fixture_${sequence}`, type: 'message', role: 'assistant', model, + content: [], stop_reason: null, usage: { input_tokens: 40, output_tokens: 0 }, + } }) + if (!refused) { + const html = `${marker}

${marker}

` + event({ type: 'content_block_start', index: 0, content_block: { type: 'text', text: '' } }) + event({ type: 'content_block_delta', index: 0, delta: { type: 'text_delta', text: html } }) + event({ type: 'content_block_stop', index: 0 }) + } + event({ type: 'message_delta', delta: refused + ? { stop_reason: 'refusal', stop_details: { type: 'refusal', category: 'fixture-deterministic' } } + : { stop_reason: 'end_turn', stop_sequence: null }, usage: { output_tokens: refused ? 1 : 100 } }) + event({ type: 'message_stop' }) + res.end() + } catch { + rejected.push({ method: req.method, path, reason: 'fixture input contract rejected' }) + save('upstream-rejected.json', rejected) + if (!res.headersSent) json(res, 400, { error: 'fixture input contract rejected' }) + else res.end() + } + }).listen(4199, '0.0.0.0') +} + +async function browser() { + const require = createRequire('/opt/fixture/package.json') + const { chromium } = require('playwright') + const { Client } = require('pg') + const origin = process.env.APP_ORIGIN + assert.equal(origin, 'http://app:8080', 'fixture origin only') + const state = { full_acceptance_complete: false, scenarios: [], blocked: [], requestFailures: [], pageErrors: [], consoleErrors: [] } + const declared = JSON.parse(readFileSync('/fixture/acceptance.json')) + save('acceptance.json', declared) + const db = new Client({ connectionTimeoutMillis: 5000, statement_timeout: 5000 }) + const browser = await chromium.launch({ headless: true }) + const context = await browser.newContext({ viewport: { width: 1440, height: 1100 }, locale: 'en-US', serviceWorkers: 'block' }) + let page + let stage = 'normal-authentication' + try { + await db.connect() + const { rows: accounts } = await db.query("SELECT id::text, name FROM accounts WHERE name IN ('fixture-pelican-a', 'fixture-pelican-b') ORDER BY name") + assert.equal(accounts.length, 2) + const { rows: groups } = await db.query("SELECT id::text, name FROM groups WHERE name = 'fixture-pelican-group'") + assert.equal(groups.length, 1) + save('fixture-entities.json', { accounts, groups }) + await context.route('**/*', async route => { + const url = new URL(route.request().url()) + if (url.origin === origin || ['data:', 'blob:', 'about:'].includes(url.protocol)) return route.continue() + state.blocked.push({ method: route.request().method(), origin: url.origin, path: url.pathname }) + await route.abort('blockedbyclient') + }) + await context.routeWebSocket('**/*', ws => { + const url = new URL(ws.url()) + if (url.origin === 'ws://app:8080') ws.connectToServer() + else { + state.blocked.push({ method: 'WEBSOCKET', origin: url.origin, path: url.pathname }) + ws.close() + } + }) + page = await context.newPage() + page.setDefaultTimeout(20_000) + page.on('requestfailed', request => { + const url = new URL(request.url()) + state.requestFailures.push({ method: request.method(), path: url.pathname, reason: request.failure()?.errorText }) + }) + // Console text and exception messages can contain application data. Retain + // only their types; scenario assertion failures carry safe fixture context. + page.on('pageerror', error => state.pageErrors.push({ name: error.name })) + page.on('console', message => { if (message.type() === 'error') state.consoleErrors.push({ type: 'error' }) }) + const manualRequests = [] + let prepareCount = 0 + page.on('request', request => { + const path = new URL(request.url()).pathname + if (path === '/api/v1/admin/accounts/pelican-question' && request.method() === 'GET') prepareCount++ + const match = path.match(/^\/api\/v1\/admin\/accounts\/(\d+)\/pelican-test$/) + if (match && request.method() === 'POST') { + const input = request.postDataJSON() + manualRequests.push({ account_id: match[1], model_id: input.model_id, prompt: input.prompt, + prompt_mode: input.prompt_mode, pelican_question: input.pelican_question }) + } + }) + await page.goto(`${origin}/login`) + await page.locator('#email').fill('reviewer@example.invalid') + await page.locator('#password').fill('Fixture-Only-795-Password!') + const login = page.waitForResponse(response => new URL(response.url()).pathname === '/api/v1/auth/login' && response.request().method() === 'POST') + await page.locator('button[type=submit]').click() + assert.equal((await login).status(), 200) + await page.waitForURL(url => url.pathname !== '/login') + await page.goto(`${origin}/admin/accounts`) + await page.getByRole('row').filter({ hasText: accounts[0].name }).waitFor() + assert.ok(await page.locator('link[rel=stylesheet]').count(), 'real application CSS loaded') + state.scenarios.push({ name: stage, status: 'passed', entry: '/admin/accounts' }) + + const dialog = () => page.getByRole('dialog').filter({ has: page.getByTestId('question-select') }) + async function openAccount(account) { + const row = page.getByRole('row').filter({ hasText: account.name }) + await row.getByRole('button', { name: 'More', exact: true }).click() + await page.locator('.action-menu-content').getByRole('button', { name: 'Intelligence test', exact: true }).click() + await dialog().getByTestId('question-select').getByRole('button').click() + await page.getByRole('option', { name: 'Pelican riding a bicycle (HTML)', exact: true }).click() + } + async function readRecords(account) { + return page.evaluate(id => JSON.parse(localStorage.getItem(`sub2api-pelican-test:${id}`) || '[]'), account.id) + } + async function checkSnapshot(root, config) { + const snapshot = root.getByTestId('pelican-question-snapshot') + await snapshot.locator('summary').click() + await snapshot.locator('pre').waitFor({ state: 'visible' }) + assert.equal(await snapshot.locator('pre').innerText(), config.actual_prompt) + assert.ok((await snapshot.innerText()).includes(config.pelican_question.round_id)) + assert.ok((await snapshot.locator('summary').innerText()).includes(config.pelican_question.id)) + assert.ok((await snapshot.locator('summary').innerText()).includes(config.pelican_question.version)) + } + async function runSamples(account, config) { + if (!(await dialog().getByTestId('manual-model-input').isVisible())) { + await dialog().getByTestId('model-input-toggle').click() + } + await dialog().getByTestId('manual-model-input').fill(model) + await dialog().locator('input[type=number]').fill('2') + await dialog().getByRole('button', { name: 'Start test', exact: true }).click() + await page.waitForFunction(id => { + const records = JSON.parse(localStorage.getItem(`sub2api-pelican-test:${id}`) || '[]') + return records[0]?.runs?.length === 2 && records[0].runs.every(run => run.status === 'success') + }, account.id, { timeout: 60_000 }) + const record = (await readRecords(account))[0] + assert.deepEqual(record.pelicanQuestion, config.pelican_question) + assert.equal(record.actualPrompt, config.actual_prompt) + for (const run of record.runs) assert.match(run.output, /fixture795-\d+/) + return record + } + + stage = 'manual-same-round-a-b-two-samples' + await openAccount(accounts[0]) + const prepare = page.waitForResponse(response => new URL(response.url()).pathname === '/api/v1/admin/accounts/pelican-question') + await dialog().getByTestId('pelican-mode-select').selectOption('random') + const prepared = await prepare + assert.equal(prepared.status(), 200) + const config = unwrap(await prepared.json()) + assert.match(config.pelican_question.round_id, /^manual:[a-f0-9]{32}$/) + await checkSnapshot(dialog(), config) + const aRecord = await runSamples(accounts[0], config) + await page.screenshot({ path: join(evidence, 'manual-a-same-round.png'), fullPage: true }) + await dialog().getByRole('button', { name: 'Close modal', exact: true }).click() + await openAccount(accounts[1]) + await dialog().getByTestId('pelican-mode-select').selectOption('random') + await checkSnapshot(dialog(), config) + const bRecord = await runSamples(accounts[1], config) + assert.equal(prepareCount, 1, 'account B reuses the prepared round') + assert.equal(manualRequests.length, 4) + for (const account of accounts) assert.equal(manualRequests.filter(request => request.account_id === account.id).length, 2) + for (const request of manualRequests) { + assert.equal(request.prompt_mode, 'random') + assert.equal(request.model_id, model) + assert.equal(request.prompt, config.actual_prompt) + assert.deepEqual(request.pelican_question, config.pelican_question) + } + const captured = await (await fetch(`${upstreamOrigin}/__fixture/captures`)).json() + assert.deepEqual(captured.rejected, []) + assert.equal(captured.captures.length, 4) + assert.equal(new Set([aRecord, bRecord].flatMap(record => record.runs.map(run => run.output.match(/fixture795-\d+/)[0]))).size, 4) + for (const alias of ['a', 'b']) assert.equal(captured.captures.filter(capture => capture.alias === alias).length, 2) + for (const [index, record] of [aRecord, bRecord].entries()) { + for (const run of record.runs) { + const marker = run.output.match(/fixture795-\d+/)[0] + const sent = captured.captures.find(capture => capture.marker === marker) + assert.ok(sent, 'each real localStorage output links to one provider capture') + assert.equal(sent.alias, index === 0 ? 'a' : 'b') + assert.equal(sent.model, model) + // This fixture's transport normalization boundary is UTF-8 text after + // the real service's TrimSpace. No claim about arbitrary input strings. + assert.equal(sent.prompt, config.actual_prompt.trim()) + assert.equal(sent.refused, false) + } + } + save('manual-api-projection.json', { prepared: config, requests: manualRequests }) + save('manual-history-projection.json', { [accounts[0].id]: aRecord, [accounts[1].id]: bRecord }) + state.scenarios.push({ name: stage, status: 'passed', samples: 4, round_id: config.pelican_question.round_id, + persistence: 'localStorage only; no manual PostgreSQL result claim' }) + + stage = 'manual-next-round-identity' + const next = page.waitForResponse(response => new URL(response.url()).pathname === '/api/v1/admin/accounts/pelican-question') + await dialog().getByTestId('pelican-next-round').click() + const nextResponse = await next + assert.equal(nextResponse.status(), 200) + const nextConfig = unwrap(await nextResponse.json()) + assert.notEqual(nextConfig.pelican_question.round_id, config.pelican_question.round_id) + // The random bank can legitimately choose the same question again. + save('manual-next-round.json', nextConfig) + state.scenarios.push({ name: stage, status: 'passed', question_repetition_permitted: true }) + + stage = 'manual-localstorage-reload-history-dom' + await page.reload() + assert.deepEqual((await readRecords(accounts[0]))[0], aRecord) + assert.deepEqual((await readRecords(accounts[1]))[0], bRecord) + await openAccount(accounts[1]) + await dialog().getByTestId('open-records').click() + const panel = page.getByTestId('records-panel') + await panel.getByTestId('pelican-record-card').first().waitFor() + assert.equal(await panel.getByTestId('pelican-record-card').count(), 2) + await panel.getByTestId('pelican-record-card').first().getByRole('button').click() + const detail = page.getByTestId('record-detail') + await checkSnapshot(detail, config) + const body = await detail.frameLocator('iframe').locator('body').innerText() + assert.ok(bRecord.runs.some(run => body.includes(run.output.match(/fixture795-\d+/)[0]))) + await page.screenshot({ path: join(evidence, 'manual-history-reloaded.png'), fullPage: true }) + state.scenarios.push({ name: stage, status: 'passed', cards: 2 }) + + stage = 'disabled-group-plan-real-ui-api-pg' + await page.goto(`${origin}/admin/pelican-tests`) + await page.getByTestId('pelican-tests-create').click() + const editor = page.getByTestId('pelican-test-editor') + await editor.getByRole('button').first().click() + await page.getByRole('option', { name: /fixture-pelican-group/ }).click() + await editor.getByTestId('pelican-test-model').fill(model) + await editor.getByTestId('pelican-mode-select').selectOption('random') + await editor.locator('#pelican-test-parallel').fill('2') + const enabled = editor.getByTestId('pelican-test-enabled') + if (await enabled.getAttribute('aria-checked') === 'true') await enabled.click() + const creation = page.waitForResponse(response => new URL(response.url()).pathname === '/api/v1/admin/pelican-group-tests' && response.request().method() === 'POST') + await page.getByTestId('pelican-test-save').click() + const createdResponse = await creation + assert.equal(createdResponse.status(), 200) + const created = unwrap(await createdResponse.json()) + const { rows } = await db.query('SELECT id::text, group_id::text, model_id, enabled, pelican_config FROM pelican_group_test_plans WHERE id = $1', [created.id]) + assert.equal(rows.length, 1) + assert.equal(rows[0].group_id, groups[0].id) + assert.equal(rows[0].model_id, model) + assert.equal(rows[0].enabled, false) + assert.equal(rows[0].pelican_config.prompt_mode, 'random') + assert.equal(rows[0].pelican_config.parallel_count, 2) + await page.getByTestId(`pelican-plan-${created.id}`).waitFor() + save('disabled-group-plan-projection.json', { api: { id: created.id, group_id: created.group_id, + model_id: created.model_id, enabled: created.enabled, pelican_config: created.pelican_config }, pg: rows[0] }) + await page.screenshot({ path: join(evidence, 'group-plan-created-disabled.png'), fullPage: true }) + state.scenarios.push({ name: stage, status: 'passed', plan_id: created.id, + boundary: 'disabled creation only; no scheduled RunDue, /run or result acceptance claimed' }) + + stage = 'browser-and-provider-error-lists' + const finalCaptures = await (await fetch(`${upstreamOrigin}/__fixture/captures`)).json() + assert.deepEqual(finalCaptures.rejected, []) + assert.equal(state.blocked.length, 0, 'browser may contact only app origin') + assert.equal(state.pageErrors.length, 0, 'no uncaught browser errors') + assert.equal(state.consoleErrors.length, 0, 'no browser console errors') + assert.equal(state.requestFailures.length, 0, 'no failed browser requests') + state.scenarios.push({ name: stage, status: 'passed' }) + console.log('Implemented initial E2E scenarios passed; full acceptance remains incomplete.') + } catch (error) { + state.scenarios.push({ name: stage, status: 'failed', error: { name: error.name, message: error.message.slice(0, 2000) } }) + if (page) { + try { await page.screenshot({ path: join(evidence, 'failure.png'), fullPage: true }) } catch { /* retain original failure */ } + } + console.error(`Isolated E2E failed in scenario: ${stage}`) + process.exitCode = 1 + } finally { + save('scenario-results.json', state) + await context.close() + await browser.close() + await db.end() + } +} + +try { + if (mode === 'upstream') upstream() + else if (mode === 'upstream-health') { + const response = await fetch(`${upstreamOrigin}/health`) + assert.equal(response.status, 200) + } else if (mode === 'topology') topology() + else if (mode === 'browser') await browser() + else throw new Error('Expected upstream, upstream-health, topology or browser mode') +} catch (error) { + // All modes operate on fictional inputs only. Never serialize request + // objects, env, headers, database clients or browser authentication state. + try { save('fixture-mode-error.json', { mode, name: error.name, message: error.message.slice(0, 2000) }) } catch { /* evidence directory may not exist */ } + console.error(`Fixture mode failed: ${mode} (${error.name})`) + process.exitCode = 1 +} diff --git a/.github/workflows/pelican-random-questions.yml b/.github/workflows/pelican-random-questions.yml index db9d67a83c3c..add59ea82aff 100644 --- a/.github/workflows/pelican-random-questions.yml +++ b/.github/workflows/pelican-random-questions.yml @@ -1,13 +1,40 @@ name: Pelican random question evidence on: + # A new workflow on a feature branch can run on pull_request immediately; + # workflow_dispatch is available only after this workflow reaches the default branch. + workflow_dispatch: pull_request: branches: [production] paths: - 'backend/internal/service/pelican*' + - 'backend/internal/service/scheduled_test*' + - 'backend/internal/service/account_test*' + - 'backend/internal/handler/admin/*pelican*' + - 'backend/internal/handler/admin/account*' + - 'backend/internal/handler/admin/scheduled_test*' + - 'backend/internal/repository/*pelican*' + - 'backend/internal/repository/account*' + - 'backend/internal/repository/scheduled_test*' + - 'backend/internal/server/routes/admin*' + - 'backend/internal/config/**' + - 'backend/internal/util/urlvalidator/**' + - 'backend/migrations/**' + - 'frontend/src/api/admin/accounts*' + - 'frontend/src/api/admin/pelicanTests*' + - 'frontend/src/api/admin/scheduledTests*' + - 'frontend/src/views/admin/AccountsView.vue' + - 'frontend/src/views/admin/PelicanTestsView.vue' + - 'frontend/src/utils/pelican*' + - 'frontend/src/types/**' + - 'frontend/src/components/admin/account/ScheduledTestsPanel.vue' - 'frontend/src/components/admin/account/Pelican*' - 'frontend/src/components/admin/account/IQTestModal.vue' + - '.github/fixtures/pelican-question-e2e/**' + - '.github/scripts/pelican-question-e2e.mjs' - '.github/scripts/pelican-question-browser.mjs' - '.github/workflows/pelican-random-questions.yml' + - 'Dockerfile' + - '.dockerignore' permissions: contents: read jobs: @@ -17,7 +44,7 @@ jobs: steps: - uses: actions/checkout@v6 with: - ref: ${{ github.event.pull_request.head.sha }} + ref: ${{ github.event.pull_request.head.sha || github.sha }} fetch-depth: 0 - run: bash .github/scripts/ci-ubuntu-mirrors.sh - uses: pnpm/action-setup@v6 @@ -45,3 +72,101 @@ jobs: with: name: pelican-random-question-ui-${{ github.run_id }} path: evidence/ + isolated-e2e: + name: Isolated application E2E (initial scope; full acceptance pending) + runs-on: ubuntu-latest + timeout-minutes: 45 + env: + APP_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + HARNESS_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + PARENT_BASE_SHA: 3e07fa89096cb58b260c032aa6de2cb2a2aa98b7 + COMPOSE_PROJECT_NAME: pelican-${{ github.run_id }}-${{ github.run_attempt }} + steps: + - uses: actions/checkout@v6 + with: + ref: ${{ env.HARNESS_SHA }} + path: harness + persist-credentials: false + - uses: actions/checkout@v6 + with: + ref: ${{ env.APP_SHA }} + path: app + persist-credentials: false + - name: Record the two immutable checkout identities + shell: bash + run: | + set -euo pipefail + export EVIDENCE_DIR="$RUNNER_TEMP/pelican-isolated-evidence" + printf 'EVIDENCE_DIR=%s\n' "$EVIDENCE_DIR" >> "$GITHUB_ENV" + mkdir -p "$EVIDENCE_DIR" + test "$(git -C app rev-parse HEAD)" = "$APP_SHA" + test "$(git -C harness rev-parse HEAD)" = "$HARNESS_SHA" + { + printf 'APP_SHA=%s\nAPP_TREE=%s\n' "$APP_SHA" "$(git -C app rev-parse 'HEAD^{tree}')" + printf 'HARNESS_SHA=%s\nHARNESS_TREE=%s\n' "$HARNESS_SHA" "$(git -C harness rev-parse 'HEAD^{tree}')" + printf 'PARENT_BASE_SHA=%s\nRUN_ID=%s\nRUN_ATTEMPT=%s\n' "$PARENT_BASE_SHA" "$GITHUB_RUN_ID" "$GITHUB_RUN_ATTEMPT" + } > "$EVIDENCE_DIR/identity.txt" + cp harness/.github/fixtures/pelican-question-e2e/acceptance.json "$EVIDENCE_DIR/acceptance.json" + - name: Build and prefetch before runtime isolation (CI only) + shell: bash + run: | + set -euo pipefail + docker build --build-arg COMMIT="$APP_SHA" --tag "pelican-app-base:$APP_SHA" app + docker build --target runner --tag "pelican-runner:$HARNESS_SHA" \ + --file harness/.github/fixtures/pelican-question-e2e/Dockerfile harness/.github + docker build --target app --build-arg "APP_IMAGE=pelican-app-base:$APP_SHA" \ + --tag "pelican-app:$APP_SHA" \ + --file harness/.github/fixtures/pelican-question-e2e/Dockerfile harness/.github + docker pull postgres:18-alpine + docker pull redis:7-alpine + - name: Start only the internal runtime network and real migrated application + working-directory: harness/.github/fixtures/pelican-question-e2e + shell: bash + run: | + set -euo pipefail + docker compose up --detach --no-build --pull never --wait --wait-timeout 180 postgres redis fake-upstream app + docker compose exec -T postgres psql --username fixture --dbname fixture --set ON_ERROR_STOP=1 < seed.sql + # Start the browser as a service (not `compose run` with a second network). + docker compose up --detach --no-build --pull never browser + docker network inspect "${COMPOSE_PROJECT_NAME}_isolated" \ + --format '{{json .Internal}}' > "$EVIDENCE_DIR/network-internal.json" + test "$(cat "$EVIDENCE_DIR/network-internal.json")" = true + for service in postgres redis fake-upstream app browser; do + container_id="$(docker compose ps --all --quiet "$service")" + test -n "$container_id" + docker inspect "$container_id" --format \ + '{"service":{{json (index .Config.Labels "com.docker.compose.service")}},"networks":{{json .NetworkSettings.Networks}},"ports":{{json .HostConfig.PortBindings}},"networkMode":{{json .HostConfig.NetworkMode}},"privileged":{{json .HostConfig.Privileged}},"mounts":{{json .Mounts}}}' \ + > "$EVIDENCE_DIR/network-$service.json" + done + node ../../scripts/pelican-question-e2e.mjs topology + - name: Wait for the browser's implemented scenarios + working-directory: harness/.github/fixtures/pelican-question-e2e + shell: bash + run: | + set -euo pipefail + container_id="$(docker compose ps --all --quiet browser)" + result="$(timeout 300s docker wait "$container_id")" + # Harness logs contain only scenario names/status, never response bodies or tokens. + docker compose logs --no-color browser + test "$result" = 0 + - name: Explicit acceptance boundary + if: always() + shell: bash + run: | + { + echo '### Isolated E2E initial increment — full acceptance pending' + echo 'This job exercises the implemented manual scenarios and disabled group-plan creation only.' + echo 'Account/group scheduled RunDue, PG/API/DOM result reconciliation, immutable old snapshots,' + echo 'second nominal round, deterministic failed record and lease release remain unimplemented.' + echo 'A green initial job does not clear the Issue #795 technical or product acceptance gates.' + } >> "$GITHUB_STEP_SUMMARY" + - name: Destroy all disposable runtime containers and volumes + if: always() + working-directory: harness/.github/fixtures/pelican-question-e2e + run: docker compose down --volumes --remove-orphans --timeout 10 + - uses: actions/upload-artifact@v7 + if: always() + with: + name: pelican-isolated-e2e-${{ github.run_id }}-${{ github.run_attempt }} + path: ${{ env.EVIDENCE_DIR }}/ + retention-days: 7 From a3ccb71dd724a4b643216e8e5b55448ee9f3b3a1 Mon Sep 17 00:00:00 2001 From: ranxi2001 Date: Thu, 12 Nov 2026 19:27:23 +0800 Subject: [PATCH 2/8] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=9A=94=E7=A6=BB?= =?UTF-8?q?=20E2E=20=E8=AF=81=E6=8D=AE=E7=9B=AE=E5=BD=95=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=B9=B6=E4=BF=9D=E7=95=99=E6=B5=8F=E8=A7=88=E5=99=A8=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/fixtures/pelican-question-e2e/README.md | 4 ++++ .../fixtures/pelican-question-e2e/compose.yml | 4 ++++ .github/scripts/pelican-question-e2e.mjs | 16 +++++++++++----- .github/workflows/pelican-random-questions.yml | 3 ++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/fixtures/pelican-question-e2e/README.md b/.github/fixtures/pelican-question-e2e/README.md index 43cf34fcd434..c03e65f52521 100644 --- a/.github/fixtures/pelican-question-e2e/README.md +++ b/.github/fixtures/pelican-question-e2e/README.md @@ -34,3 +34,7 @@ GitHub `pull_request`(base 为 `production`,包含 fixture/script/workflow CI artifact 预期包含应用/harness SHA/tree、显式未完成清单、命名场景结果、网络结构投影、仅限 fixture 题面的 provider captures(无认证头/全量 body)、真实手动请求/题面投影、本轮 localStorage 结果投影、必要的实体/计划 PG 投影、浏览器错误/拒绝清单和截图。比较 `actual_prompt` 的边界是本 fixture 的 UTF-8 文本经过真实 service TrimSpace 后的发送值,不能外推任意输入。 不导出 auth token、Cookie、完整 HAR、数据库全表、凭据列、原始应用日志或真实用户数据。不把整个运行目录当附件。fixture 密码/key/CA 都是本轮自建假值,不能用到任何其他环境。失败时也留存上述受限产物,`always()` 销毁容器、网络和一次性卷,artifact 保留七天。父协调者首次远程运行前需审查此增量,发布后仍须按原 brief 继续同一 PR 的未完成范围。 + +## 证据目录权限 + +浏览器与假上游容器使用 CI runner 的 UID/GID,保持 `cap_drop: ALL` 和只读根文件系统。证据目录由同一 runner 创建,因此无需增加 DAC_OVERRIDE 或放宽目录权限。网络结构投影核对这两个容器的实际用户;浏览器启动失败也写入场景结果。 diff --git a/.github/fixtures/pelican-question-e2e/compose.yml b/.github/fixtures/pelican-question-e2e/compose.yml index db375de2075f..82cc44ab5b68 100644 --- a/.github/fixtures/pelican-question-e2e/compose.yml +++ b/.github/fixtures/pelican-question-e2e/compose.yml @@ -36,6 +36,8 @@ services: fake-upstream: <<: *runtime image: pelican-runner:${HARNESS_SHA:?required} + # Bind-mounted evidence belongs to the Actions runner; root has no DAC override. + user: "${FIXTURE_UID:?required}:${FIXTURE_GID:?required}" command: [upstream] read_only: true volumes: ["${EVIDENCE_DIR:?required}:/evidence"] @@ -80,6 +82,8 @@ services: browser: <<: *runtime image: pelican-runner:${HARNESS_SHA:?required} + # Bind-mounted evidence belongs to the Actions runner; root has no DAC override. + user: "${FIXTURE_UID:?required}:${FIXTURE_GID:?required}" command: [browser] read_only: true shm_size: 1gb diff --git a/.github/scripts/pelican-question-e2e.mjs b/.github/scripts/pelican-question-e2e.mjs index 70c826b792e0..283f691419f8 100644 --- a/.github/scripts/pelican-question-e2e.mjs +++ b/.github/scripts/pelican-question-e2e.mjs @@ -27,6 +27,9 @@ function topology() { const actual = JSON.parse(readFileSync(join(evidence, `network-${service}.json`))) assert.equal(actual.service, service) assert.equal(actual.privileged, false) + if (['browser', 'fake-upstream'].includes(service)) { + assert.equal(actual.user, `${process.env.FIXTURE_UID}:${process.env.FIXTURE_GID}`) + } assert.equal(Object.keys(actual.ports || {}).length, 0, 'no published ports') assert.deepEqual(Object.keys(actual.networks), [`${process.env.COMPOSE_PROJECT_NAME}_isolated`]) assert.equal(actual.networkMode, `${process.env.COMPOSE_PROJECT_NAME}_isolated`) @@ -141,11 +144,14 @@ async function browser() { const declared = JSON.parse(readFileSync('/fixture/acceptance.json')) save('acceptance.json', declared) const db = new Client({ connectionTimeoutMillis: 5000, statement_timeout: 5000 }) - const browser = await chromium.launch({ headless: true }) - const context = await browser.newContext({ viewport: { width: 1440, height: 1100 }, locale: 'en-US', serviceWorkers: 'block' }) + let browser + let context let page - let stage = 'normal-authentication' + let stage = 'browser-startup' try { + browser = await chromium.launch({ headless: true }) + context = await browser.newContext({ viewport: { width: 1440, height: 1100 }, locale: 'en-US', serviceWorkers: 'block' }) + stage = 'normal-authentication' await db.connect() const { rows: accounts } = await db.query("SELECT id::text, name FROM accounts WHERE name IN ('fixture-pelican-a', 'fixture-pelican-b') ORDER BY name") assert.equal(accounts.length, 2) @@ -362,8 +368,8 @@ async function browser() { process.exitCode = 1 } finally { save('scenario-results.json', state) - await context.close() - await browser.close() + await context?.close() + await browser?.close() await db.end() } } diff --git a/.github/workflows/pelican-random-questions.yml b/.github/workflows/pelican-random-questions.yml index add59ea82aff..90d5550b4e27 100644 --- a/.github/workflows/pelican-random-questions.yml +++ b/.github/workflows/pelican-random-questions.yml @@ -98,6 +98,7 @@ jobs: set -euo pipefail export EVIDENCE_DIR="$RUNNER_TEMP/pelican-isolated-evidence" printf 'EVIDENCE_DIR=%s\n' "$EVIDENCE_DIR" >> "$GITHUB_ENV" + printf 'FIXTURE_UID=%s\nFIXTURE_GID=%s\n' "$(id -u)" "$(id -g)" >> "$GITHUB_ENV" mkdir -p "$EVIDENCE_DIR" test "$(git -C app rev-parse HEAD)" = "$APP_SHA" test "$(git -C harness rev-parse HEAD)" = "$HARNESS_SHA" @@ -135,7 +136,7 @@ jobs: container_id="$(docker compose ps --all --quiet "$service")" test -n "$container_id" docker inspect "$container_id" --format \ - '{"service":{{json (index .Config.Labels "com.docker.compose.service")}},"networks":{{json .NetworkSettings.Networks}},"ports":{{json .HostConfig.PortBindings}},"networkMode":{{json .HostConfig.NetworkMode}},"privileged":{{json .HostConfig.Privileged}},"mounts":{{json .Mounts}}}' \ + '{"service":{{json (index .Config.Labels "com.docker.compose.service")}},"networks":{{json .NetworkSettings.Networks}},"ports":{{json .HostConfig.PortBindings}},"networkMode":{{json .HostConfig.NetworkMode}},"privileged":{{json .HostConfig.Privileged}},"user":{{json .Config.User}},"mounts":{{json .Mounts}}}' \ > "$EVIDENCE_DIR/network-$service.json" done node ../../scripts/pelican-question-e2e.mjs topology From aba462d8a352bd62a4ede12e0374eb10446152a0 Mon Sep 17 00:00:00 2001 From: ranxi2001 Date: Thu, 12 Nov 2026 19:27:35 +0800 Subject: [PATCH 3/8] =?UTF-8?q?fix:=20=E5=85=81=E8=AE=B8=E9=9A=94=E7=A6=BB?= =?UTF-8?q?=20fixture=20=E7=94=A8=E6=88=B7=E8=AF=BB=E5=8F=96=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E6=80=A7=20TLS=20=E7=A7=81=E9=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/fixtures/pelican-question-e2e/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/fixtures/pelican-question-e2e/Dockerfile b/.github/fixtures/pelican-question-e2e/Dockerfile index e2da8800b636..c15b508a4585 100644 --- a/.github/fixtures/pelican-question-e2e/Dockerfile +++ b/.github/fixtures/pelican-question-e2e/Dockerfile @@ -8,7 +8,8 @@ RUN mkdir -p /opt/fixture/tls && \ openssl req -x509 -newkey rsa:2048 -nodes -days 7 \ -subj '/CN=fake-upstream' -addext 'subjectAltName=DNS:fake-upstream' \ -addext 'basicConstraints=critical,CA:TRUE' \ - -keyout /opt/fixture/tls/key.pem -out /opt/fixture/tls/cert.pem + -keyout /opt/fixture/tls/key.pem -out /opt/fixture/tls/cert.pem && \ + chmod 644 /opt/fixture/tls/key.pem COPY scripts/pelican-question-e2e.mjs /opt/fixture/pelican-question-e2e.mjs ENV NODE_EXTRA_CA_CERTS=/opt/fixture/tls/cert.pem ENTRYPOINT ["node", "/opt/fixture/pelican-question-e2e.mjs"] From 4e459e3067663c9abf9fc7e0af256af79c1220b1 Mon Sep 17 00:00:00 2001 From: ranxi2001 Date: Thu, 12 Nov 2026 19:38:44 +0800 Subject: [PATCH 4/8] =?UTF-8?q?fix:=20=E5=AE=8C=E6=88=90=E9=9A=94=E7=A6=BB?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E9=A6=96=E6=AC=A1=E7=99=BB=E5=BD=95=E5=B9=B6?= =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E5=8A=A0=E8=BD=BD=20Airwallex=20SDK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fixtures/pelican-question-e2e/README.md | 4 ++++ .github/scripts/pelican-question-e2e.mjs | 21 +++++++++++++++---- frontend/vite.config.ts | 5 +++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/fixtures/pelican-question-e2e/README.md b/.github/fixtures/pelican-question-e2e/README.md index c03e65f52521..e8454782229f 100644 --- a/.github/fixtures/pelican-question-e2e/README.md +++ b/.github/fixtures/pelican-question-e2e/README.md @@ -38,3 +38,7 @@ CI artifact 预期包含应用/harness SHA/tree、显式未完成清单、命名 ## 证据目录权限 浏览器与假上游容器使用 CI runner 的 UID/GID,保持 `cap_drop: ALL` 和只读根文件系统。证据目录由同一 runner 创建,因此无需增加 DAC_OVERRIDE 或放宽目录权限。网络结构投影核对这两个容器的实际用户;浏览器启动失败也写入场景结果。 + +## 首次登录与支付 SDK + +全新 fixture 正常完成引导退出与管理员声明确认,均由真实 UI 操作,不注入 localStorage 或伪造认证状态。登录 redirect 直接进入账号页,避免立即整页跳转取消初始化请求。隔离 job 同时发现 Airwallex SDK 被公共 vendor-misc 提前加载;本 PR 将该 SDK 独立分包,仍仅由现有支付页动态 import,账号页不应请求外部支付脚本。 diff --git a/.github/scripts/pelican-question-e2e.mjs b/.github/scripts/pelican-question-e2e.mjs index 283f691419f8..54c3ef1123d1 100644 --- a/.github/scripts/pelican-question-e2e.mjs +++ b/.github/scripts/pelican-question-e2e.mjs @@ -194,14 +194,26 @@ async function browser() { prompt_mode: input.prompt_mode, pelican_question: input.pelican_question }) } }) - await page.goto(`${origin}/login`) + await page.goto(`${origin}/login?redirect=/admin/accounts`) await page.locator('#email').fill('reviewer@example.invalid') await page.locator('#password').fill('Fixture-Only-795-Password!') const login = page.waitForResponse(response => new URL(response.url()).pathname === '/api/v1/auth/login' && response.request().method() === 'POST') await page.locator('button[type=submit]').click() assert.equal((await login).status(), 200) - await page.waitForURL(url => url.pathname !== '/login') - await page.goto(`${origin}/admin/accounts`) + await page.waitForURL(url => url.pathname === '/admin/accounts') + // Complete normal first-login UI on this disposable fixture installation. + // Do not inject consent/auth state or hide overlays with CSS. + await page.locator('.driver-popover').waitFor({ state: 'visible' }) + await page.keyboard.press('Escape') + await page.locator('.driver-popover').waitFor({ state: 'hidden' }) + const compliance = page.getByRole('dialog').filter({ has: page.locator('#admin-compliance-phrase') }) + await compliance.waitFor({ state: 'visible' }) + const phrase = await compliance.locator('label[for="admin-compliance-phrase"] + div').innerText() + await compliance.locator('#admin-compliance-phrase').fill(phrase) + const accepted = page.waitForResponse(response => new URL(response.url()).pathname === '/api/v1/admin/compliance/accept') + await compliance.getByRole('button', { name: 'Acknowledge and Continue', exact: true }).click() + assert.equal((await accepted).status(), 200) + await compliance.waitFor({ state: 'hidden' }) await page.getByRole('row').filter({ hasText: accounts[0].name }).waitFor() assert.ok(await page.locator('link[rel=stylesheet]').count(), 'real application CSS loaded') state.scenarios.push({ name: stage, status: 'passed', entry: '/admin/accounts' }) @@ -321,7 +333,8 @@ async function browser() { state.scenarios.push({ name: stage, status: 'passed', cards: 2 }) stage = 'disabled-group-plan-real-ui-api-pg' - await page.goto(`${origin}/admin/pelican-tests`) + await page.locator('a[href="/admin/pelican-tests"]').first().click() + await page.waitForURL(url => url.pathname === '/admin/pelican-tests') await page.getByTestId('pelican-tests-create').click() const editor = page.getByTestId('pelican-test-editor') await editor.getByRole('button').first().click() diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 5df99b8faa7e..071abf230315 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -144,6 +144,11 @@ export default defineConfig(({ mode }) => { return 'vendor-stripe' } + // SDK 模块初始化会加载外部脚本;仅在 Airwallex 支付页按需导入。 + if (id.includes('/@airwallex/components-sdk/')) { + return 'vendor-airwallex' + } + // 其他小型第三方库合并 return 'vendor-misc' } From 9916442a7f92145ec4922f87b8e553001bd98d6e Mon Sep 17 00:00:00 2001 From: ranxi2001 Date: Thu, 12 Nov 2026 19:41:31 +0800 Subject: [PATCH 5/8] =?UTF-8?q?test:=20=E6=AD=A3=E5=B8=B8=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E5=8E=86=E5=8F=B2=E5=BC=B9=E7=AA=97=E5=90=8E=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E5=AF=BC=E8=88=AA=E8=BF=9B=E5=85=A5=E5=88=86=E7=BB=84?= =?UTF-8?q?=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/scripts/pelican-question-e2e.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/scripts/pelican-question-e2e.mjs b/.github/scripts/pelican-question-e2e.mjs index 54c3ef1123d1..aedece003ad3 100644 --- a/.github/scripts/pelican-question-e2e.mjs +++ b/.github/scripts/pelican-question-e2e.mjs @@ -333,6 +333,9 @@ async function browser() { state.scenarios.push({ name: stage, status: 'passed', cards: 2 }) stage = 'disabled-group-plan-real-ui-api-pg' + await detail.getByRole('button', { name: 'Close', exact: true }).click() + await panel.getByRole('button', { name: 'Close', exact: true }).click() + await dialog().getByRole('button', { name: 'Close modal', exact: true }).click() await page.locator('a[href="/admin/pelican-tests"]').first().click() await page.waitForURL(url => url.pathname === '/admin/pelican-tests') await page.getByTestId('pelican-tests-create').click() From a91a1be00720799ee7de6ea28770a2379cf35683 Mon Sep 17 00:00:00 2001 From: ranxi2001 Date: Thu, 12 Nov 2026 19:46:14 +0800 Subject: [PATCH 6/8] =?UTF-8?q?test:=20=E9=A6=96=E6=AC=A1=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E7=A1=AE=E8=AE=A4=E5=90=8E=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E9=A1=B5=E5=B9=B6=E4=BF=9D=E7=95=99=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E8=AF=8A=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/fixtures/pelican-question-e2e/README.md | 2 ++ .github/scripts/pelican-question-e2e.mjs | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/fixtures/pelican-question-e2e/README.md b/.github/fixtures/pelican-question-e2e/README.md index e8454782229f..0407ef044b14 100644 --- a/.github/fixtures/pelican-question-e2e/README.md +++ b/.github/fixtures/pelican-question-e2e/README.md @@ -42,3 +42,5 @@ CI artifact 预期包含应用/harness SHA/tree、显式未完成清单、命名 ## 首次登录与支付 SDK 全新 fixture 正常完成引导退出与管理员声明确认,均由真实 UI 操作,不注入 localStorage 或伪造认证状态。登录 redirect 直接进入账号页,避免立即整页跳转取消初始化请求。隔离 job 同时发现 Airwallex SDK 被公共 vendor-misc 提前加载;本 PR 将该 SDK 独立分包,仍仅由现有支付页动态 import,账号页不应请求外部支付脚本。 + +管理员确认前已发出的页面读取会被真实合规中间件拒绝。脚本保留首次初始化阶段的错误列表,确认持久化后正常刷新页面,再对鹈鹕场景执行浏览器错误零值断言;不声称首次安装全过程无控制台错误。 diff --git a/.github/scripts/pelican-question-e2e.mjs b/.github/scripts/pelican-question-e2e.mjs index aedece003ad3..59a38549bdfd 100644 --- a/.github/scripts/pelican-question-e2e.mjs +++ b/.github/scripts/pelican-question-e2e.mjs @@ -214,6 +214,17 @@ async function browser() { await compliance.getByRole('button', { name: 'Acknowledge and Continue', exact: true }).click() assert.equal((await accepted).status(), 200) await compliance.waitFor({ state: 'hidden' }) + // Requests made before first-install acknowledgement are gated by the real + // middleware. Preserve their diagnostics, then reload the real page so its + // initial account query runs after acknowledgement has persisted. + await page.waitForLoadState('networkidle') + state.bootstrap = { blocked: [...state.blocked], requestFailures: [...state.requestFailures], + pageErrors: [...state.pageErrors], consoleErrors: [...state.consoleErrors] } + assert.equal(state.blocked.length, 0, 'bootstrap must not request external resources') + assert.equal(state.requestFailures.length, 0, 'bootstrap transport must complete') + state.pageErrors = [] + state.consoleErrors = [] + await page.reload() await page.getByRole('row').filter({ hasText: accounts[0].name }).waitFor() assert.ok(await page.locator('link[rel=stylesheet]').count(), 'real application CSS loaded') state.scenarios.push({ name: stage, status: 'passed', entry: '/admin/accounts' }) @@ -366,7 +377,7 @@ async function browser() { state.scenarios.push({ name: stage, status: 'passed', plan_id: created.id, boundary: 'disabled creation only; no scheduled RunDue, /run or result acceptance claimed' }) - stage = 'browser-and-provider-error-lists' + stage = 'post-bootstrap-browser-and-provider-error-lists' const finalCaptures = await (await fetch(`${upstreamOrigin}/__fixture/captures`)).json() assert.deepEqual(finalCaptures.rejected, []) assert.equal(state.blocked.length, 0, 'browser may contact only app origin') From 8f67db65b3c9575fd43661686599040af2285923 Mon Sep 17 00:00:00 2001 From: ranxi2001 Date: Thu, 12 Nov 2026 19:54:55 +0800 Subject: [PATCH 7/8] =?UTF-8?q?test:=20=E4=BB=8E=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=85=A5=E5=8F=A3=E9=AA=8C=E8=AF=81=E5=88=86?= =?UTF-8?q?=E7=BB=84=E8=AE=A1=E5=88=92=E5=B9=B6=E6=9B=B4=E6=96=B0=E8=AF=81?= =?UTF-8?q?=E6=8D=AE=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fixtures/pelican-question-e2e/README.md | 6 +++-- .../pelican-question-e2e/acceptance.json | 24 +++++++++---------- .github/scripts/pelican-question-e2e.mjs | 3 +-- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/fixtures/pelican-question-e2e/README.md b/.github/fixtures/pelican-question-e2e/README.md index 0407ef044b14..22d5addebfb1 100644 --- a/.github/fixtures/pelican-question-e2e/README.md +++ b/.github/fixtures/pelican-question-e2e/README.md @@ -1,4 +1,4 @@ -# Issue #795 隔离应用 E2E:首个待审增量 +# Issue #795 隔离应用 E2E:手动链路与禁用分组计划 Refs #795。本目录只提供 CI fixture,不修改应用业务代码,不表示完整验收、真实模型兼容性或经验难度校准完成。逐场景状态由 `acceptance.json` 声明;脚本即使成功,也固定输出 `full_acceptance_complete: false`。 @@ -25,7 +25,7 @@ GitHub `pull_request`(base 为 `production`,包含 fixture/script/workflow - [ ] 第二 nominal time T2 按现有哈希公式选到另一题,等待真实 tick,新旧记录共存;不能修改生产抽题算法。 - [ ] arm 单次 refusal 后真正产生 failed 持久化结果、失败历史及 lease 释放;现有 refusal server 能力尚未被此增量测试。 - [ ] 对结果/租约/到期字段进行限定 SQL 投影,与 API、capture 和场景 ID 关联。目前只有初始化实体与禁用分组计划投影,没有定时结果 SQL 证据。 -- [ ] 远程 Actions 首次运行、raw job log 定向修正、精确 head/check 回读。没有运行本地动态检查。 +- 远程 Actions、失败记录及当前 head 检查结论见 PR #809;场景结果以当次 artifact 为准。没有运行本地动态检查。 - [ ] 隔离链路真实截图上传 PR 原生附件并回读;现有组件 job 截图仍只是组件证据,不能混同此 job。无 PNG 提交到源码。 - [ ] 父协调者独审、完整技术验收与产品/经验难度证据。fixture 的简单 SVG 不代表题目作答合格或难度相当。 @@ -44,3 +44,5 @@ CI artifact 预期包含应用/harness SHA/tree、显式未完成清单、命名 全新 fixture 正常完成引导退出与管理员声明确认,均由真实 UI 操作,不注入 localStorage 或伪造认证状态。登录 redirect 直接进入账号页,避免立即整页跳转取消初始化请求。隔离 job 同时发现 Airwallex SDK 被公共 vendor-misc 提前加载;本 PR 将该 SDK 独立分包,仍仅由现有支付页动态 import,账号页不应请求外部支付脚本。 管理员确认前已发出的页面读取会被真实合规中间件拒绝。脚本保留首次初始化阶段的错误列表,确认持久化后正常刷新页面,再对鹈鹕场景执行浏览器错误零值断言;不声称首次安装全过程无控制台错误。 + +分组计划场景从固定页面地址进入,再使用真实表单创建计划;不依赖当前管理员可定制的侧栏菜单展开/隐藏状态,也不声称已验收侧栏导航。 diff --git a/.github/fixtures/pelican-question-e2e/acceptance.json b/.github/fixtures/pelican-question-e2e/acceptance.json index 8e5729f91c81..d16059c25d3f 100644 --- a/.github/fixtures/pelican-question-e2e/acceptance.json +++ b/.github/fixtures/pelican-question-e2e/acceptance.json @@ -1,15 +1,6 @@ { "scope": "initial-reviewable-increment", "full_acceptance_complete": false, - "implemented_not_remotely_verified": [ - "runtime internal Docker network for app, browser, fake provider, PostgreSQL and Redis", - "normal login and real accounts UI with original CSS", - "real prepare, account A and B with two samples each in one manual round", - "provider payload compared with API question and real DOM snapshot", - "manual localStorage recovery, history expansion and fixture iframe after reload", - "next manual round identity changes; repeated question selection is permitted", - "disabled group plan created through real browser form, create API and PG" - ], "unimplemented": [ "account scheduled plans created via UI, two samples per A and B", "same nominal UTC time, actual account runner Claim and four PG results", @@ -21,11 +12,18 @@ "restricted result/lease/due SQL projections linked to captures and API IDs" ], "pending_external_gates": [ - "all remote Actions execution and raw-log-driven corrections", "screenshots from successful isolated chain uploaded as PR native attachments and read back", - "exact published PR head and check readback by parent", - "independent parent review and merge decision", "product policy and empirical difficulty calibration; fixture output cannot prove either" ], - "fixture_transport_difference": "Uses fixture-only HTTPS and an ephemeral fixture CA, because the enabled real account-test URL allowlist calls ValidateHTTPSURL. The audit's proposed HTTP URL is not accepted with that allowlist enabled. No application validation is disabled or modified." + "fixture_transport_difference": "Uses fixture-only HTTPS and an ephemeral fixture CA, because the enabled real account-test URL allowlist calls ValidateHTTPSURL. The audit's proposed HTTP URL is not accepted with that allowlist enabled. No application validation is disabled or modified.", + "implemented_scenarios": [ + "runtime internal Docker network for app, browser, fake provider, PostgreSQL and Redis", + "normal login and real accounts UI with original CSS", + "real prepare, account A and B with two samples each in one manual round", + "provider payload compared with API question and real DOM snapshot", + "manual localStorage recovery, history expansion and fixture iframe after reload", + "next manual round identity changes; repeated question selection is permitted", + "disabled group plan created through real browser form, create API and PG" + ], + "verification_evidence": "Read scenario-results.json and the current PR head checks; this declaration does not assert runtime success." } diff --git a/.github/scripts/pelican-question-e2e.mjs b/.github/scripts/pelican-question-e2e.mjs index 59a38549bdfd..9c6d8e6e0735 100644 --- a/.github/scripts/pelican-question-e2e.mjs +++ b/.github/scripts/pelican-question-e2e.mjs @@ -347,8 +347,7 @@ async function browser() { await detail.getByRole('button', { name: 'Close', exact: true }).click() await panel.getByRole('button', { name: 'Close', exact: true }).click() await dialog().getByRole('button', { name: 'Close modal', exact: true }).click() - await page.locator('a[href="/admin/pelican-tests"]').first().click() - await page.waitForURL(url => url.pathname === '/admin/pelican-tests') + await page.goto(`${origin}/admin/pelican-tests`) await page.getByTestId('pelican-tests-create').click() const editor = page.getByTestId('pelican-test-editor') await editor.getByRole('button').first().click() From 02fdcf636f0f8cbabb851f335cc65cd16b44a712 Mon Sep 17 00:00:00 2001 From: ranxi2001 Date: Thu, 12 Nov 2026 20:03:47 +0800 Subject: [PATCH 8/8] =?UTF-8?q?test:=20=E7=AD=89=E5=BE=85=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E6=93=8D=E4=BD=9C=E6=8C=89=E9=92=AE=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E7=A8=B3=E5=AE=9A=E5=90=8E=E5=86=8D=E6=89=93=E5=BC=80=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fixtures/pelican-question-e2e/README.md | 2 ++ .github/scripts/pelican-question-e2e.mjs | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/fixtures/pelican-question-e2e/README.md b/.github/fixtures/pelican-question-e2e/README.md index 22d5addebfb1..c9c70d5adf58 100644 --- a/.github/fixtures/pelican-question-e2e/README.md +++ b/.github/fixtures/pelican-question-e2e/README.md @@ -46,3 +46,5 @@ CI artifact 预期包含应用/harness SHA/tree、显式未完成清单、命名 管理员确认前已发出的页面读取会被真实合规中间件拒绝。脚本保留首次初始化阶段的错误列表,确认持久化后正常刷新页面,再对鹈鹕场景执行浏览器错误零值断言;不声称首次安装全过程无控制台错误。 分组计划场景从固定页面地址进入,再使用真实表单创建计划;不依赖当前管理员可定制的侧栏菜单展开/隐藏状态,也不声称已验收侧栏导航。 + +账号菜单保留原有滚动时关闭行为;harness 先滚动定位并等待绘制稳定,再打开菜单。仅菜单已消失时允许至多两次重新打开,次数写入 `menuReopens`;生成请求不会重试。 diff --git a/.github/scripts/pelican-question-e2e.mjs b/.github/scripts/pelican-question-e2e.mjs index 9c6d8e6e0735..fb8484fbe9e4 100644 --- a/.github/scripts/pelican-question-e2e.mjs +++ b/.github/scripts/pelican-question-e2e.mjs @@ -232,8 +232,23 @@ async function browser() { const dialog = () => page.getByRole('dialog').filter({ has: page.getByTestId('question-select') }) async function openAccount(account) { const row = page.getByRole('row').filter({ hasText: account.name }) - await row.getByRole('button', { name: 'More', exact: true }).click() - await page.locator('.action-menu-content').getByRole('button', { name: 'Intelligence test', exact: true }).click() + const more = row.getByRole('button', { name: 'More', exact: true }) + // AccountsView closes its menu on table/window scroll. Let Playwright's + // scroll-to-button finish before opening the menu. Only menu navigation + // may be repeated; model submissions below are never retried. + for (let attempt = 0; attempt < 3; attempt++) { + await more.scrollIntoViewIfNeeded() + await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))) + await more.click() + try { + await page.locator('.action-menu-content').getByRole('button', { name: 'Intelligence test', exact: true }).click({ timeout: 5000 }) + break + } catch (error) { + if (await dialog().isVisible()) break + if (attempt === 2 || await page.locator('.action-menu-content').isVisible()) throw error + state.menuReopens = (state.menuReopens || 0) + 1 + } + } await dialog().getByTestId('question-select').getByRole('button').click() await page.getByRole('option', { name: 'Pelican riding a bicycle (HTML)', exact: true }).click() }