Skip to content

fix: resolve C3 export login flow and add tests - #75

Open
Armaldio wants to merge 1 commit into
mainfrom
fix-construct-3-export-login-e2e-tests
Open

fix: resolve C3 export login flow and add tests#75
Armaldio wants to merge 1 commit into
mainfrom
fix-construct-3-export-login-e2e-tests

Conversation

@Armaldio

Copy link
Copy Markdown
Member

Problem

The Construct 3 export login flow broke due to changes on the Construct 3 website. The old approach:

  1. Used UI automation to click through login dialog iframes
  2. Injected credentials via raw IndexedDB on the account.construct.net origin

Root cause: The editor reads login state from its own origin (editor.construct.net), not account.construct.net. Cross-origin IndexedDB is not shared. The UI selectors also changed on the C3 site.

Fix

Login flow (script.ts):

  • Call account.construct.net/login.json API directly (version-agnostic, stable endpoint)
  • Wait for localforage to be available in the editor's JS context
  • Inject credentials via localforage on the editor's own origin
  • Reload to apply login state

Listener improvements:

  • All 8 dialog listeners registered immediately after navigation/login (before file chooser), not after
  • notNowBtn listener now re-registers itself recursively
  • Added registerNewVersionAvailableListener (was missing)
  • All catch handlers guard against "Target page, context or browser has been closed"

Tests

Unit tests (export.test.ts - 11 static analysis tests):

  • Verify correct login patterns (localforage, API, origin ordering)
  • Verify old broken patterns are removed (raw IndexedDB, UI selectors, wrong origin)
  • Verify listener ordering, recursion, and browser-closed guards
  • 10/11 fail on the old code, 11/11 pass on the fixed code

E2e tests (construct-export.spec.ts):

  • Parameterized across 4 Construct 3 versions: stable (latest), stable r495-2, beta, LTS r449-5
  • Tests both logged-out and logged-in export for each version
  • Requires packaged Electron binary (pnpm package) to run

Login was broken due to changes on the Construct 3 website. The old
approach used UI automation to click through login dialog iframes and
injected credentials via raw IndexedDB on account.construct.net, but the
editor reads login state from its own origin (editor.construct.net).

Fix:
- Call account.construct.net/login.json API directly (version-agnostic)
- Inject credentials via localforage on editor.construct.net origin
- Reload page to apply login state
- Register all dialog listeners immediately after navigation (before file
  chooser) instead of after
- Make notNowBtn listener recursive with browser-closed guard
- Add registerNewVersionAvailableListener
- Add 'Target page, context or browser has been closed' guards to all
  listener catch handlers

Tests:
- 11 static analysis unit tests that verify the correct patterns in
  script.ts and fail if the fix is reverted (10/11 fail on old code)
- E2e test suite parameterized across 4 C3 versions (stable, r495-2,
  beta, LTS r449-5) testing both logged-in and logged-out export
- Minimal vitest config for running unit tests without Electron Forge
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