Skip to content

Commit

Permalink
System specs for due invoice payment reminder (#1431)
Browse files Browse the repository at this point in the history
add system specs for due invoice payment reminder
  • Loading branch information
mayankagnihotri7 authored Jul 28, 2023
1 parent 200da9c commit 4e1e4d2
Showing 1 changed file with 58 additions and 0 deletions.
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

0 comments on commit 4e1e4d2

Please sign in to comment.