-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from camino-school/report-card-tests
Report card tests
- Loading branch information
Showing
7 changed files
with
266 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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
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
83 changes: 83 additions & 0 deletions
83
test/lanttern_web/live/pages/report_cards/id/report_card_live_test.exs
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,83 @@ | ||
defmodule LantternWeb.ReportCardLiveTest do | ||
use LantternWeb.ConnCase | ||
|
||
import Lanttern.ReportingFixtures | ||
|
||
alias Lanttern.LearningContextFixtures | ||
alias Lanttern.SchoolsFixtures | ||
alias Lanttern.TaxonomyFixtures | ||
|
||
@live_view_path_base "/report_cards" | ||
|
||
setup [:register_and_log_in_user] | ||
|
||
describe "Report card live view basic navigation" do | ||
test "disconnected and connected mount", %{conn: conn} do | ||
report_card = report_card_fixture(%{name: "Some report card name abc"}) | ||
|
||
conn = get(conn, "#{@live_view_path_base}/#{report_card.id}") | ||
|
||
assert html_response(conn, 200) =~ ~r"<h1 .+>\s*Some report card name abc\s*<\/h1>" | ||
|
||
{:ok, _view, _html} = live(conn) | ||
end | ||
|
||
test "list students and students report cards", %{conn: conn} do | ||
cycle_2024 = | ||
SchoolsFixtures.cycle_fixture(%{ | ||
start_at: ~D[2024-01-01], | ||
end_at: ~D[2024-12-31], | ||
name: "Cycle 2024" | ||
}) | ||
|
||
report_card = | ||
report_card_fixture(%{school_cycle_id: cycle_2024.id, name: "Some report card name abc"}) | ||
|
||
student_a = SchoolsFixtures.student_fixture(%{name: "Student AAA"}) | ||
_student_b = SchoolsFixtures.student_fixture(%{name: "Student BBB"}) | ||
|
||
student_a_report_card = | ||
student_report_card_fixture(%{report_card_id: report_card.id, student_id: student_a.id}) | ||
|
||
{:ok, view, _html} = live(conn, "#{@live_view_path_base}/#{report_card.id}") | ||
|
||
assert view |> has_element?("h1", report_card.name) | ||
assert view |> has_element?("span", "Cycle: Cycle 2024") | ||
assert view |> has_element?("span", "Student AAA") | ||
assert view |> has_element?("span", "Student BBB") | ||
|
||
view | ||
|> element("a", "Preview") | ||
|> render_click() | ||
|
||
assert_redirect(view, "/student_report_card/#{student_a_report_card.id}") | ||
end | ||
|
||
test "list strand reports", %{conn: conn} do | ||
report_card = report_card_fixture() | ||
|
||
subject = TaxonomyFixtures.subject_fixture(%{name: "Some subject SSS"}) | ||
year = TaxonomyFixtures.year_fixture(%{name: "Some year YYY"}) | ||
|
||
strand = | ||
LearningContextFixtures.strand_fixture(%{ | ||
name: "Strand for report ABC", | ||
type: "Some type XYZ", | ||
subjects_ids: [subject.id], | ||
years_ids: [year.id] | ||
}) | ||
|
||
strand_report = | ||
strand_report_fixture(%{report_card_id: report_card.id, strand_id: strand.id}) | ||
|
||
{:ok, view, _html} = live(conn, "#{@live_view_path_base}/#{report_card.id}?tab=strands") | ||
|
||
assert view | ||
|> has_element?("#strands_reports-#{strand_report.id} h5", "Strand for report ABC") | ||
|
||
assert view |> has_element?("#strands_reports-#{strand_report.id} p", "Some type XYZ") | ||
assert view |> has_element?("#strands_reports-#{strand_report.id} span", subject.name) | ||
assert view |> has_element?("#strands_reports-#{strand_report.id} span", year.name) | ||
end | ||
end | ||
end |
92 changes: 92 additions & 0 deletions
92
...student_report_card/id/strand_report/strand_report_id/student_strand_report_live_test.exs
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,92 @@ | ||
defmodule LantternWeb.StudentStrandReportLiveTest do | ||
use LantternWeb.ConnCase | ||
|
||
import Lanttern.ReportingFixtures | ||
|
||
alias Lanttern.LearningContextFixtures | ||
alias Lanttern.SchoolsFixtures | ||
alias Lanttern.TaxonomyFixtures | ||
|
||
@live_view_path_base "/student_report_card" | ||
|
||
setup [:register_and_log_in_user] | ||
|
||
describe "Student strand report live view basic navigation" do | ||
test "disconnected and connected mount", %{conn: conn} do | ||
student = SchoolsFixtures.student_fixture(%{name: "Student ABC"}) | ||
report_card = report_card_fixture(%{name: "Some report card name abc"}) | ||
|
||
student_report_card = | ||
student_report_card_fixture(%{report_card_id: report_card.id, student_id: student.id}) | ||
|
||
strand = LearningContextFixtures.strand_fixture(%{name: "Some strand name for report"}) | ||
|
||
strand_report = | ||
strand_report_fixture(%{report_card_id: report_card.id, strand_id: strand.id}) | ||
|
||
conn = | ||
get( | ||
conn, | ||
"#{@live_view_path_base}/#{student_report_card.id}/strand_report/#{strand_report.id}" | ||
) | ||
|
||
response = html_response(conn, 200) | ||
assert response =~ ~r"<h1 .+>\s*Some strand name for report\s*<\/h1>" | ||
|
||
{:ok, _view, _html} = live(conn) | ||
end | ||
|
||
test "display student strand report correctly", %{conn: conn} do | ||
cycle = SchoolsFixtures.cycle_fixture(%{name: "Cycle 2024"}) | ||
student = SchoolsFixtures.student_fixture(%{name: "Student ABC"}) | ||
|
||
report_card = | ||
report_card_fixture(%{school_cycle_id: cycle.id, name: "Some report card name abc"}) | ||
|
||
student_report_card = | ||
student_report_card_fixture(%{ | ||
report_card_id: report_card.id, | ||
student_id: student.id, | ||
comment: "student abc comment", | ||
footnote: "student abc footnote" | ||
}) | ||
|
||
subject = TaxonomyFixtures.subject_fixture(%{name: "Some subject SSS"}) | ||
year = TaxonomyFixtures.year_fixture(%{name: "Some year YYY"}) | ||
|
||
strand = | ||
LearningContextFixtures.strand_fixture(%{ | ||
name: "Strand for report ABC", | ||
type: "Some type XYZ", | ||
subjects_ids: [subject.id], | ||
years_ids: [year.id] | ||
}) | ||
|
||
strand_report = | ||
strand_report_fixture(%{ | ||
report_card_id: report_card.id, | ||
strand_id: strand.id, | ||
description: "Some description for strand report" | ||
}) | ||
|
||
{:ok, view, _html} = | ||
live( | ||
conn, | ||
"#{@live_view_path_base}/#{student_report_card.id}/strand_report/#{strand_report.id}" | ||
) | ||
|
||
assert view |> has_element?("a", "Student ABC") | ||
assert view |> has_element?("a", "Some report card name abc") | ||
assert view |> has_element?("p", "student abc footnote") | ||
|
||
# strand report card | ||
assert view | ||
|> has_element?("h1", "Strand for report ABC") | ||
|
||
assert view |> has_element?("p", "Some type XYZ") | ||
assert view |> has_element?("span", "Some subject SSS") | ||
assert view |> has_element?("span", "Some year YYY") | ||
assert view |> has_element?("p", "Some description for strand report") | ||
end | ||
end | ||
end |
86 changes: 86 additions & 0 deletions
86
test/lanttern_web/live/pages/student_report_card/id/student_report_card_live_test.exs
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,86 @@ | ||
defmodule LantternWeb.StudentReportCardLiveTest do | ||
use LantternWeb.ConnCase | ||
|
||
import Lanttern.ReportingFixtures | ||
|
||
alias Lanttern.LearningContextFixtures | ||
alias Lanttern.SchoolsFixtures | ||
alias Lanttern.TaxonomyFixtures | ||
|
||
@live_view_path_base "/student_report_card" | ||
|
||
setup [:register_and_log_in_user] | ||
|
||
describe "Student report card live view basic navigation" do | ||
test "disconnected and connected mount", %{conn: conn} do | ||
student = SchoolsFixtures.student_fixture(%{name: "Student ABC"}) | ||
report_card = report_card_fixture(%{name: "Some report card name abc"}) | ||
|
||
student_report_card = | ||
student_report_card_fixture(%{report_card_id: report_card.id, student_id: student.id}) | ||
|
||
conn = get(conn, "#{@live_view_path_base}/#{student_report_card.id}") | ||
|
||
response = html_response(conn, 200) | ||
assert response =~ ~r"<h1 .+>\s*Student ABC\s*<\/h1>" | ||
assert response =~ ~r"<h2 .+>\s*Some report card name abc\s*<\/h2>" | ||
|
||
{:ok, _view, _html} = live(conn) | ||
end | ||
|
||
test "display student report card correctly", %{conn: conn} do | ||
cycle = SchoolsFixtures.cycle_fixture(%{name: "Cycle 2024"}) | ||
student = SchoolsFixtures.student_fixture(%{name: "Student ABC"}) | ||
|
||
report_card = | ||
report_card_fixture(%{school_cycle_id: cycle.id, name: "Some report card name abc"}) | ||
|
||
student_report_card = | ||
student_report_card_fixture(%{ | ||
report_card_id: report_card.id, | ||
student_id: student.id, | ||
comment: "student abc comment", | ||
footnote: "student abc footnote" | ||
}) | ||
|
||
subject = TaxonomyFixtures.subject_fixture(%{name: "Some subject SSS"}) | ||
year = TaxonomyFixtures.year_fixture(%{name: "Some year YYY"}) | ||
|
||
strand = | ||
LearningContextFixtures.strand_fixture(%{ | ||
name: "Strand for report ABC", | ||
type: "Some type XYZ", | ||
subjects_ids: [subject.id], | ||
years_ids: [year.id] | ||
}) | ||
|
||
strand_report = | ||
strand_report_fixture(%{report_card_id: report_card.id, strand_id: strand.id}) | ||
|
||
{:ok, view, _html} = live(conn, "#{@live_view_path_base}/#{student_report_card.id}") | ||
|
||
assert view |> has_element?("h1", "Student ABC") | ||
assert view |> has_element?("h2", "Some report card name abc") | ||
assert view |> has_element?("p", "student abc comment") | ||
assert view |> has_element?("p", "student abc footnote") | ||
|
||
# strand report card | ||
assert view | ||
|> has_element?("#strand-report-#{strand_report.id} h5", "Strand for report ABC") | ||
|
||
assert view |> has_element?("#strand-report-#{strand_report.id} p", "Some type XYZ") | ||
assert view |> has_element?("#strand-report-#{strand_report.id} span", "Some subject SSS") | ||
assert view |> has_element?("#strand-report-#{strand_report.id} span", "Some year YYY") | ||
|
||
# navigation to details | ||
view | ||
|> element("#strand-report-#{strand_report.id} a", "Strand for report ABC") | ||
|> render_click() | ||
|
||
assert_redirect( | ||
view, | ||
"#{@live_view_path_base}/#{student_report_card.id}/strand_report/#{strand_report.id}" | ||
) | ||
end | ||
end | ||
end |