Skip to content

Commit

Permalink
updated specs
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagoguridi committed Jan 15, 2025
1 parent 54a107e commit e99c08f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/views/planned_subjects/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% end %>

<div class="mdc-deprecated-list-group subjects-list">
<div class="subject-group-header">
<div class="subject-group-header" id="planned-subjects">
<h3 class="mdc-deprecated-list-group__subheader mdc-typography--subtitle2">
Materias planeadas
</h3>
Expand Down
6 changes: 5 additions & 1 deletion spec/support/planned_subjects_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ def assert_available_subject(subject_name)
end

def within_planned_subjects(&block)
within(:xpath, "//h3[contains(text(), 'Materias planeadas')]/following-sibling::*[1]", &block)
within(:xpath, "//div[@id='planned-subjects']/following-sibling::*[1]", &block)
end

def within_not_planned_approved_subjects(&block)
within(:xpath, "//h3[contains(text(), 'Materias aprobadas sin semestre asignado')]/following-sibling::*[1]", &block)
end

def within_not_planned_subjects(&block)
Expand Down
44 changes: 32 additions & 12 deletions spec/system/planned_subjects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,70 @@
visit planned_subjects_path

expect(page).to have_text "Materias planeadas"
expect(page).to have_text "Materias aprobadas sin semestre asignado"
expect(page).to have_text "Materias recomendadas"

within_planned_subjects do
expect(page).to have_no_text "GAL 1"
expect(page).to have_no_text "GAL 2"
assert_approved_subject "T1"
expect(page).to have_no_text "T1"
end

expect(page).to have_text "Créditos actuales: 11"
expect(page).to have_text "Créditos planeados: 11"
within_not_planned_approved_subjects do
expect(page).to have_no_text "GAL 1"
expect(page).to have_no_text "GAL 2"
expect(page).to have_text "T1"
end

expect(page).to have_text "Créditos planeados: 0"

within_not_planned_subjects do
expect(page).to have_text "GAL 1"
expect(page).to have_text "GAL 2"
expect(page).to have_no_text "T1"
end

within ".mdc-deprecated-list-item", text: "GAL 1" do
within ".mdc-deprecated-list-item", text: "T1" do
find("span", text: "add_circle_outline").click
end

within_planned_subjects do
assert_available_subject "GAL 1"
expect(page).to have_no_text "GAL 1"
expect(page).to have_no_text "GAL 2"
expect(page).to have_text "Primer semestre"
expect(page).to have_text "Créditos planeados: 11"
assert_approved_subject "T1"
end

expect(page).to have_no_text "Materias aprobadas sin semestre asignado"

within_not_planned_subjects do
expect(page).to have_no_text "GAL 1"
expect(page).to have_text "GAL 1"
expect(page).to have_text "GAL 2"
expect(page).to have_no_text "T1"
end

expect(page).to have_text "Créditos actuales: 11"
expect(page).to have_text "Créditos planeados: 20"
expect(page).to have_text "Créditos planeados: 11"

within ".mdc-deprecated-list-item", text: "GAL 1" do
find("span", text: "add_circle_outline").click
end

within ".mdc-deprecated-list-item", text: "GAL 2" do
select "Sem. 2", from: "semester"
find("span", text: "add_circle_outline").click
end

within_planned_subjects do
assert_available_subject "GAL 1"
assert_blocked_subject "GAL 2"
assert_approved_subject "T1"
expect(page).to have_text "Primer semestre"
expect(page).to have_text "Créditos planeados: 20"
assert_blocked_subject "GAL 2"
expect(page).to have_text "Segundo semestre"
expect(page).to have_text "Créditos planeados: 10"
end

expect(page).to have_text "Créditos actuales: 11"
expect(page).to have_text "Créditos planeados: 30"

within ".mdc-deprecated-list-item", text: "GAL 2" do
Expand All @@ -80,8 +97,12 @@

within_planned_subjects do
assert_available_subject "GAL 1"
expect(page).to have_no_text "GAL 2"
assert_approved_subject "T1"
expect(page).to have_text "Primer semestre"
expect(page).to have_text "Créditos planeados: 20"
expect(page).to have_no_text "GAL 2"
expect(page).to have_no_text "Segundo semestre"
expect(page).to have_no_text "Créditos planeados: 10"
end

within_not_planned_subjects do
Expand All @@ -90,7 +111,6 @@
expect(page).to have_no_text "T1"
end

expect(page).to have_text "Créditos actuales: 11"
expect(page).to have_text "Créditos planeados: 20"
end
end

0 comments on commit e99c08f

Please sign in to comment.