Browse Source

Fix flaky test (#1991)

* Fix flaky test

* typo
pull/1992/head
kosiakkatrina 1 year ago committed by GitHub
parent
commit
6741f0bf9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      spec/requests/organisations_controller_spec.rb
  2. 2
      spec/requests/schemes_controller_spec.rb

4
spec/requests/organisations_controller_spec.rb

@ -123,12 +123,13 @@ RSpec.describe OrganisationsController, type: :request do
end end
end end
it "shows schemes in alpabetical order" do it "shows schemes in alphabetical order" do
schemes[0].update!(service_name: "aaa", owning_organisation: user.organisation) schemes[0].update!(service_name: "aaa", owning_organisation: user.organisation)
schemes[1].update!(service_name: "daa", owning_organisation: user.organisation) schemes[1].update!(service_name: "daa", owning_organisation: user.organisation)
schemes[2].update!(service_name: "baa", owning_organisation: user.organisation) schemes[2].update!(service_name: "baa", owning_organisation: user.organisation)
schemes[3].update!(service_name: "Faa", owning_organisation: user.organisation) schemes[3].update!(service_name: "Faa", owning_organisation: user.organisation)
schemes[4].update!(service_name: "Caa", owning_organisation: user.organisation) schemes[4].update!(service_name: "Caa", owning_organisation: user.organisation)
same_org_scheme.update!(service_name: "zzz", owning_organisation: user.organisation)
get "/organisations/#{organisation.id}/schemes", headers:, params: {} get "/organisations/#{organisation.id}/schemes", headers:, params: {}
all_links = page.all(".govuk-link") all_links = page.all(".govuk-link")
scheme_links = all_links.select { |link| link[:href] =~ %r{^/schemes/\d+$} } scheme_links = all_links.select { |link| link[:href] =~ %r{^/schemes/\d+$} }
@ -138,6 +139,7 @@ RSpec.describe OrganisationsController, type: :request do
expect(scheme_links[2][:href]).to eq("/schemes/#{schemes[4].id}") expect(scheme_links[2][:href]).to eq("/schemes/#{schemes[4].id}")
expect(scheme_links[3][:href]).to eq("/schemes/#{schemes[1].id}") expect(scheme_links[3][:href]).to eq("/schemes/#{schemes[1].id}")
expect(scheme_links[4][:href]).to eq("/schemes/#{schemes[3].id}") expect(scheme_links[4][:href]).to eq("/schemes/#{schemes[3].id}")
expect(scheme_links[5][:href]).to eq("/schemes/#{same_org_scheme.id}")
end end
context "with schemes that are not in scope for the user, i.e. that they do not belong to" do context "with schemes that are not in scope for the user, i.e. that they do not belong to" do

2
spec/requests/schemes_controller_spec.rb

@ -201,7 +201,7 @@ RSpec.describe SchemesController, type: :request do
assert_select ".govuk-tag", text: /Incomplete/, count: 1 assert_select ".govuk-tag", text: /Incomplete/, count: 1
end end
it "shows schemes in alpabetical order" do it "shows schemes in alphabetical order" do
schemes[0].update!(service_name: "aaa") schemes[0].update!(service_name: "aaa")
schemes[1].update!(service_name: "daa") schemes[1].update!(service_name: "daa")
schemes[2].update!(service_name: "baa") schemes[2].update!(service_name: "baa")

Loading…
Cancel
Save