Skip to content

Commit

Permalink
chartjs-4: JS処理を待つ時間が短すぎてテストに失敗していた
Browse files Browse the repository at this point in the history
  • Loading branch information
koi-chan committed Nov 24, 2024
1 parent 5146054 commit 390555f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/javascript/controllers/speeches_chart_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SpeechesChartController extends Controller {
},

// SpeechesChartControllerのthisを使いたいため、アロー関数にする
onHover: (_e, elements) => {
onHover: (_e, elements, _c) => {
const chartClassList = this.chartTarget.classList;

if (elements[0] === undefined) {
Expand All @@ -77,6 +77,8 @@ class SpeechesChartController extends Controller {
animation: { active: { duration: 400 } },
},
});

this.chartTarget.classList.add("chartjs-render-monitor");
}

/**
Expand Down
6 changes: 3 additions & 3 deletions test/system/channel_days_index_chart_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ChannelDaysIndexChartTest < ApplicationSystemTestCase
test '月のページにおいてグラフが描画されている' do
visit(@browse_month.path)

sleep(0.1)
sleep(0.5)

chart_canvas = find_chart_canvas
assert do
Expand All @@ -43,7 +43,7 @@ class ChannelDaysIndexChartTest < ApplicationSystemTestCase

visit(@browse_month.path)

sleep(0.1)
sleep(0.5)

chart_canvas = find_chart_canvas
chart_canvas.click
Expand All @@ -69,7 +69,7 @@ class ChannelDaysIndexChartTest < ApplicationSystemTestCase

visit(@browse_month.path)

sleep(0.1)
sleep(0.5)

chart_canvas = find_chart_canvas
chart_canvas.click
Expand Down

0 comments on commit 390555f

Please sign in to comment.