Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break up large spec files #12502

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- name: Set up database
run: |
bundle exec rake db:create db:schema:load
bin/rake db:create db:schema:load

- name: Run tests
env:
Expand All @@ -83,7 +83,7 @@ jobs:
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/controllers/**/*_spec.rb}"
run: |
git show --no-patch # the commit being tested (which is often a merge due to actions/checkout@v3)
bundle exec rake knapsack_pro:rspec
bin/rake knapsack_pro:rspec

models:
runs-on: ubuntu-22.04
Expand All @@ -106,10 +106,10 @@ jobs:
# [n] - where the n is a number of parallel jobs you want to run your tests on.
# Use a higher number if you have slow tests to split them between more parallel jobs.
# Remember to update the value of the `ci_node_index` below to (0..n-1).
ci_node_total: [5]
ci_node_total: [4]
# Indexes for parallel jobs (starting from zero).
# E.g. use [0, 1] for 2 parallel jobs, [0, 1, 2] for 3 parallel jobs, etc.
ci_node_index: [0, 1, 2, 3, 4]
ci_node_index: [0, 1, 2, 3]
steps:
- uses: actions/checkout@v3

Expand All @@ -125,7 +125,7 @@ jobs:

- name: Set up database
run: |
bundle exec rake db:create db:schema:load
bin/rake db:create db:schema:load

- name: Run tests
env:
Expand All @@ -142,7 +142,7 @@ jobs:
#KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES: true
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/models/**/*_spec.rb}"
run: |
bundle exec rake knapsack_pro:rspec
bin/rake knapsack_pro:rspec

system_admin:
runs-on: ubuntu-22.04
Expand All @@ -165,10 +165,10 @@ jobs:
# [n] - where the n is a number of parallel jobs you want to run your tests on.
# Use a higher number if you have slow tests to split them between more parallel jobs.
# Remember to update the value of the `ci_node_index` below to (0..n-1).
ci_node_total: [13]
ci_node_total: [14]
# Indexes for parallel jobs (starting from zero).
# E.g. use [0, 1] for 2 parallel jobs, [0, 1, 2] for 3 parallel jobs, etc.
ci_node_index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
ci_node_index: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
steps:
- uses: actions/checkout@v3

Expand All @@ -191,7 +191,7 @@ jobs:

- name: Set up database
run: |
bundle exec rake db:create db:schema:load
bin/rake db:create db:schema:load

- name: Run tests

Expand All @@ -210,7 +210,7 @@ jobs:
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/system/admin/**/*_spec.rb}"

run: |
bundle exec rake knapsack_pro:queue:rspec
bin/rake knapsack_pro:queue:rspec

- name: Archive failed tests screenshots
if: failure()
Expand Down Expand Up @@ -268,7 +268,7 @@ jobs:

- name: Set up database
run: |
bundle exec rake db:create db:schema:load
bin/rake db:create db:schema:load

- name: Run tests

Expand All @@ -287,7 +287,7 @@ jobs:
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/system/consumer/**/*_spec.rb}"

run: |
bundle exec rake knapsack_pro:queue:rspec
bin/rake knapsack_pro:queue:rspec

- name: Archive failed tests screenshots
if: failure()
Expand Down Expand Up @@ -346,7 +346,7 @@ jobs:

- name: Set up database
run: |
bundle exec rake db:create db:schema:load
bin/rake db:create db:schema:load

- name: Run tests

Expand All @@ -365,7 +365,7 @@ jobs:
KNAPSACK_PRO_TEST_FILE_PATTERN: "{spec/lib/**/*_spec.rb,spec/migrations/**/*_spec.rb,spec/serializers/**/*_spec.rb,engines/**/*_spec.rb}"

run: |
bundle exec rake knapsack_pro:rspec
bin/rake knapsack_pro:rspec

- name: Archive failed tests screenshots
if: failure()
Expand Down Expand Up @@ -424,7 +424,7 @@ jobs:

- name: Set up database
run: |
bundle exec rake db:create db:schema:load
bin/rake db:create db:schema:load

- name: Run tests
env:
Expand All @@ -441,7 +441,7 @@ jobs:
#KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES: true
KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN: "{engines/**/*_spec.rb,spec/models/**/*_spec.rb,spec/controllers/**/*_spec.rb,spec/serializers/**/*_spec.rb,spec/lib/**/*_spec.rb,spec/migrations/**/*_spec.rb,spec/system/**/*_spec.rb}"
run: |
bundle exec rake knapsack_pro:rspec
bin/rake knapsack_pro:rspec

