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

chore/#38 playwright 테스트 설정 #61

Merged
merged 62 commits into from
Aug 26, 2024
Merged

chore/#38 playwright 테스트 설정 #61

merged 62 commits into from
Aug 26, 2024

Conversation

minai621
Copy link
Contributor

@minai621 minai621 commented Aug 17, 2024

요약 (Summary)

컴포넌트의 시각적 회귀 테스트와 접근성 테스트를 위해 playwright를 도입하였습니다.

  • 시각적 회귀 테스트
    컴포넌트 수정이 스타일의 변화와 같은 시각적인 변경이 있는지 확인합니다. 단위 테스트로 확인할 수 없는 UI 변경을 감지합니다.
  • 접근성 테스트
    사용자 사용 경험 향상을 위해 접근성을 위배하지 않았는지 확인합니다. 단위 테스트로는 실제 UI 동작을 확인할 수 없어 playwright에서의 테스트가 유의미하다고 생각했습니다.

배경 (Background)

UI 컴포넌트 개발 과정에서 의도하지 않은 시각적 변경이나 접근성 문제가 발생할 수 있습니다. 이러한 문제들은 단순한 단위 테스트로는 포착하기 어렵고, 수동 테스트는 시간이 많이 소요되며 일관성이 떨어질 수 있습니다. Playwright를 도입함으로써 자동화된 방식으로 이러한 문제들을 효과적으로 감지하고 해결할 수 있습니다.

목표 (Goals)

  • 컴포넌트의 시각적 변경사항을 자동으로 감지하고 리포트합니다.
  • 접근성 문제를 조기에 발견할 수 있도록 테스트 합니다.
  • CI 환경에서 테스트를 자동화하여 변경을 감지합니다.

이외 고려 사항들 (Other Considerations)

컴포넌트를 수정할 때, 스타일을 변경해야 하는 경우가 존재합니다.
만일, 합의된 변경 사항이라면 PR에서 VRT 레이블을 추가하여 스냅샷을 업데이트하여 테스트가 통과될 수 있도록 해야 합니다.

테스트 환경이 ci 환경이기 때문에 로컬 환경이 아님을 유의해야 합니다.
필요한 경우 폰트 설치와 같은 설정을 추가로 해주어야 합니다.

관련 이슈

Summary by CodeRabbit

  • New Features
    • Visual Regression Testing (VRT) 자동화 프로세스 추가.
    • Playwright를 이용한 접근성 테스트 기능 도입.
    • Storybook과의 상호작용을 위한 유틸리티 함수 추가.
  • Bug Fixes
    • 버튼 컴포넌트의 라벨 텍스트 수정.
  • Chores
    • .gitignore 파일에 테스트 및 보고서 관련 파일 추가.
    • package.json에 E2E 테스트 관련 스크립트 및 종속성 추가.
  • Documentation
    • Playwright 테스트 결과를 기록하는 새로운 JSON 파일 추가.

Copy link

🐱 스토리북이 배포되었습니다: https://www.chromatic.com/build?appId=667edcfe9b923ba1892556f4&number=22 🐱

Copy link

VRT 테스트 성공

VRT 테스트가 성공적으로 완료되었습니다.

@ghdtjgus76 ghdtjgus76 added VRT 시각적 회귀 테스트를 위해 스냅샷을 업데이트 합니다. and removed VRT 시각적 회귀 테스트를 위해 스냅샷을 업데이트 합니다. labels Aug 19, 2024
.github/workflows/chromatic_auto_deploy.yml Show resolved Hide resolved
.github/workflows/chromatic_auto_deploy.yml Show resolved Hide resolved
.github/workflows/label-vrt-update.yml Show resolved Hide resolved
.github/workflows/label-vrt-update.yml Show resolved Hide resolved
Comment on lines +63 to +73
- name: VRT 레이블 제거
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'VRT'
})
Copy link
Contributor

Choose a reason for hiding this comment

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

VRT 레이블을 제거해야 하는 이유가 뭔가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

VRT 테스트가 완료됐다는 의미랑 트리거용으로 사용했기 때문에 PR을 원상복귀하기 위해서 추가했는데, 없어도 문제가 있진 않습니다.

