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

System specs for due invoice payment reminder #1431

Merged
merged 1 commit into from
Jul 28, 2023
Merged
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
58 changes: 58 additions & 0 deletions spec/system/clients/due_invoice_payment_reminder_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Due invoice payment reminder", type: :system do
let!(:company) { create(:company) }
let!(:client) { create(:client, company:) }
let(:user) { create(:user, current_workspace_id: company.id) }
let!(:invoice1) { create(:invoice_with_invoice_line_items, client:, status: "sent") }
let!(:invoice2) { create(:invoice_with_invoice_line_items, client:, status: "viewed") }
let!(:invoice3) { create(:invoice_with_invoice_line_items, client:, status: "overdue") }

before do
create(:employment, company:, user:)
user.add_role :admin, company
sign_in(user)
end

it "can view invoice number on payment reminder modal" do
with_forgery_protection do
visit "/clients/#{client.id}"

find("div.relative.h-8").click
click_button "Payment Reminder"

expect(page).to have_content(invoice1.invoice_number)
expect(page).to have_content(invoice2.invoice_number)
expect(page).to have_content(invoice3.invoice_number)
end
end

it "can view client email and subject on email preview" do
with_forgery_protection do
visit "/clients/#{client.id}"

find("div.relative.h-8").click
click_button "Payment Reminder"
click_button "Continue"

expect(page).to have_content(client.email)
expect(page).to have_content("Reminder to complete payments for unpaid invoices")
expect(page).to have_content(invoice3.invoice_number)
end
end

it "can send payment reminder to client" do
with_forgery_protection do
visit "/clients/#{client.id}"

find("div.relative.h-8").click
click_button "Payment Reminder"
click_button "Continue"
click_button "Send Reminder"

expect(page).to have_content("Payment reminder has been sent to #{client.email}")
end
end
end