Skip to content

Add E2E tests for user roles and scope filtering#109

Open
erseco wants to merge 1 commit intomainfrom
feature-e2e-roles-and-scopes-8632494155142451783
Open

Add E2E tests for user roles and scope filtering#109
erseco wants to merge 1 commit intomainfrom
feature-e2e-roles-and-scopes-8632494155142451783

Conversation

@erseco
Copy link
Collaborator

@erseco erseco commented Mar 2, 2026

Added a Playwright E2E test file (tests/e2e/specs/documentate-roles-scope.spec.js) to verify the Documentate_Scope_Filter functionality logic and WordPress role capabilities mappings work well together.

The test ensures:

  • Administrator: Can see and interact with all documents in the CPT list view.
  • Editor: Can only see documents within their assigned documentate_scope_term_id and subcategories.
  • Author: Can only see their own created documents, within their assigned documentate_scope_term_id (this confirms author capabilities correctly mesh with scope filter).
  • Subscriber: Encounters a WP-die restricted access message when attempting to navigate to the documents list, properly enforcing capability barriers.

The script runs automated data setup for categories, users with specific scopes and posts using wp-env integration. All tests run locally via Playwright logic mimicking admin UI usage.


PR created automatically by Jules for task 8632494155142451783 started by @erseco

@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 367364d835

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +159 to +162
const newPage = await context.newPage();

// Login as editor
await newPage.goto( '/wp-login.php' );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use a fresh browser context before role-specific login

Using context.newPage() here reuses the test context's existing auth state, and this suite is configured to preload storage-states/admin.json in tests/e2e/playwright.config.js, so the page is already logged in as admin before the editor/author/subscriber login flow starts. In that state, visiting /wp-login.php does not provide the normal login form, so filling #user_login/#user_pass can fail (or keep the admin session), which makes the role-based scope assertions unreliable. Create an isolated browser context (or explicitly clear/logout auth) before attempting each non-admin login.

Useful? React with 👍 / 👎.

@erseco erseco force-pushed the feature-e2e-roles-and-scopes-8632494155142451783 branch from 367364d to 8f2dec2 Compare March 2, 2026 20:17
@erseco erseco force-pushed the feature-e2e-roles-and-scopes-8632494155142451783 branch from 8f2dec2 to e0424d9 Compare March 4, 2026 11:34
@erseco erseco force-pushed the feature-e2e-roles-and-scopes-8632494155142451783 branch from e0424d9 to 351a0d5 Compare March 4, 2026 20:11
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
@erseco erseco force-pushed the feature-e2e-roles-and-scopes-8632494155142451783 branch from 351a0d5 to 45cbcf1 Compare March 4, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant