From b039ec19196f8a6add9010068f087de7516c4466 Mon Sep 17 00:00:00 2001 From: Chris Huynh Date: Thu, 12 Dec 2024 11:57:26 -0600 Subject: [PATCH] further fix tests --- test/fixtures/samples.yml | 2 +- test/system/projects/samples_test.rb | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/fixtures/samples.yml b/test/fixtures/samples.yml index baf829bfec..a615e9026f 100644 --- a/test/fixtures/samples.yml +++ b/test/fixtures/samples.yml @@ -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: diff --git a/test/system/projects/samples_test.rb b/test/system/projects/samples_test.rb index 6240a04e62..fc9237d472 100644 --- a/test/system/projects/samples_test.rb +++ b/test/system/projects/samples_test.rb @@ -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 @@ -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' @@ -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' @@ -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) @@ -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' @@ -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