Skip to content

test: Migrate acceptance tests to @umbraco-cms/acceptance-test-helpers#304

Merged
rickbutterfield merged 1 commit into
v5/devfrom
v5/test/acceptance-helpers-migration
Jun 30, 2026
Merged

test: Migrate acceptance tests to @umbraco-cms/acceptance-test-helpers#304
rickbutterfield merged 1 commit into
v5/devfrom
v5/test/acceptance-helpers-migration

Conversation

@rickbutterfield

Copy link
Copy Markdown
Owner

Problem

The Playwright acceptance suite fails in every test's beforeEach (the umbracoApi fixture → isLoginStateValid()getLocalStorageAuthToken()):

TypeError: Cannot read properties of undefined (reading 'value')

Root cause: the project depends on the deprecated @umbraco/playwright-testhelpers@^17.0.34. Its getLocalStorageAuthToken() reads the auth token from the localStorage key umb:userAuthTokenResponse. Umbraco 17.5's backoffice switched to cookie-based auth, so that key no longer exists — the saved storage state holds only umb:appLanguage plus auth cookies — and the helper throws.

The package is deprecated upstream:

"The helpers have been moved into the Umbraco CMS acceptance test project. Please use @umbraco-cms/acceptance-test-helpers instead. Versioning now follows CMS versions…"

The replacement's isLoginStateValid() was rewritten to rely on cookies (no localStorage token read), matching Umbraco 17.5. This is the same package the Umbraco Forms acceptance tests use.

Change

  • Swap @umbraco/playwright-testhelpers@^17.0.34@umbraco-cms/acceptance-test-helpers@^17.5.0 (matching the 17.5.0 test site).
  • Update the five import sites (same exported names: ApiHelpers, UiHelpers, ConstantHelper, test).
  • Add non-null assertions for the env credentials in auth.setup.ts (the new helper's stricter login signatures require string).

Verification

With the running Umbraco 17.5 test site, the full DefaultConfig suite now authenticates and passes:

[setup] authenticate
[DefaultConfig] Can navigate to the content section @smoke
[DefaultConfig] Block Grid page renders block previews @smoke
[DefaultConfig] Block List page renders block previews @smoke
  4 passed

Note for merge ordering

This PR and #302 (the #300 RTE fix) both touch block-preview.spec.ts — this PR changes the import line; #302 adds the RTE regression test (with the old import, to stay internally consistent on its own branch). Expect a trivial one-line conflict on the import when both land: keep @umbraco-cms/acceptance-test-helpers. I verified the combined result (this migration + #302's fix + the RTE test) passes locally.

🤖 Generated with Claude Code

The acceptance suite failed in every test's beforeEach with
"TypeError: Cannot read properties of undefined (reading 'value')" from
ApiHelpers.getLocalStorageAuthToken via the umbracoApi fixture.

Root cause: the project used the deprecated @umbraco/playwright-testhelpers
(17.0.34), whose isLoginStateValid() reads the auth token from the
localStorage key `umb:userAuthTokenResponse`. Umbraco 17.5's backoffice moved
to cookie-based auth, so that key no longer exists (the saved storage state
holds only `umb:appLanguage` plus auth cookies) and the helper threw.

The package is deprecated upstream in favour of
@umbraco-cms/acceptance-test-helpers, whose versions track the CMS and whose
isLoginStateValid() was rewritten to rely on cookies. Migrate to it at 17.5.x
(matching the test site / Umbraco version), as the Forms acceptance tests do.

- Swap the dependency and update the five import sites (same exported names).
- Add non-null assertions for the env credentials, which the new helper's
  stricter login signatures require.

Verified: the full DefaultConfig suite (setup + 3 smoke tests) now passes
against the Umbraco 17.5 test site.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rickbutterfield rickbutterfield merged commit 80009b6 into v5/dev Jun 30, 2026
4 checks passed
@rickbutterfield rickbutterfield deleted the v5/test/acceptance-helpers-migration branch June 30, 2026 14:54
rickbutterfield added a commit that referenced this pull request Jun 30, 2026
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