Skip to content

Commit

Permalink
test: 로그인 e2e테스트 도입
Browse files Browse the repository at this point in the history
  • Loading branch information
eun-hak committed Jul 4, 2024
1 parent 373791b commit 550680d
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions cypress/e2e/sign.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
describe('template spec', () => {
it('passes', () => {
cy.visit('http://localhost:3000/sign');
//test1 : 로그인과정 테스트

describe('Signin Form Test', () => {
// 로그인 api 검증
beforeEach(() => {
cy.request({
method: 'POST',
url: 'https://joo-api.store/login',
body: {
email: '[email protected]',
password: 'qwer1234!'
}
}).then((resp) => {
const token = resp.body.data.accessToken;
if (typeof token === 'string' && token.length > 0) {
cy.setCookie('token', token);
} else {
throw new Error('Token is not a valid string.');
}
});
cy.visit('http://localhost:3000/signin');
});

// 로그인 및 리다이렉션 검증
it('successfully logs in', () => {
cy.visit('http://localhost:3000/signin');
cy.get('input[id="email"]').type('[email protected]');
cy.get('input[id="password"]').type('qwer1234!');
cy.get('form').submit();
cy.url().should('include', '/');
cy.visit('http://localhost:3000/');
});
});

0 comments on commit 550680d

Please sign in to comment.