Skip to content

ci: add playwright-tests package-lock.json for e2e workflow caching#1566

Open
MrDirkelz wants to merge 7 commits into
mainfrom
1565-cms-app-write-and-ensure-end-2-end-tests-work
Open

ci: add playwright-tests package-lock.json for e2e workflow caching#1566
MrDirkelz wants to merge 7 commits into
mainfrom
1565-cms-app-write-and-ensure-end-2-end-tests-work

Conversation

@MrDirkelz

Copy link
Copy Markdown
Collaborator

No description provided.

@MrDirkelz MrDirkelz self-assigned this Apr 24, 2026
@MrDirkelz MrDirkelz linked an issue Apr 24, 2026 that may be closed by this pull request
MrDirkelz added 6 commits June 2, 2026 14:52
Add second test user for group authz specs

Include configuration for a second test user in the E2E workflow and
documentation. This user is used for group-based authorization testing,
ensuring that different users see distinct content sets based on their
group memberships.

Also adds new E2E tests for image caching, CMS login flow, creating,
deleting, publishing, and translating content, along with offline
editing
and synchronization capabilities. These tests exercise core CMS and
application functionality under various conditions.
This commit introduces a new environment variable,
`E2E_AUTH_PROVIDER_LABEL`,
to playwright-tests. This variable specifies the visible label of the
auth
provider button on the CMS sign-in screen, making the login process more
flexible and robust for end-to-end testing.

The README.md has been updated to include this new variable in the list
of
required configurations for running the tests, and the global setup
description has been modified to reference it.

Additionally, the `createTestPost` fixture has been enhanced to
correctly
handle cases where a new post might not initially have a title input
visible,
ensuring that a translation is added if necessary before proceeding.

The `db.ts` fixture now includes `listLanguageCodes` and
`findContentByParent`
helper functions to improve test data management and assertion
capabilities
within the CMS end-to-end tests.
The login flow in global-setup has been refactored to improve robustness
and provide better debugging capabilities. This includes:

- Enabling headed mode for debugging by default if `HEADED` or `PWDEBUG`
  environment variables are set.
- Capturing diagnostics (URL, title, screenshot) on login failure to aid
  in troubleshooting.
- Handling both single-page and two-page login flows more gracefully.
- Using `pressSequentially` for password input to better mimic user
  interaction.
- Adding a check to ensure the password field correctly captures the
  entered value.
- Including a best-effort click for consent/authorize screens that may
  appear post-login.
Handle incorrect credentials during login more efficiently. Previously,
the test would wait for the URL to change, which could take up to 30
seconds. Now, it also races this against the visibility of a credential
error message. If an error appears within 15 seconds, the test fails
faster, surfacing issues with bad credentials more quickly.
This commit refactors several CMS tests to improve their reliability and
maintainability. Key changes include:

- **Image Caching Tests:**
  - Removed `clearAllCaches` as Playwright contexts start with empty
    cache storage.
  - Added a timeout to `waitForServiceWorker` to prevent tests from
    hanging indefinitely.
  - Adjusted `waitUntil` for `page.goto` and `page.reload` to
    `domcontentloaded` where appropriate, as `networkidle` can cause
    tests to time out due to ongoing connections.

- **Authentication Tests:**
  - Replaced direct localStorage checks with a polling mechanism in the
    login flow test. This accounts for asynchronous token persistence by
    the Auth0 SDK.
  - Corrected a locator in the login flow test to ensure it targets the
    correct sign-in heading.

- **Content Creation Tests:**
  - Created a `createTestPost` helper function to encapsulate the common
    steps of creating a new post, reducing boilerplate in
    `create-content.spec.ts`.
  - Utilized `createTestPost` in `delete-content.spec.ts` and
    `translate-content.spec.ts`.

- **Offline Edit Sync Tests:**
  - Updated the `OFFLINE_BADGE` selector to specifically target visible
    badges using `:visible` and `text-is` for more robust matching.
  - Improved the cleanup logic in the "Restore" test to be more
    resilient, making it a best-effort attempt rather than a hard
    requirement that could fail the test if the API behaves
    unexpectedly.

- **Publish Content Tests:**
  - Removed `publish-content.spec.ts` as its functionality is covered by
    other tests and it was becoming redundant.

- **Fixtures:**
  - Introduced `pickDefaultLanguageCode` in `db.ts` to dynamically
    determine the language code to use in tests, making them more
    adaptable to different environment configurations.
  - Updated `global-setup.ts` to correctly handle both single-page and
    two-page Universal Login flows during authentication.

- **Playwright Configuration:**
  - Changed `headless` mode to `true` in `playwright.config.ts` for
    faster execution by default.
@MrDirkelz MrDirkelz force-pushed the 1565-cms-app-write-and-ensure-end-2-end-tests-work branch from 721a0ce to 768d5b6 Compare June 2, 2026 12:52
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.

CMS, APP: Write and ensure end 2 end tests work

1 participant