ci: add playwright-tests package-lock.json for e2e workflow caching#1566
Open
MrDirkelz wants to merge 7 commits into
Open
ci: add playwright-tests package-lock.json for e2e workflow caching#1566MrDirkelz wants to merge 7 commits into
MrDirkelz wants to merge 7 commits into
Conversation
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.
721a0ce to
768d5b6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.