-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
System specs for due invoice payment reminder (#1431)
add system specs for due invoice payment reminder
- Loading branch information
1 parent
200da9c
commit 4e1e4d2
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |