Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ceara/aitt 602 levelbuilder instructions test #58329

Merged
merged 2 commits into from
May 2, 2024

Conversation

cearachew
Copy link
Contributor

Warning!!

The AP CSP Create Performance Task is in progress. The most critical dates are from April 3 - April 30, 2024. Please consider any risk introduced by this PR that could affect our students taking AP CSP. Code.org students taking AP CSP primarily use App Lab for their Create Task, however a small percent use Game Lab. Carefully consider whether your change has any risk of alterering, changing, or breaking anything in these two labs. Even small changes, such as a different button color, are considered significant during this time period. Reach out to the Student Learning team or Curriculum team for more details.

Description

Adds a ruby integration test that verifies that the levelbuilder /instructions view is successfully created. There is one test that creates a simple /instructions page, and another test that creates a page with a variety of level types to display, including ones that previously broke the page.

Links

Jira ticket: https://codedotorg.atlassian.net/browse/AITT-602
Follow up to this commit: #54547

Testing story

When I undo the fix to the instructions page from this commit, the new test fails, with the fix from that commit, the test passes

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, thanks for picking this up!

Comment on lines +95 to +154
@unit = create :script, name: 'csp2-2020'
lesson_group = create :lesson_group, script: @unit
@lesson = create(
:lesson,
script_id: @unit.id,
lesson_group: lesson_group,
name: 'first lesson',
relative_position: 1,
absolute_position: 1,
has_lesson_plan: true,
properties: {
overview: 'lesson overview',
student_overview: 'student overview'
}
)
@lesson2 = create(
:lesson,
script_id: @unit.id,
lesson_group: lesson_group,
name: 'second lesson',
relative_position: 2,
absolute_position: 2,
has_lesson_plan: true
)
@level = create :maze
@level2 = create(:level, long_instructions: 'foo', short_instructions: 'bar')
@level3 = create :multi
@script_level1 = create(
:script_level,
activity_section: @activity_section,
activity_section_position: 1,
chapter: 1,
position: 1,
lesson: @lesson,
script: @lesson.script,
levels: [@level],
challenge: true
)
@script_level2 = create(
:script_level,
activity_section: @activity_section,
activity_section_position: 1,
chapter: 1,
position: 2,
lesson: @lesson,
script: @lesson.script,
levels: [@level2],
challenge: true
)
@script_level3 = create(
:script_level,
activity_section: @activity_section,
activity_section_position: 1,
chapter: 1,
position: 1,
lesson: @lesson2,
script: @lesson2.script,
levels: [@level3],
challenge: true
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may be able to replace all of this with something like:

@unit = create(:script, name: ..., :with_levels, lessons_count: 2, levels_count: 2)
@unit.lessons.first.script_levels.first.update!(challenge: true)
...
assert_select '.instructions_summary h1', "Lesson 1: #{@script.lessons.first.name}"

this invokes:

trait :with_levels do
transient do
lessons_count {1}
levels_count {2}
end
after(:create) do |script, evaluator|
lesson_group = create :lesson_group, script: script
evaluator.lessons_count.times do
lesson = create :lesson, :with_activity_section, lesson_group: lesson_group
evaluator.levels_count.times do
level = create(:level)
create :script_level, levels: [level], activity_section: lesson.activity_sections.first

fine to keep what you have this time, but worth looking in the factories for shortcuts next time.

@cearachew cearachew merged commit fb6dd60 into staging May 2, 2024
2 checks passed
@cearachew cearachew deleted the ceara/AITT-602-levelbuilder-instructions-test branch May 2, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants