Skip to content

Commit

Permalink
Feature/test update (#2819)
Browse files Browse the repository at this point in the history
* Bugfix - output times in BST without requiring local time as server's are kept in UTC.

* fix
  • Loading branch information
jon-shipley authored Jun 16, 2024
1 parent 3b4b3b2 commit fa318e8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,8 @@

Then(/^I should see the pin gen reflected in the check history$/) do
check_details = SqlDbHelper.check_details(@pupil_details['id'])
current_timezone = Time.now.zone
if current_timezone == 'BST'
timezone_string = 'GB'
else
timezone_string = 'GMT'
end
expect(pupil_history_page.check_history.rows.first.pin_gen.text).to eql check_details['createdAt'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
zone = 'Europe/London'
expect(pupil_history_page.check_history.rows.first.pin_gen.text).to eql check_details['createdAt'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(pupil_history_page.check_history.rows.first.login.text).to eql ""
expect(pupil_history_page.check_history.rows.first.recieved.text).to eql @check_type == 'Official' ? '' : 'n/a'
expect(pupil_history_page.check_history.rows.first.active.text).to eql @check_type == 'Official' ? '*' : ''
Expand All @@ -114,14 +109,9 @@

Then(/^I should see the pupil login reflected in the check history$/) do
check_details = SqlDbHelper.check_details(@pupil_details['id'])
current_timezone = Time.now.zone
if current_timezone == 'BST'
timezone_string = 'GB'
else
timezone_string = 'GMT'
end
expect(pupil_history_page.check_history.rows.first.pin_gen.text).to eql check_details['createdAt'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(pupil_history_page.check_history.rows.first.login.text).to eql check_details['pupilLoginDate'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
zone = 'Europe/London'
expect(pupil_history_page.check_history.rows.first.pin_gen.text).to eql check_details['createdAt'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(pupil_history_page.check_history.rows.first.login.text).to eql check_details['pupilLoginDate'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(pupil_history_page.check_history.rows.first.recieved.text).to eql @check_type == 'Official' ? '' : 'n/a'
expect(pupil_history_page.check_history.rows.first.active.text).to eql @check_type == 'Official' ? '*' : ''
expect(pupil_history_page.check_history.rows.first.type.text).to eql @check_type
Expand Down Expand Up @@ -150,15 +140,10 @@

Then(/^I should see the completed check reflected in the check history$/) do
check_details = SqlDbHelper.check_details(@pupil_details['id'])
current_timezone = Time.now.zone
if current_timezone == 'BST'
timezone_string = 'GB'
else
timezone_string = 'GMT'
end
expect(pupil_history_page.check_history.rows.first.pin_gen.text).to eql check_details['createdAt'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(pupil_history_page.check_history.rows.first.login.text).to eql check_details['pupilLoginDate'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(pupil_history_page.check_history.rows.first.recieved.text).to eql @check_type == 'Official' ? check_details['receivedByServerAt'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ") : 'n/a'
zone = 'Europe/London'
expect(pupil_history_page.check_history.rows.first.pin_gen.text).to eql check_details['createdAt'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(pupil_history_page.check_history.rows.first.login.text).to eql check_details['pupilLoginDate'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(pupil_history_page.check_history.rows.first.recieved.text).to eql @check_type == 'Official' ? check_details['receivedByServerAt'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ") : 'n/a'
expect(pupil_history_page.check_history.rows.first.active.text).to eql @check_type == 'Official' ? '*' : ''
expect(pupil_history_page.check_history.rows.first.type.text).to eql @check_type
expect(pupil_history_page.check_history.rows.first.status.text).to eql @check_type == 'Official' ? "Check complete" : 'Logged in'
Expand All @@ -177,16 +162,11 @@
Then(/^I should see a list of all checks with the latest being marked as active$/) do
pupil_checks = SqlDbHelper.get_all_checks_from_school(@school_id).select {|check| check['pupil_id'] == @pupil_details['id']}.sort_by {|check| check['id']}
latest_check = pupil_checks.last
current_timezone = Time.now.zone
if current_timezone == 'BST'
timezone_string = 'GB'
else
timezone_string = 'GMT'
end
zone = 'Europe/London'
pupil_history_page.check_history.rows.each_with_index do |check, index|
expect(check.pin_gen.text).to eql pupil_checks[index]['createdAt'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(check.login.text).to eql pupil_checks[index]['pupilLoginDate'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(check.recieved.text).to eql pupil_checks[index]['receivedByServerAt'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(check.pin_gen.text).to eql pupil_checks[index]['createdAt'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(check.login.text).to eql pupil_checks[index]['pupilLoginDate'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(check.recieved.text).to eql pupil_checks[index]['receivedByServerAt'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(check.active.text).to eql pupil_checks[index] == latest_check ? '*' : ''
expect(check.type.text).to eql 'Official'
expect(check.status.text).to eql 'Check complete'
Expand Down Expand Up @@ -221,16 +201,11 @@
expect(pupil_history_page).to have_discretionary_restart_button
pupil_checks = SqlDbHelper.get_all_checks_from_school(@school_id).select {|check| check['pupil_id'] == @pupil_details['id']}.sort_by {|check| check['id']}
latest_check = pupil_checks.last
current_timezone = Time.now.zone
if current_timezone == 'BST'
timezone_string = 'GB'
else
timezone_string = 'GMT'
end
zone = 'Europe/London'
pupil_history_page.check_history.rows.each_with_index do |check, index|
expect(check.pin_gen.text).to eql pupil_checks[index]['createdAt'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(check.login.text).to eql pupil_checks[index]['pupilLoginDate'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(check.recieved.text).to eql pupil_checks[index]['receivedByServerAt'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(check.pin_gen.text).to eql pupil_checks[index]['createdAt'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(check.login.text).to eql pupil_checks[index]['pupilLoginDate'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(check.recieved.text).to eql pupil_checks[index]['receivedByServerAt'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(check.active.text).to eql pupil_checks[index] == latest_check ? '*' : ''
expect(check.type.text).to eql 'Official'
expect(check.status.text).to eql 'Check complete'
Expand All @@ -250,16 +225,11 @@
expect(pupil_history_page.pupil_history.discretionary_restart.text).to eql 'N'
pupil_checks = SqlDbHelper.get_all_checks_from_school(@school_id).select {|check| check['pupil_id'] == @pupil_details['id']}.sort_by {|check| check['id']}
latest_check = pupil_checks.last
current_timezone = Time.now.zone
if current_timezone == 'BST'
timezone_string = 'GB'
else
timezone_string = 'GMT'
end
zone = 'Europe/London'
pupil_history_page.check_history.rows.each_with_index do |check, index|
expect(check.pin_gen.text).to eql pupil_checks[index]['createdAt'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(check.login.text).to eql pupil_checks[index]['pupilLoginDate'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(check.recieved.text).to eql pupil_checks[index]['receivedByServerAt'].in_time_zone(timezone_string).strftime("%-d %b %H:%M #{current_timezone}").gsub(" ", " ")
expect(check.pin_gen.text).to eql pupil_checks[index]['createdAt'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(check.login.text).to eql pupil_checks[index]['pupilLoginDate'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(check.recieved.text).to eql pupil_checks[index]['receivedByServerAt'].in_time_zone(zone).strftime("%-d %b %H:%M %Z").gsub(" ", " ")
expect(check.active.text).to eql pupil_checks[index] == latest_check ? '*' : ''
expect(check.type.text).to eql 'Official'
expect(check.status.text).to eql 'Check complete'
Expand Down
2 changes: 1 addition & 1 deletion test/se_manager/.cache/selenium/se-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"browser_name": "chrome",
"major_browser_version": "119",
"browser_version": "119.0.6045.105",
"browser_ttl": 1718493022
"browser_ttl": 1718547024
}
],
"drivers": []
Expand Down

0 comments on commit fa318e8

Please sign in to comment.