"unexpected": 0,
"flaky": 0
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

PR 날릴 때 EOL 한 번씩 확인해주세요~!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

playwright action에서 자동으로 생성되는 파일인데, 현재 formatting 실행할 수 있는 방법이 있나용?

Copy link
Contributor

Choose a reason for hiding this comment

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

혹시 결과 파일의 위치를 옮길 수 있나요? 컴포넌트가 많아질 수록(themed가 추가될 수록) 결과를 확인하기 힘들어질 것 같아서 각 컴포넌트 폴더 내에 함께 위치하면 어떨까 해서요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

잘 이해가 안됐는데 다시 설명해줄 수 있나요?
현재 .playwright/components/snapshots/Button.test.ts-snapshots 처럼 존재하는데
각 컴포넌트 폴더 내에 함께 위치한다는게, packages/primitive/components/Button에 두자는 말씀인지 헷갈리네용

Copy link
Contributor

Choose a reason for hiding this comment

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

위 comment와 같은 맥락에서 각 컴포넌트의 e2e 테스트 코드는 각 컴포넌트 폴더 내에 위치하면 좋을 것 같습니다! (jest 테스트와 같은 depth에서 테스트하면 어떨까요?)

Copy link
Contributor

Choose a reason for hiding this comment

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

다만 이 comment를 반영하게 된다면 현재 @ghdtjgus76 가 작업중인 code gen과의 병합도 필요할 것 같습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

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

넵 codegen에도 반영해야 할 거 같네요
다만, 디바이더 컴포넌트 작업을 위해서 기존 codegen PR은 머지한 후에 별도 이슈로 파서 반영해야 할 거 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ghdtjgus76 @ShinYoung-Kim
CDD로 개발한다는 관점에서 유닛 테스트까지는 컴포넌트 폴더에 위치하는게 맞는 것 같은데, e2e 테스트는 독립적인 것 같아서 지금의 폴더 구조를 유지했습니다. 추후에는 컴포넌트끼리 조합해서 사용할텐데 컴포넌트 폴더에 엮이기는 어렵지 않을까요?

Copy link
Collaborator

Choose a reason for hiding this comment

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

음 저도 근데 다른 디자인 시스템들도 e2e 폴더는 가장 루트로 빼는 거 같아서 지금이 좋은 거 같습니다
다만 코드젠에 e2e 관련 템플릿 및 자동화도 추가해야할 거 같다는 의미였습니다~

Comment on lines +3 to +15
type Value =
| string
| boolean
| number
| {
[Key: string]: Value;
};

