Skip to content

test(e2e): fix permission write-race in environment-permission-test#7782

Closed
talissoncosta wants to merge 1 commit into
mainfrom
fix/e2e-permission-write-race
Closed

test(e2e): fix permission write-race in environment-permission-test#7782
talissoncosta wants to merge 1 commit into
mainfrom
fix/e2e-permission-write-race

Conversation

@talissoncosta

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

One of the intermittent E2E failures on the production deploy gate, distinct from the boot-loader deadlock (#7776) — here the app boots fine but environment-permission-test times out waiting for switch-environment-production after the permission to view it was just granted.

Two changes:

  • setUserPermission awaits the save. The helper toggled the permission switch and immediately closed the modal + logged out. The toggle saves async (POST/PUT to .../user-permissions/), so logout could abort the in-flight request and the grant never persisted — the next user then couldn't see the entity. The backend has no permission read-cache, so the lost write is the most likely cause. Now we await the /user-permissions/ response before closing the modal.
  • reloadUntilVisible helper. Belt-and-braces for the read side: the environment list is fetched once on navigation, so a just-granted VIEW_ENVIRONMENT can't appear by waiting on the same page — it needs a reload. Used for the 'User with permissions can see environment' assertion.

How did you test this code?

environment-permission-test reproduced the switch-environment-production timeout (app booted, env absent). Traced the grant to an un-awaited /user-permissions/ POST in setUserPermission. Locally re-ran the spec against production with the fix; the grant now persists and the env appears. As a timing race against shared prod state, the real signal is the deploy-gate pass rate.

Note: separate from the non-idempotent-seed failure (createEnvironment on a dirty seed) seen in project-permission-test — that's a teardown/seed-lifecycle issue, not addressed here.

setUserPermission toggled the permission and immediately closed the
modal, so logout could abort the in-flight POST/PUT to
/user-permissions/ and the grant never persisted — the next user then
couldn't see the entity (flaky 'switch-environment-production' timeout
in environment-permission-test). Await the save response before
closing.

Also add reloadUntilVisible for state that is only eventually
consistent across a fresh navigation: the env list is fetched on
navigation, so a just-granted VIEW_ENVIRONMENT needs a reload, not a
longer wait on the same page.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@talissoncosta talissoncosta requested a review from a team as a code owner June 15, 2026 12:14
@talissoncosta talissoncosta requested review from kyle-ssg and removed request for a team June 15, 2026 12:14
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Jun 15, 2026 12:14pm
flagsmith-frontend-staging Ready Ready Preview, Comment Jun 15, 2026 12:14pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Jun 15, 2026 12:14pm

Request Review

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-7782 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-7782 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-7782 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-7782 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-7782 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-7782 Finished ✅ Results

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  34.2 seconds
commit  e08faa1
info  🔄 Run: #17498 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  33.4 seconds
commit  e08faa1
info  🔄 Run: #17498 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  45.3 seconds
commit  e08faa1
info  🔄 Run: #17498 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  42.8 seconds
commit  e08faa1
info  🔄 Run: #17498 (attempt 1)

@github-actions

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

@talissoncosta

Copy link
Copy Markdown
Contributor Author

Superseded by #7785, which consolidates the E2E flakiness fixes into one branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

front-end Issue related to the React Front End Dashboard testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants