Skip to content

Commit

Permalink
further fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHuynh333 committed Dec 13, 2024
1 parent cc6819a commit b039ec1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/fixtures/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sample1:
project_id: <%= ActiveRecord::FixtureSet.identify(:project1, :uuid) %>
puid: INXT_SAM_AAAAAAAAAA
created_at: <%= 1.week.ago %>
updated_at: <%= 1.day.ago %>
updated_at: <%= 3.hours.ago %>
attachments_updated_at: <%= 2.hours.ago %>

sample2:
Expand Down
11 changes: 8 additions & 3 deletions test/system/projects/samples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SamplesTest < ApplicationSystemTestCase
assert_selector 'th:first-child', text: @sample1.puid
assert_selector 'td:nth-child(2)', text: @sample1.name
assert_selector 'td:nth-child(3)', text: I18n.l(@sample1.created_at.localtime, format: :full_date)
# assert_selector 'td:nth-child(4)', text: "yesterday at #{Time.now.strftime('%-I:%M%P')}"
assert_selector 'td:nth-child(4)', text: '3 hours ago'
assert_selector 'td:nth-child(5)', text: '2 hours ago'
# actions tested by role in separate test
end
Expand Down Expand Up @@ -659,6 +659,7 @@ class SamplesTest < ApplicationSystemTestCase
within('tbody tr:first-child th') do
assert_text @sample1.puid
end
# sort by name
click_on I18n.t('samples.table_component.name')

assert_selector 'table thead th:nth-child(2) svg.icon-arrow_up'
Expand All @@ -671,6 +672,7 @@ class SamplesTest < ApplicationSystemTestCase
assert_selector 'tr:last-child td:nth-child(2)', text: @sample30.name
end

# change name sort direction
click_on I18n.t('samples.table_component.name')

assert_selector 'table thead th:nth-child(2) svg.icon-arrow_down'
Expand All @@ -686,6 +688,7 @@ class SamplesTest < ApplicationSystemTestCase
end

test 'sort samples attachments_updated_at_nulls_last' do
# attachments_updated_at_nulls_last sorts null data together
### setup start ###
visit namespace_project_samples_url(@namespace, @project)

Expand All @@ -697,6 +700,7 @@ class SamplesTest < ApplicationSystemTestCase
within('tbody tr:first-child th') do
assert_text @sample1.puid
end
# sort by attachments_updated_at
click_on I18n.t('samples.table_component.attachments_updated_at')

assert_selector 'table thead th:nth-child(5) svg.icon-arrow_up'
Expand All @@ -709,14 +713,15 @@ class SamplesTest < ApplicationSystemTestCase
assert_selector 'tr:last-child td:nth-child(2)', text: @sample30.name
end

# change sort direction
click_on I18n.t('samples.table_component.attachments_updated_at')

assert_selector 'table thead th:nth-child(5) svg.icon-arrow_down'
within('#samples-table table tbody') do
assert_selector 'tr:first-child th', text: @sample2.puid
assert_selector 'tr:first-child td:nth-child(2)', text: @sample2.name
assert_selector 'tr:nth-child(2) th', text: @sample3.puid
assert_selector 'tr:nth-child(2) td:nth-child(2)', text: @sample3.name
assert_selector 'tr:nth-child(2) th', text: @sample30.puid
assert_selector 'tr:nth-child(2) td:nth-child(2)', text: @sample30.name
assert_selector 'tr:last-child th', text: @sample1.puid
assert_selector 'tr:last-child td:nth-child(2)', text: @sample1.name
end
Expand Down

0 comments on commit b039ec1

Please sign in to comment.