non_knapsack_jest_karma:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -475,7 +475,7 @@ jobs:
run: yarn install --frozen-lockfile

- name: Run JS tests
run: bundle exec rake karma:run
run: bin/rake karma:run

- name: Run jest tests
run: yarn jest
161 changes: 0 additions & 161 deletions spec/system/admin/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1140,165 +1140,4 @@ def searching_for_customers
end
end
end

describe "Legal Invoices", feature: :invoices do
before do
login_as user
end

describe "for order states" do
context "complete" do
let!(:order1) {
create(:order_with_totals_and_distribution, user:, distributor:,
order_cycle:, state: 'complete',
payment_state: 'balance_due',
customer_id: customer.id)
}

context "editing the order" do
before do
visit spree.edit_admin_order_path(order1)
end

it "displays the invoice tab" do
expect(page).to have_content "Complete".upcase
expect(page).to have_content "Invoices".upcase
end
end

context "visiting the invoices tab" do
let!(:table_header) {
[
"Date/Time",
"Invoice Number",
"Amount",
"Status",
"File",
].join(" ").upcase
}

let(:invoice_number){ "#{order.distributor_id}-1" }
let(:table_contents) {
[
Invoice.first.created_at.strftime('%B %d, %Y').to_s,
invoice_number,
"0.0",
"Active",
"Download"
].join(" ")
}
let(:download_href) {
"#{spree.print_admin_order_path(order1)}?invoice_id=#{Invoice.last.id}"
}

before do
Spree::Config[:enterprise_number_required_on_invoices?] = false
visit spree.admin_order_invoices_path(order1)
end

it "displays the invoices table" do
# with no invoices, only the table header is displayed
expect(page).to have_css "table.index"
expect(page).to have_content "#{customer.first_name} #{customer.last_name} -"
expect(page.find("table").text).to have_content(table_header)

# the New invoice button + the warning should be visible
expect(page).to have_link "Create or Update Invoice"
expect(page).to have_content "The order has changed since the last invoice update."
click_link "Create or Update Invoice"

# and disappear after clicking
expect(page).not_to have_link "Create or Update Invoice"
expect(page).not_to have_content "The order has changed since the last invoice update."

# creating an invoice, displays a second row
expect(page.find("table").text).to have_content(table_contents)

# with a valid invoice download link
expect(page).to have_link("Download",
href: download_href)
end

context "the Create or Update Invoice button" do
context "when an ABN number is mandatory for invoices but not present" do
before do
Spree::Config[:enterprise_number_required_on_invoices?] = true
end

it "displays a warning that an ABN is required when it's clicked" do
visit spree.admin_order_invoices_path(order1)
message = accept_prompt { click_link "Create or Update Invoice" }
distributor = order1.distributor
expect(message)
.to eq "#{distributor.name} must have a valid ABN before invoices can be used."
end
end
end
end
end

context "resumed" do
let!(:order2) {
create(:order_with_totals_and_distribution, user:, distributor:,
order_cycle:, state: 'resumed',
payment_state: 'balance_due')
}
before do
visit spree.edit_admin_order_path(order2)
end

it "displays the invoice tab" do
expect(page).to have_content "Resumed".upcase
expect(page).to have_content "Invoices".upcase
end
end

context "canceled" do
let!(:order3) {
create(:order_with_totals_and_distribution, user:, distributor:,
order_cycle:, state: 'canceled',
payment_state: 'balance_due')
}
before do
visit spree.edit_admin_order_path(order3)
end

it "displays the invoice tab" do
expect(page).to have_content "Cancelled".upcase
expect(page).to have_content "Invoices".upcase
end
end

context "cart" do
let!(:order_empty) {
create(:order_with_line_items, user:, distributor:, order_cycle:,
line_items_count: 0)
}
before do
visit spree.edit_admin_order_path(order_empty)
end

it "should not display the invoice tab" do
expect(page).to have_content "Cart".upcase
expect(page).not_to have_content "Invoices".upcase
end
end

context "payment" do
let!(:order4) do
create(:order_ready_for_payment, user:, distributor:,
order_cycle:,
payment_state: 'balance_due')
end
before do
visit spree.edit_admin_order_path(order4)
end

it "should not display the invoice tab" do
expect(page).to have_content "Payment".upcase
expect(page).not_to have_content "Invoices".upcase
end
end
end
end
end
Loading
Loading