-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
Current behavior
We are trying to do a login with cypress, and we tried to use the "cy.origin" command. In local this worked well, as the domain of the login was a complete different one.
Once we launched this in the pipeline, started complaining cypress that the "super domain" was the same one ( same error as this issue ).
As cypress identifies the login domain as the same domain, we assumed that then we could use the cypress commands directly in that page, so we did the following condition so that the code would be executed with origin or without depending of the environment:
const loginFunction = ({ username, password, emailInput, passwordInput, nextButton }) => {
cy.get(emailInput, { timeout: 5000 }).should('be.visible').type(username, { log: false });
cy.get(passwordInput).type(password, { log: false });
cy.get(nextButton).click();
};
// When localhost, we need the "origin command"
if (Cypress.config('baseUrl').includes('localhost')) {
cy.origin(
loginOrigin,
{
args: {
username: usernameForLogin,
password: passwordForLogin,
emailInput: LoginPage.emailInput,
passwordInput: LoginPage.passwordInput,
nextButton: LoginPage.nextButton
}
},
loginFunction
);
} else {
// When deployed, we don't need the "origin command"
loginFunction({
username: usernameForLogin,
password: passwordForLogin,
emailInput: LoginPage.emailInput,
passwordInput: LoginPage.passwordInput,
nextButton: LoginPage.nextButton
});
}
Problem comes that when we are doing the login in the CI ( not using the cy.origin ), one response of loading a page returns a 400 ( usually returns a 302 that page - With cy.origin or by normal usage of the login )
Same code executed in localhost, and using the cy.origin works just perfectly
Desired behavior
That the code works the same with or without origin
Test code to reproduce
Provided in the description
Cypress Version
12.5.1
Node version
18.13.0
Operating System
Windows 10 19042.2486
Debug Logs
No response
Other
SSO for the login used is
Azure AD B2C
Frontend application is
Angular with @azure/msal-angular