Skip to content

Commit

Permalink
[fix] some gws spec failure (#5206)
Browse files Browse the repository at this point in the history
  • Loading branch information
itowtips committed Apr 9, 2024
1 parent 7a64631 commit 40923c0
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 73 deletions.
138 changes: 70 additions & 68 deletions spec/features/gws/affair/attendance/time_card/group_spec.rb
Expand Up @@ -77,103 +77,105 @@ def time_card_title(date, group)
end

it do
Timecop.freeze(user638_enter) do
Timecop.travel(user638_enter) do
login_user(user638)
visit gws_affair_attendance_main_path(site)
punch_enter(user638_enter)
end

Timecop.freeze(user545_enter) do
Timecop.travel(user545_enter) do
login_user(user545)
visit gws_affair_attendance_main_path(site)
punch_enter(user545_enter)
end

Timecop.freeze(user638_leave) do
Timecop.travel(user638_leave) do
login_user(user638)
visit gws_affair_attendance_main_path(site)
punch_leave(user638_leave)
end

Timecop.freeze(user545_leave) do
Timecop.travel(user545_leave) do
login_user(user545)
visit gws_affair_attendance_main_path(site)
punch_leave(user545_leave)
end

login_user(user638)
visit index_path
# change group
within "form" do
select user638_group.name, from: 'group_id'
click_on I18n.t("ss.buttons.search")
end
wait_for_js_ready

within ".attendance-box.daily" do
expect(page).to have_css(".attendance-box-title", text: time_card_title(Time.zone.today, user638_group))

# change year month
select I18n.l(Time.zone.parse("2020/8/1").to_date, format: :attendance_year_month), from: 'year_month'
wait_for_js_ready
expect(page).to have_css(".attendance-box-title",
text: time_card_title(Time.zone.parse("2020/8/#{Time.zone.today.day}"), user638_group))

# change day
select I18n.t("gws/attendance.day", count: 30), from: 'day'
Timecop.travel(user545_leave) do
login_user(user638)
visit index_path
# change group
within "form" do
select user638_group.name, from: 'group_id'
click_on I18n.t("ss.buttons.search")
end
wait_for_js_ready
expect(page).to have_css(".attendance-box-title", text: time_card_title(Time.zone.parse("2020/8/30"), user638_group))

within ".time-card" do
expect(page).to have_css(".time.enter", text: "8:30")
expect(page).to have_css(".time.leave", text: "17:00")
expect(page).to have_css(".time.working-time", text: "7:45")
within ".attendance-box.daily" do
expect(page).to have_css(".attendance-box-title", text: time_card_title(Time.zone.today, user638_group))

# change year month
select I18n.l(Time.zone.parse("2020/8/1").to_date, format: :attendance_year_month), from: 'year_month'
wait_for_js_ready
expect(page).to have_css(".attendance-box-title",
text: time_card_title(Time.zone.parse("2020/8/#{Time.zone.today.day}"), user638_group))

# change day
select I18n.t("gws/attendance.day", count: 30), from: 'day'
wait_for_js_ready
expect(page).to have_css(".attendance-box-title", text: time_card_title(Time.zone.parse("2020/8/30"), user638_group))

within ".time-card" do
expect(page).to have_css(".time.enter", text: "8:30")
expect(page).to have_css(".time.leave", text: "17:00")
expect(page).to have_css(".time.working-time", text: "7:45")
end
end
end

login_user(user545)
visit index_path
# change group
within "form" do
select user638_group.name, from: 'group_id'
click_on I18n.t("ss.buttons.search")
end
wait_for_js_ready

within ".attendance-box.daily" do
expect(page).to have_css(".attendance-box-title", text: time_card_title(Time.zone.today, user638_group))

# change year month
select I18n.l(Time.zone.parse("2020/8/1").to_date, format: :attendance_year_month), from: 'year_month'
login_user(user545)
visit index_path
# change group
within "form" do
select user638_group.name, from: 'group_id'
click_on I18n.t("ss.buttons.search")
end
wait_for_js_ready
expect(page).to have_css(".attendance-box-title",
text: time_card_title(Time.zone.parse("2020/8/#{Time.zone.today.day}"), user638_group))

# change day
select I18n.t("gws/attendance.day", count: 30), from: 'day'
wait_for_js_ready
expect(page).to have_css(".attendance-box-title", text: time_card_title(Time.zone.parse("2020/8/30"), user638_group))
within ".attendance-box.daily" do
expect(page).to have_css(".attendance-box-title", text: time_card_title(Time.zone.today, user638_group))

# change year month
select I18n.l(Time.zone.parse("2020/8/1").to_date, format: :attendance_year_month), from: 'year_month'
wait_for_js_ready
expect(page).to have_css(".attendance-box-title",
text: time_card_title(Time.zone.parse("2020/8/#{Time.zone.today.day}"), user638_group))

# change day
select I18n.t("gws/attendance.day", count: 30), from: 'day'
wait_for_js_ready
expect(page).to have_css(".attendance-box-title", text: time_card_title(Time.zone.parse("2020/8/30"), user638_group))

within ".time-card" do
expect(page).to have_css(".time.enter", text: "8:30")
expect(page).to have_css(".time.leave", text: "17:00")
expect(page).to have_css(".time.working-time", text: "7:45")
end
end

within ".time-card" do
expect(page).to have_css(".time.enter", text: "8:30")
expect(page).to have_css(".time.leave", text: "17:00")
expect(page).to have_css(".time.working-time", text: "7:45")
# change group
within "form" do
select user545_group.name, from: 'group_id'
click_on I18n.t("ss.buttons.search")
end
end
wait_for_js_ready

# change group
within "form" do
select user545_group.name, from: 'group_id'
click_on I18n.t("ss.buttons.search")
end
wait_for_js_ready

within ".attendance-box.daily" do
expect(page).to have_css(".attendance-box-title", text: time_card_title(Time.zone.parse("2020/8/30"), user545_group))
within ".time-card" do
expect(page).to have_css(".time.enter", text: "8:12")
expect(page).to have_css(".time.leave", text: "20:32")
expect(page).to have_css(".time.working-time", text: "7:45")
within ".attendance-box.daily" do
expect(page).to have_css(".attendance-box-title", text: time_card_title(Time.zone.parse("2020/8/30"), user545_group))
within ".time-card" do
expect(page).to have_css(".time.enter", text: "8:12")
expect(page).to have_css(".time.leave", text: "20:32")
expect(page).to have_css(".time.working-time", text: "7:45")
end
end
end
end
Expand Down
Expand Up @@ -5,6 +5,7 @@
let!(:user) { gws_user }

let!(:year) { site.fiscal_year }
let!(:last_year) { year - 1 }
let!(:group) { user.gws_default_group }

let!(:category1) { create :gws_workload_category, order: 10 }
Expand Down Expand Up @@ -48,19 +49,18 @@
create :gws_workload_work, due_start_on: d1, due_end_on: d2, due_date: d3, load: load2
end
let!(:item4) do
last_year = year - 1
d1 = Date.new(last_year, 4, 1)
d2 = Date.new(last_year, 4, 7)
d3 = Date.new(last_year, 4, 7)
create :gws_workload_work, year: last_year, due_start_on: d1, due_end_on: d2, due_date: d3, load: load3
end

it "total_datasets" do
expect(item1.year_months).to eq [{ "year" => 2023, "month" => 4 }]
expect(item2.year_months).to eq [{ "year" => 2023, "month" => 5 }]
expect(item1.year_months).to eq [{ "year" => year, "month" => 4 }]
expect(item2.year_months).to eq [{ "year" => year, "month" => 5 }]
expect(item3.year_months).to eq [
{ "year" => 2023, "month" => 4 }, { "year" => 2023, "month" => 5 }, { "year" => 2023, "month" => 6 }]
expect(item4.year_months).to eq [{ "year" => 2022, "month" => 4 }]
{ "year" => year, "month" => 4 }, { "year" => year, "month" => 5 }, { "year" => year, "month" => 6 }]
expect(item4.year_months).to eq [{ "year" => last_year, "month" => 4 }]

aggregation = described_class.new(site, year, group, users)
aggregation.set_base_items
Expand Down

0 comments on commit 40923c0

Please sign in to comment.