-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Omit induction summary rows with no values
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -88,7 +88,7 @@ def rows | |
} | ||
} | ||
end | ||
@rows | ||
@rows.select { |row| row[:value][:text].present? } | ||
end | ||
|
||
def title | ||
|
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 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe InductionSummaryComponent, test: :with_fake_quals_data, type: :component do | ||
describe "rendering" do | ||
let(:fake_quals_data) do | ||
Hashie::Mash.new( | ||
quals_data(trn: "1234567") | ||
.deep_transform_keys(&:to_s) | ||
.deep_transform_keys(&:underscore) | ||
) | ||
end | ||
let(:induction) { fake_quals_data.fetch("induction") } | ||
let(:qualification) do | ||
Qualification.new( | ||
name: "Induction summary", | ||
awarded_at: induction.end_date&.to_date, | ||
type: :itt, | ||
details: induction | ||
) | ||
end | ||
let(:component) { described_class.new(qualification:) } | ||
let(:rendered) { render_inline(component) } | ||
|
||
it "renders the component title" do | ||
expect(rendered.css(".govuk-summary-card__title").text).to eq("Induction summary") | ||
end | ||
|
||
it "renders the component rows" do | ||
rows = rendered.css(".govuk-summary-list__row") | ||
expect(rows[0].css(".govuk-summary-list__key").text).to eq("Status") | ||
expect(rows[0].css(".govuk-summary-list__value").text).to eq("Pass") | ||
|
||
expect(rows[1].css(".govuk-summary-list__key").text).to eq("Completed") | ||
expect(rows[1].css(".govuk-summary-list__value").text).to eq(" 1 October 2022") | ||
|
||
expect(rows[2].css(".govuk-summary-list__key").text).to eq("Certificate") | ||
expect(rows[2].css(".govuk-summary-list__value").text).to eq("Download Induction certificate") | ||
|
||
expect(rows[3].css(".govuk-summary-list__key").text).to eq("Appropriate body") | ||
expect(rows[3].css(".govuk-summary-list__value").text).to eq("Induction body") | ||
|
||
expect(rows[4].css(".govuk-summary-list__key").text).to eq("Start date") | ||
expect(rows[4].css(".govuk-summary-list__value").text).to eq(" 1 September 2022") | ||
|
||
expect(rows[5].css(".govuk-summary-list__key").text).to eq("End date") | ||
expect(rows[5].css(".govuk-summary-list__value").text).to eq(" 1 October 2022") | ||
|
||
expect(rows[6].css(".govuk-summary-list__key").text).to eq("Number of terms") | ||
expect(rows[6].css(".govuk-summary-list__value").text).to eq("1") | ||
end | ||
|
||
it "renders does not render empty component rows" do | ||
component.qualification.awarded_at = nil | ||
|
||
expect(rendered.css(".govuk-summary-list__key").map(&:text)).not_to include("Completed") | ||
end | ||
end | ||
end |