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: MultiCombobox の E2E テストを単体テストで書き直す #5021

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

s-sasaki-0529
Copy link
Contributor

@s-sasaki-0529 s-sasaki-0529 commented Oct 17, 2024

関連URL

概要

MultiComboBox コンポーネントには E2E テストがありますが、基本的には単体テストで十分なテストであるため、単体テスト(testing-library) に移植します。

これによって、 CI で時間がかかっている E2E テストのコスト削減及び、暗黙に発生している Storybook への依存の削減、自動テスト全体のポリシー整備を行います。

変更内容

  • E2E テスト側を削除
  • 同程度の内容の単体テストを実装

やらなかったこと

現行のE2Eテストにある以下のテストシナリオは単体テストで再現できませんでした。JSDOM に IntersectionObserver が実装されていないためです。

test('部分的レンダリングしているアイテム数がスクロールにより順次増加すること', async (t) => {
  const combobox = Selector('[data-test=multi-combobox-many]')
  const comboboxControls = ((await combobox.getAttribute('aria-controls')) || '').split(' ')
  const listbox = elementWithId(comboboxControls[0])

  await t
    .click(combobox)
    .expect(listbox.find('.smarthr-ui-ComboBox-selectButton').count)
    .eql(100)
    .scroll(listbox, 'bottom')
    .expect(listbox.find('.smarthr-ui-ComboBox-selectButton').count)
    .eql(200)
    .scroll(listbox, 'bottom')
    .expect(listbox.find('.smarthr-ui-ComboBox-selectButton').count)
    .eql(300)
})

最初の調査で見逃してしまってて恐縮なんですが、これのために testcafe を残すというのもつらいので、本PRにおいてはなくなく削除してます。Playwright による新しい E2E があるので、そちらで改めて対応すべきかは別途検討します。

確認方法

テストコードのみなのでCIが通ればOKです。

備考

基本的には以下の SingleCombobox のときのコピペをベースにしてます。

@s-sasaki-0529 s-sasaki-0529 marked this pull request as ready for review October 17, 2024 10:20
@s-sasaki-0529 s-sasaki-0529 requested a review from a team as a code owner October 17, 2024 10:20
@s-sasaki-0529 s-sasaki-0529 requested review from oti and yt-ymmt and removed request for a team October 17, 2024 10:20
Copy link

pkg-pr-new bot commented Oct 17, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/kufu/smarthr-ui@5021

commit: 3345256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant