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

test: 첫번째 인적사항 페이지 테스트 코드 #167

Merged
merged 4 commits into from
Aug 31, 2024

Conversation

2yunseong
Copy link
Collaborator

주요 변경사항

image

검증 스펙

  • 사용자는 이름을 5글자까지 입력 가능하다.
  • 사용자는 연락처에 숫자만 기입할 수 있다.
  • 사용자는 연락처에 11자리의 숫자까지만 입력할 수 있다.
  • 사용자가 연락처에 숫자를 입력한다면 자동으로 휴대전화 포맷으로 보여진다
  • 사용자가 연락처를 입력한 시점부터 연락처 형식에 맞게 작성을 완료하지 못한 경우 “연락처를 입력해주세요.” 라는 안내문구가 뜬다.
  • 사용자는 학번에 6자리 숫자를 입력할 수 있다.
  • 사용자가 학번을 입력한 시점부터 학번 형식에 맞게 작성을 완료하지 못한 경우 “학번을 입력해주세요.” 라는 안내문구가 뜬다.
  • 사용자는 학적상태(재학/휴학)를 기입할 수 있다.
  • 사용자는 학년을 선택한 후 학기를 1학기, 2학기 중 선택할 수 있다.
  • 기본 인적 사항(첫번째 페이지)에 모든 내용을 양식에 맞게 추가하지 않았을 경우 “필수 질문을 작성해주세요.”라는 alert창이 뜬다.
  • 질문 제목 네비게이션을 통한 질문 페이지 이동은, 현재 작성 해놓은 가장 나중의 페이지까지만 이동이 가능하다.
  • 질문 제목 네비게이션을 통한 이후 질문 페이지 이동 시에는 반드시 현재 작성하고 있는 질문지에 대한 유효성 검증이 성공해야만 한다.

관련 이슈

체크리스트

  • reviewers 설정
  • label 설정
  • milestone 설정

@2yunseong 2yunseong added the test ✅ 테스트 작성 label Aug 24, 2024
@2yunseong 2yunseong requested review from geongyu09 and smb0123 August 24, 2024 10:54
@2yunseong 2yunseong self-assigned this Aug 24, 2024
Copy link
Collaborator

@loopy-lim loopy-lim left a comment

Choose a reason for hiding this comment

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

어디서 테스트 코드 작성하는 법에 대해서 배우셨나요...? 왜 이렇게 잘 쓰시는거죠.. ㄷㄷㄷㄷ

몇가지 궁금한 것? 에 대해 적어두었습니다.
지나가는 행인이라 생각하시고 보시면 좋겠습니다.

Comment on lines +26 to +31
it("사용자는 5글자가 넘는 이름을 입력할 시 앞의 5글자까지만 입력을 받는다.", () => {
cy.get("@nameInput")
.type("에코노베이션")
.should("have.value", "에코노베이")
.clear();
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

오... 바로 위의 코드로 저는 합칠 생각을 했었는데 이렇게 보니, 코드를 나누는 것이 더 좋아보입니다.

cy.get("@phoneInput").type("01011");
cy.get("@phoneInput")
.siblings()
.find("div")
Copy link
Collaborator

Choose a reason for hiding this comment

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

이것도 괜찮지만, find 이후 exist로 테스트 하는 것도 의미상 괜찮아 보입니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

오호 넵 너무좋네요 감사합니다~!

Comment on lines +117 to +124
input: {
name: "김아무개",
contacted: "01012341234",
classOf: "123456",
registered: "재학",
grade: "4학년",
semester: "1학기",
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 코드는 무엇을 뜻하나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

testSuite를 나타내는 객체인데요, 입력과 나와야하는 출력을 데이터로 구조화? 해보았습니다 ㅋㅋ

Copy link
Collaborator

Choose a reason for hiding this comment

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

사실... 이 데이터를 안써서 어떻게 되어 있나 의미상 넣어두었나 싶었어요 ㅋㅋㅋ(의미상 넣어둔거군요)

Copy link
Collaborator

@geongyu09 geongyu09 left a comment

Choose a reason for hiding this comment

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

코드를 보면서 많이 배우게 된 것 같습니다!
alias를 설정하면 이렇게나 간단히 코드를 작성할 수 있군요..! 제 pr도 수정해야겠습니다


it("모든 올바른 값을 입력한 뒤에는 작성한 값이 LocalStorage에 저장된다.", () => {
/* test 케이스 데이터 */
const testSuite = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

저였으면, 단순히 하나씩 equal()에 그대로 박았을 것 같은데, 이렇게 묶는 것이 훨씬 가독성이 좋네요.. 저도 참고하도록 하겠습니다

cy.get("@nameInput")
.type("에코노베이션")
.should("have.value", "에코노베이")
.clear();
Copy link
Collaborator

Choose a reason for hiding this comment

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

혹시.. 마지막 부분에 clear를 붙인 이유가 있나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should로 assertion이 끝나서 값을 비워주려고 clear()를 호출하였습니다~!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

습관성..? 이랄까요?ㅋㅋ

Comment on lines +5 to +11
cy.visit(`${BASE_URL}/application`);
cy.clearAllLocalStorage();
cy.get("label").contains("개발자").click();
cy.get("label").contains("WEB").click();
cy.wait(100);
cy.get("label").contains("선택없음").click();
cy.get("button").contains(/다음/).click();
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 내용은 commands.ts 파일에 Cypress.Commands.add를 이용해서 함수로 만들어 사용해 보는게 좋을 것 같아요 !

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

네 좋습니다! 민보님이랑 건규님도 commands로 만드셔서 호출하신거 같은데, 여기서 구현하면 중복이 일어날 것 같으니 다 PR머지된 이후 새로 작성하겠습니다 ~

Copy link
Collaborator

Choose a reason for hiding this comment

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

넵 알겠습니다 !

cy.get("label").contains("선택없음").click();
cy.get("button").contains(/다음/).click();

cy.get("input").first().as("nameInput");
Copy link
Collaborator

Choose a reason for hiding this comment

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

아래 코드와 형식을 맞추기 위해서 first() -> eq(0)으로 변경하는 것도 좋아보여요. (이건 개인적인 생각입니다.)

Comment on lines +168 to +170
cy.on("window:alert", (text) => {
expect(text).to.equal("필수 질문을 작성해주세요.");
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 부분은 건규님이 작성하는 함수로 대체하는게 좋아보이네요.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#167 (comment) 와 같이 다음 PR에서 리팩토링 해보겠습니다!

Copy link
Collaborator

@smb0123 smb0123 left a comment

Choose a reason for hiding this comment

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

입력과 출력 값을 상수화 시킨게 인상적이었어요.
많이 배워가네요. 감사합니다 !

it("사용자는 연락처에 11자리 숫자만 기입할 수 있다. 숫자를 기입하면, 표준 연락처 형식에 맞게 값을 보여준다.", () => {
cy.get("@phoneInput")
.type("01011111111")
.should("have.value", "010-1111-1111")
Copy link
Collaborator

Choose a reason for hiding this comment

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

조금 과한 액션일 수도 있는데 옆에 주석으로 정규식을 작성해보는 것도 좋을 것 같습니다 !

/^\d{3}-\d{4}-\d{4}$/

@geongyu09 geongyu09 self-requested a review August 28, 2024 06:59
@2yunseong 2yunseong merged commit c429027 into main Aug 31, 2024
1 check passed
@2yunseong 2yunseong deleted the test/161-personal-info-1 branch September 3, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test ✅ 테스트 작성
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FE] test: 신청폼 인적사항 e2e 테스트
4 participants