Repository navigation
Commit 3f0e3ac
test(ui): the live member's API requests carry the member alone, not the inherited admin cookie (#31871)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi96VGP7vMPA9C54zyjz2LMch)_
Fixes #31827
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:夜间 live 层的成员夹具改为只用成员自己的凭据发 API 请求(成员自己的会话 cookie 加它的
Bearer),成员登录也从空状态开始;`read-only-member-record.spec.ts` 只换成调用新助手,断言一条未动。
- 为什么改:在 `@playwright/test` 里,不指定 `storageState` 新建的请求上下文会继承配置里的管理员
cookie,于是成员请求同时带着管理员 cookie 和成员 Bearer。#31469 起服务端拒绝这种「两个账号」的请求,数据路由回
401,夜间层因此变红。席位裁定:改夹具,不改产品。
- 风险与回滚:只动 `ui/e2e/live/` 下两个测试文件,不发布任何包,不动 `packages/`。回滚即 revert。
- 先看:`ui/e2e/live/member.ts` 的 `memberRequestContext` 和模块注释里的 ⛔ 段。
- 两分钟验证:起后端后跑 `OS_TEST_TIERS=nightly pnpm --filter
@objectstack/example-showcase exec vitest run
test/console-live-specs.live.test.ts`,预期 `28 passed`。
- 需要你做的:无,席位落地。
## What changes
- `ui/e2e/live/member.ts` gains `memberRequestContext(member)`: a
request context carrying the member's own session cookie and its Bearer,
with its `storageState` named so the config's administrator cookie is
not inherited.
- The member's sign-in context starts from an empty `storageState` (`{
cookies: [], origins: [] }`) instead of the inherited administrator
cookie, so the sign-in request names the member only.
- `read-only-member-record.spec.ts` builds its premise context with the
helper. That is its only change: the `playwright` fixture it no longer
uses leaves the destructuring, and no assertion moves.
- The module comment states the trap: inside `@playwright/test`,
`playwright.request.newContext()` and the imported
`request.newContext()` both start with the config's `use.storageState`.
No test was skipped, renamed or loosened. No change under `packages/`.
## Why
The nightly live tier went red at `6be71abc` on
`read-only-member-record.spec.ts:48`, premise step: the member's `GET
/api/v1/data/showcase_inquiry/<id>` answered 401 where 200 was expected.
Step 0 (seat ruling 6735238125):
- **Bisect.** Each commit measured on a fresh backend booted by
`ui/e2e/live/ci/start-backend.sh`, with the spec's request shape:
| Commit | Result |
|:--|:--|
| `44a030bf` (last green nightly) | green, read 200 / write 403 |
| `133f75aec0~1` | green, 200 / 403 |
| `133f75aec0` #31469 | **red**, 401 / 401 |
| `ed4b83226b` #31443 | red |
| `59630d9357` #31622 | red |
| `8c9260f79c` #31657 | red |
| `f127b04e07` #31686 | red |
| `6be71abc` (red nightly) | red |
- **Cause.** The member's context was `playwright.request.newContext({
extraHTTPHeaders: { Authorization: 'Bearer <member>' } })`. Inside
`@playwright/test` that context inherits the config's
`use.storageState`, which is the global setup's administrator cookie.
Measured: the context's cookie equals the administrator's. So each
premise request carried two accounts' credentials. Before #31469 the
bearer won. Since #31469 the session read refuses such a request with
`CREDENTIALS_NAME_DIFFERENT_ACCOUNTS`, and the data route answers its
own anonymous 401. #31469's acceptance notes describe exactly that
data-route answer, so the product behaves as ruled and the fixture
relied on what #31469 ruled out.
## Sweep (owed by the ruling)
Every live spec and helper under `ui/e2e/live/` that builds a request
context or sends a credential:
| Site | Accounts it sends | Action |
|:--|:--|:--|
| `read-only-member-record.spec.ts` premise context | admin cookie
(inherited) + member Bearer | **moved onto `memberRequestContext`** |
| `member.ts` sign-in context (`request.newContext()`) | admin cookie
(inherited) on the member's sign-in | **moved onto an empty
`storageState`** |
| `read-only-member-record.spec.ts` member browser context | member
`storageState` named explicitly | one account, unchanged |
| `global-setup.ts` sign-in context | none (global setup runs before any
`use` state exists) | one account, unchanged |
| `inline-edit-polish-2572.spec.ts` `request` + Bearer | admin cookie +
admin token from the same `state.json` | one account, unchanged |
| `studio-customize-journey.spec.ts` `request` override | `storageState`
passed by name (admin), no other credential | one account, unchanged |
| `studio-object-designer.spec.ts` in-page `fetch` | admin page's own
cookie + its own localStorage token | one account, unchanged |
| every other spec's `request.get/post/…` (cascading-options,
grid-file-upload, list-row-action-cel, master-detail,
record-form-direct-url, record-history-display) | admin `request`
fixture alone | one account, unchanged |
Measured for the two inherited sites: the imported
`request.newContext()` and `playwright.request.newContext()` each start
with 1 cookie under this config; with `storageState: { cookies: [],
origins: [] }` they start with 0.
## Verification
All heavy runs went through `scripts/pm/os-verify-lock.sh`. Head
`86082eb9b5`, backend closure and `pnpm console:build` rebuilt at the
head first.
- **Nightly live file, head:** `OS_TEST_TIERS=nightly pnpm exec vitest
run test/console-live-specs.live.test.ts` in `examples/app-showcase`:
Playwright `28 passed (1.3m)`, vitest `Test Files 1 passed (1)`, `Tests
1 passed (1)`.
- **Ablation:** `scripts/ablation-replace.mjs` deletes the helper's
`storageState` line in `member.ts` (anchor 1 → 0, blob `d4e1a39d33f5` →
`dc6c2ff0d686`), so the inherited administrator cookie is back. The same
run: `✘ read-only-member-record.spec.ts:48`, `Expected: 200`, `Received:
401`, `Test Files 1 failed (1)`. Restored: blob equals HEAD's
(`d4e1a39d33f5`), `git diff HEAD` empty, `git status --porcelain` empty.
- **Before the fix, on main `3487ccc1`:** the same nightly run was red,
1 of 28, the same 401.
- **Dispatch gates:** see the os-dev-report on #31827 for each command's
exit code and the `--ran` reconciliation; `pnpm lint` and `eslint` over
the two touched files are reported there too.
No changeset: the diff publishes nothing (`ui/e2e/live/` only), so this
PR carries `skip-changeset`.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(No `packages/spec` change.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset. (Publishes
nothing; `skip-changeset`.)
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English. (The 维护者速读 section is
the seat's required Chinese summary.)
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmPpwZNVKwJLQGotdJy
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmPpwZNVKwJLQGotdJy)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent bf06a50 commit 3f0e3ac
2 files changed
Lines changed: 27 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
29 | 39 | | |
30 | 40 | | |
31 | 41 | | |
| |||
68 | 78 | | |
69 | 79 | | |
70 | 80 | | |
71 | | - | |
| 81 | + | |
| 82 | + | |
72 | 83 | | |
73 | 84 | | |
74 | 85 | | |
| |||
90 | 101 | | |
91 | 102 | | |
92 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
| |||
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
69 | | - | |
| 68 | + | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
| |||
0 commit comments