Nuxt: Login through auth0 doesn't redirect to localhost
See original GitHub issueCurrent behavior
I created a simple test that checks if the home page redirects to a specific route:
describe('Open Artwork page', () => {
it('should display the title', () => {
cy.visit('http://localhost:3000/')
cy.contains('Artwork').should('be.visible');
});
});
The user has to login in with Auth0 to access the home page. This is the login command:
Cypress.Commands.add('login', () => {
const environment = Cypress.env("ENV")
const tenantName = environment === 'development'
? 'artbeat-venture'
: `artbeat-venture-${environment}`
const args = {
email: Cypress.env()[environment]['username'],
password: Cypress.env()[environment]['password'],
environment,
tenantName,
}
cy.session(args, () => {
const { tenantName } = args
cy.origin(
`https://${tenantName}.eu.auth0.com`, { args },
({ email, password, environment, tenantName, baseUrl }) => {
cy.visit({
url: `https://${tenantName}.eu.auth0.com/authorize`,
qs: {
client_id: Cypress.env()[environment]['clientId'],
response_type: "token",
redirect_uri: `http://localhost:3000`,
},
})
cy.get('#username').type(email)
cy.get('#password').type(password)
cy.get('button').contains('Continue').click();
})
// assert we've returned to the site
cy.url().should('contain', '/artwork') // todo: check this
})
})
We run the login command on the beforeEach
:
beforeEach(function () {
cy.login()
})
We are able to run the test locally with the standard npm run dev
(vue app).
The github action pipeline is the following and we are not able to run the tests.
It looks like after the login cypress cannot redirect to localhost:3000
.
This is our yml file:
cypress-run:
name: Run E2E tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Cypress run
uses: cypress-io/github-action@v4
with:
cache-key: hash-${{ hashFiles('package-lock.json') }}
build: npm run build
start: npm run start
wait-on: http://localhost:3000
command: npm run cypress-run:staging
- name: Archive e2e artifacts
id: artifacts
uses: actions/upload-artifact@v2
if: failure()
with:
name: e2e
path: |
cypress/videos/
cypress/screenshots/
The test is stuck with a blank page, even with longer timeout (30 mins):
I also tried locally with the same github action setup aka:
npm run build
npm run start
npm run cypress-run:staging
and it works.
We checked the logs from auth0 and we receive a successful Login Confirmation message from the logs so I assume the issue is on a cypress level. Maybe it’s a chrome configuration on github.
Thanks in advance!
Desired behavior
The desired behavior is that the app is able to load the homepage after the auth0 redirect on localhost:3000
Test code to reproduce
I can’t provide a repository as my app login is bounded through an auth0 clientId
Cypress Version
10.4.0
Node version
v14.19.1
Operating System
macOS 12.2.1 locally, ubuntu on github
Debug Logs
No response
Other
No response
Issue Analytics
- State:
- Created a year ago
- Comments:15 (6 by maintainers)
Top GitHub Comments
@nicoladl Great! Thanks for clarifying.
It is definitely an issue with the nuxt build. I’m just leaving a message to posterity.