Skip to content

Commit

Permalink
Fix system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
forsbergplustwo committed Sep 19, 2023
1 parent 03a6035 commit 5b8ccfb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
6 changes: 4 additions & 2 deletions test/system/imports/destroy_all_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class Imports::DestroyAllTest < ApplicationSystemTestCase

assert_text "View details", count: 2

accept_alert do
click_on "Delete all imports"
click_on "More actions"
click_on "Delete all imports"
within "#destroy-modal" do
click_on "Delete imports"
end
assert_text "All imports deleted"
assert_text "No imports yet"
Expand Down
9 changes: 5 additions & 4 deletions test/system/imports_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class ImportsTest < ApplicationSystemTestCase

attach_to_import("payouts-recurring.csv")

assert_button "Import", disabled: false
click_on "Import"
assert_button "Save", disabled: false
click_on "Save"

assert_text "Import successfully created."
assert_text "Import details"
Expand All @@ -42,8 +42,9 @@ class ImportsTest < ApplicationSystemTestCase
test "should destroy Import" do
visit import_url(@import)

accept_alert do
click_on "Delete import", match: :first
click_on "Delete import"
within "#destroy-modal" do
click_on "Delete import"
end

assert_text "Import successfully destroyed."
Expand Down
50 changes: 25 additions & 25 deletions test/system/partner_api_credentials_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,45 @@ class PartnerApiCredentialsTest < ApplicationSystemTestCase
@partner_api_credential = partner_api_credentials(:one)
end

test "visiting the index" do
visit partner_api_credentials_url
assert_selector "h1", text: "Partner api credentials"
end

test "should create partner api credential" do
visit partner_api_credentials_url
click_on "New partner api credential"
sign_in users(:new)
PartnerApiCredential.any_instance.expects(:credentials_have_access).returns(true)

visit root_url
find('span', text: 'Partner API Credentials').click

fill_in "Shopify organization ID", with: @partner_api_credential.organization_id
fill_in "Shopify access token", with: @partner_api_credential.access_token

fill_in "Access token", with: @partner_api_credential.access_token
fill_in "Organization", with: @partner_api_credential.organization_id
fill_in "Status", with: @partner_api_credential.status
fill_in "Status message", with: @partner_api_credential.status_message
fill_in "User", with: @partner_api_credential.user_id
click_on "Create Partner api credential"
click_on "Save"

assert_text "Partner api credential was successfully created"
click_on "Back"
end

test "should update Partner api credential" do
visit partner_api_credential_url(@partner_api_credential)
click_on "Edit this partner api credential", match: :first
sign_in users(:regular)
PartnerApiCredential.any_instance.expects(:credentials_have_access).returns(true)

fill_in "Access token", with: @partner_api_credential.access_token
fill_in "Organization", with: @partner_api_credential.organization_id
fill_in "Status", with: @partner_api_credential.status
fill_in "Status message", with: @partner_api_credential.status_message
fill_in "User", with: @partner_api_credential.user_id
click_on "Update Partner api credential"
visit root_url
find('span', text: 'Partner API Credentials').click

fill_in "Shopify organization ID", with: "54321"
fill_in "Shopify access token", with: @partner_api_credential.access_token

click_on "Save"

assert_text "Partner api credential was successfully updated"
click_on "Back"
end

test "should destroy Partner api credential" do
visit partner_api_credential_url(@partner_api_credential)
click_on "Destroy this partner api credential", match: :first
sign_in users(:regular)

visit edit_partner_api_credential_url(@partner_api_credential)

click_on "Delete"
within "#destroy-modal" do
click_on "Delete"
end
assert_text "Partner api credential was successfully destroyed"
end
end

0 comments on commit 5b8ccfb

Please sign in to comment.