Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cypress): onBeforeLoad being called during login #3480

Merged
merged 2 commits into from
Apr 5, 2024

Conversation

tdeekens
Copy link
Contributor

@tdeekens tdeekens commented Apr 4, 2024

Summary

The onBeforeLoad never seems to be called which this intends to fix.

Description

In the loginByOidc we call the onBeforeLoad like:

if (commandOptions.onBeforeLoad) {
  commandOptions.onBeforeLoad(win);
}

I noticed that we do not do this when logging in via the form. This causes issues internally when we use the general loginToMerchantCenter command which we often pass an onBeforeLoad to e.g. set local storage values to hide collapse the menu or hide certain models (like for rebranding).

We could either invoke the onBeforeLoad in the authCallback or when navigating to the initialRoute. The latter seems unexpected as you then only invoke the callback when another parameter is passed.

@tdeekens tdeekens requested a review from a team as a code owner April 4, 2024 21:20
@tdeekens tdeekens self-assigned this Apr 4, 2024
Copy link

changeset-bot bot commented Apr 4, 2024

🦋 Changeset detected

Latest commit: d8548e9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 36 packages
Name Type
@commercetools-frontend/cypress Patch
@commercetools-applications/merchant-center-template-starter-typescript Patch
@commercetools-applications/merchant-center-template-starter Patch
@commercetools-applications/merchant-center-custom-view-template-starter-typescript Patch
@commercetools-applications/merchant-center-custom-view-template-starter Patch
@commercetools-backend/eslint-config-node Patch
@commercetools-backend/express Patch
@commercetools-backend/loggers Patch
@commercetools-frontend/actions-global Patch
@commercetools-frontend/application-components Patch
@commercetools-frontend/application-config Patch
@commercetools-frontend/application-shell-connectors Patch
@commercetools-frontend/application-shell Patch
@commercetools-frontend/assets Patch
@commercetools-frontend/babel-preset-mc-app Patch
@commercetools-frontend/browser-history Patch
@commercetools-frontend/codemod Patch
@commercetools-frontend/constants Patch
@commercetools-frontend/create-mc-app Patch
@commercetools-frontend/eslint-config-mc-app Patch
@commercetools-frontend/i18n Patch
@commercetools-frontend/jest-preset-mc-app Patch
@commercetools-frontend/jest-stylelint-runner Patch
@commercetools-frontend/l10n Patch
@commercetools-frontend/mc-dev-authentication Patch
@commercetools-frontend/mc-html-template Patch
@commercetools-frontend/mc-scripts Patch
@commercetools-frontend/notifications Patch
@commercetools-frontend/permissions Patch
@commercetools-frontend/react-notifications Patch
@commercetools-frontend/sdk Patch
@commercetools-frontend/sentry Patch
@commercetools-frontend/url-utils Patch
@commercetools-local/playground Patch
@commercetools-local/visual-testing-app Patch
@commercetools-website/components-playground Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Apr 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
merchant-center-application-kit-components-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 4, 2024 9:22pm

@@ -125,7 +125,7 @@ function loginByForm(commandOptions: CommandLoginOptions) {
// const mcFrontendHostname = mcUrl.hostname.replace('mc-api', 'mc');

function authCallback() {
cy.visit(url);
cy.visit(url, { onBeforeLoad: commandOptions.onBeforeLoad });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Verified this locally with a patched package.

@tdeekens tdeekens merged commit 31d6a09 into main Apr 5, 2024
16 of 17 checks passed
@tdeekens tdeekens deleted the td/fix-onbefore-load branch April 5, 2024 07:08
@ct-changesets ct-changesets bot mentioned this pull request Apr 5, 2024
ddouglasz pushed a commit that referenced this pull request May 22, 2024
* fix(cypress): onBeforeLoad being called during login

* Create large-bats-travel.md
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.

2 participants