Skip to content

Commit 2146bc0

Browse files
committed
test(auth): fix login command and simplify login flow
1 parent 24ca06f commit 2146bc0

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

cypress/e2e/repo.cy.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
describe('Repo', () => {
22
beforeEach(() => {
3-
// Log in with default admin user
4-
cy.visit('/login');
5-
6-
cy.intercept('GET', '**/api/auth/me').as('getUser');
7-
8-
cy.get('[data-test="username"]').type('admin');
9-
cy.get('[data-test="password"]').type('admin');
10-
cy.get('[data-test="login"]').click();
11-
12-
cy.wait('@getUser');
3+
cy.login('admin', 'admin');
134

145
cy.visit('/dashboard/repo');
156

cypress/support/commands.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@
2929
Cypress.Commands.add('login', (username, password) => {
3030
cy.session([username, password], () => {
3131
cy.visit('/login');
32+
cy.intercept('GET', '**/api/auth/me').as('getUser');
33+
3234
cy.get('[data-test=username]').type(username);
3335
cy.get('[data-test=password]').type(password);
3436
cy.get('[data-test=login]').click();
35-
cy.url().should('contain', '/admin/profile');
37+
38+
cy.wait('@getUser');
39+
cy.url().should('include', '/dashboard/repo');
3640
});
3741
});

0 commit comments

Comments
 (0)