interface Options {
id: string;
args?: Record<string, string | boolean>;
globals?: Record<string, Value>;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

사람마다 type, interface 중 선호하는 방법이 다르던데 저희 팀의 컨벤션을 정하면 좋을 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gs0428 @ShinYoung-Kim @ghdtjgus76
라이브러리 개발엔 interface 사용이 권장된다고 하네요. (선언병합 때문에)
근데 결국에 primitive한 값을 표현하는 부분에서 type을 사용할 수 밖에 없는데, 혼합 형식의 지금 구조로 다 같이 이야기 해보는게 좋을 것 같아요.

Copy link
Collaborator

Choose a reason for hiding this comment

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

객체처럼 표현할 때는 interface로 사용하되 원시값들은 type 사용하는 방식 좋을 거 같습니다~!

playwright.config.ts Show resolved Hide resolved
Comment on lines +21 to +22
- name: 의존성 설치
run: pnpm install
Copy link
Collaborator

Choose a reason for hiding this comment

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

pnpm install --no-frozen-lockfile로 지정해줘야 할 거 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--no-frozen-lockfile 지정하는 이유가 있나요? lockfile에 문제 없는 경우엔 지정 안해도 될 것 같아서 비워뒀긴 합니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

음 ci 환경에서 관련 에러가 발생한 적이 있어서 추가하면 좋을 거 같다고 생각했습니다!
디벨롭 브랜치에 있는 다른 워크 플로우 파일은 --no-frozen-lockfile 속성 지정되어 있긴 하네요

Copy link
Collaborator

Choose a reason for hiding this comment

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

--frozen-lockfile은 CI 환경에서 설치 과정의 일관성과 재현성을 보장하기 위해 사용된다고 하는데 그럼 다른 워크 플로우 파일을 수정하는게 맞겠네요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--frozen-lockfile은 CI 환경에서 설치 과정의 일관성과 재현성을 보장하기 위해 사용된다고 하는데 그럼 다른 워크 플로우 파일을 수정하는게 맞겠네요

넵, --no-frozen-lockfile을 지정하면 lockfile을 무시한다해서 그냥 두겠습니당.

.github/workflows/label-vrt-update.yml Show resolved Hide resolved
.github/workflows/label-vrt-update.yml Show resolved Hide resolved
.github/workflows/pr-vrt.yml Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

넵 codegen에도 반영해야 할 거 같네요
다만, 디바이더 컴포넌트 작업을 위해서 기존 codegen PR은 머지한 후에 별도 이슈로 파서 반영해야 할 거 같습니다!

Copy link

🐱 스토리북이 배포되었습니다: https://www.chromatic.com/build?appId=667edcfe9b923ba1892556f4&number=30 🐱

Copy link

VRT 테스트 성공

VRT 테스트가 성공적으로 완료되었습니다.

@minai621 minai621 merged commit 74cab14 into develop Aug 26, 2024
3 of 4 checks passed
@minai621 minai621 deleted the chore/#38 branch August 26, 2024 05:10
@minai621 minai621 added the VRT 시각적 회귀 테스트를 위해 스냅샷을 업데이트 합니다. label Sep 6, 2024
Copy link
Contributor

coderabbitai bot commented Sep 6, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

변경 사항은 GitHub Actions 워크플로우를 업데이트하여 Visual Regression Testing(VRT) 자동화 및 Playwright 통합을 포함합니다. 새로운 워크플로우 파일이 추가되었으며, 기존 파일의 구성도 개선되었습니다. Playwright 및 접근성 테스트를 위한 새로운 스크립트와 종속성이 package.json에 추가되었고, .gitignore 파일도 업데이트되었습니다. 전반적으로, 테스트와 배포 프로세스의 일관성과 신뢰성이 향상되었습니다.

Changes

파일 경로 변경 요약
.github/workflows/... Chromatic 배포 워크플로우 업데이트, pnpm 설치 방식 변경 및 Chromatic 액션 버전 업데이트. 새로운 VRT 업데이트 워크플로우 추가.
.gitignore Playwright 관련 테스트 및 보고서 파일을 무시하도록 새로운 패턴 추가.
.playwright/results.json Playwright 테스트 결과를 포함하는 JSON 파일 추가.
e2e/... Button 컴포넌트에 대한 Playwright 테스트 추가 및 접근성 검사 기능 구현.
package.json E2E 테스트 및 접근성 검사를 위한 새로운 스크립트 및 종속성 추가.
playwright.config.ts Playwright 테스트 설정을 정의하는 구성 파일 추가.
tsconfig.json TypeScript 컴파일러가 E2E 테스트 및 Playwright 구성 파일을 인식하도록 include 속성 수정.

Sequence Diagram(s)

sequenceDiagram
    participant PR as Pull Request
    participant Workflow as GitHub Actions Workflow
    participant Playwright as Playwright
    participant Storybook as Storybook Server

    PR->>Workflow: PR labeled with "VRT"
    Workflow->>Playwright: Run VRT tests
    Playwright->>Storybook: Start Storybook server
    Playwright->>Playwright: Execute VRT tests
    Playwright->>Storybook: Terminate server
    Playwright->>Workflow: Update snapshots
    Workflow->>PR: Comment on VRT results
Loading

Poem

🐰
새로운 변화가 왔어요,
테스트와 배포가 즐거워요.
버튼이 반짝, 결과는 빛나,
접근성도 챙기니 기분이 좋아요!
깃허브에서 춤추는 코드,
함께하는 우리, 더 나은 길로!
🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VRT 시각적 회귀 테스트를 위해 스냅샷을 업데이트 합니다. ⚙️ 세팅
Projects
None yet
Development

Successfully merging this pull request may close these issues.

playwright 세팅
5 participants