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

make script level checkboxes on lesson edit page work in UI tests #37641

Merged
merged 6 commits into from
Nov 29, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/src/lib/levelbuilder/lesson-editor/LevelToken.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ class LevelToken extends Component {
<div style={styles.reorder} onMouseDown={this.handleDragStart}>
<i className="fa fa-arrows-v" />
</div>
<span style={styles.levelTokenName} onMouseDown={this.toggleExpand}>
<span
style={styles.levelTokenName}
onClick={this.toggleExpand}
className="uitest-level-token-name"
>
<span style={styles.levelArea}>
<span style={styles.titleAndBubble}>
<ProgressBubble
Expand Down
4 changes: 2 additions & 2 deletions dashboard/app/models/activity_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def summarize_for_lesson_show
summary
end

def summarize_for_edit
def summarize_for_lesson_edit
summary = summarize
summary[:scriptLevels] = script_levels.map(&:summarize_for_edit)
summary[:scriptLevels] = script_levels.map(&:summarize_for_lesson_edit)
summary
end

Expand Down
8 changes: 4 additions & 4 deletions dashboard/app/models/lesson.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def lesson_plan_base_url
CDO.code_org_url "/curriculum/#{script.name}/#{relative_position}"
end

def summarize(include_bonus_levels = false)
def summarize(include_bonus_levels = false, for_edit: false)
lesson_summary = Rails.cache.fetch("#{cache_key}/lesson_summary/#{I18n.locale}/#{include_bonus_levels}") do
cached_levels = include_bonus_levels ? cached_script_levels : cached_script_levels.reject(&:bonus)

Expand All @@ -223,7 +223,7 @@ def summarize(include_bonus_levels = false)
title: localized_title,
lesson_group_display_name: lesson_group&.localized_display_name,
lockable: !!lockable,
levels: cached_levels.map {|l| l.summarize(false)},
levels: cached_levels.map {|sl| sl.summarize(false, for_edit: for_edit)},
Copy link
Member Author

Choose a reason for hiding this comment

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

note: we should no longer have to pass in for_edit here after PLAT-460 is done.

description_student: render_codespan_only_markdown(I18n.t("data.script.name.#{script.name}.lessons.#{key}.description_student", default: '')),
description_teacher: render_codespan_only_markdown(I18n.t("data.script.name.#{script.name}.lessons.#{key}.description_teacher", default: '')),
unplugged: display_as_unplugged # TODO: Update to use unplugged property
Expand Down Expand Up @@ -267,7 +267,7 @@ def summarize(include_bonus_levels = false)
# TODO: [PLAT-369] trim down to only include those fields needed on the
# script edit page
def summarize_for_script_edit
summary = summarize.dup
summary = summarize(for_edit: true).dup
# Do not let script name override lesson name when there is only one lesson
summary[:name] = name
summary.freeze
Expand Down Expand Up @@ -296,7 +296,7 @@ def summarize_for_lesson_edit
purpose: purpose,
preparation: preparation,
announcements: announcements,
activities: lesson_activities.map(&:summarize_for_edit),
activities: lesson_activities.map(&:summarize_for_lesson_edit),
resources: resources,
objectives: objectives.map(&:summarize_for_edit)
}
Expand Down
4 changes: 2 additions & 2 deletions dashboard/app/models/lesson_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def summarize_for_lesson_show
summary
end

def summarize_for_edit
def summarize_for_lesson_edit
summary = summarize
summary[:activitySections] = activity_sections.map(&:summarize_for_edit)
summary[:activitySections] = activity_sections.map(&:summarize_for_lesson_edit)
summary
end

Expand Down
8 changes: 4 additions & 4 deletions dashboard/app/models/script_level.rb
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def path
build_script_level_path(self)
end

def summarize(include_prev_next=true)
def summarize(include_prev_next=true, for_edit: false)
kind =
if level.unplugged?
LEVEL_KIND.unplugged
Expand Down Expand Up @@ -398,7 +398,7 @@ def summarize(include_prev_next=true)
summary[:sublevels] = level.summarize_sublevels(script_level: self)
end

if Rails.application.config.levelbuilder_mode
if for_edit
summary[:key] = level.key
summary[:skin] = level.try(:skin)
summary[:videoKey] = level.video_key
Expand Down Expand Up @@ -450,8 +450,8 @@ def summarize_for_lesson_show
summary
end

def summarize_for_edit
summary = summarize
def summarize_for_lesson_edit
summary = summarize(for_edit: true)
summary[:id] = id
summary[:activitySectionPosition] = activity_section_position
summary[:levels] = levels.map do |level|
Expand Down
8 changes: 4 additions & 4 deletions dashboard/test/controllers/lessons_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class LessonsControllerTest < ActionController::TestCase
assessment: true
)

existing_summary = existing_script_level.summarize_for_edit
existing_summary = existing_script_level.summarize_for_lesson_edit
assert_equal 1, existing_summary[:activitySectionPosition]
assert_equal existing_survey.id, existing_summary[:activeId]
existing_summary[:assessment] = false
Expand Down Expand Up @@ -615,7 +615,7 @@ class LessonsControllerTest < ActionController::TestCase
# sl 2
# activity 2
# section 2
activities_data = @lesson.lesson_activities.map(&:summarize_for_edit)
activities_data = @lesson.lesson_activities.map(&:summarize_for_lesson_edit)
assert_equal 2, activities_data.count
script_level_data = activities_data.last[:activitySections].first[:scriptLevels].pop
script_level_data[:activitySectionPosition] = 2
Expand Down Expand Up @@ -670,7 +670,7 @@ class LessonsControllerTest < ActionController::TestCase
# section 2
# sl 2
# sl 1
activities_data = @lesson.lesson_activities.map(&:summarize_for_edit)
activities_data = @lesson.lesson_activities.map(&:summarize_for_lesson_edit)
assert_equal 2, activities_data.count
script_level_data = activities_data.first[:activitySections].first[:scriptLevels].pop
script_level_data[:activitySectionPosition] = 2
Expand Down Expand Up @@ -712,7 +712,7 @@ class LessonsControllerTest < ActionController::TestCase
end
sl_ids = section.script_levels.map(&:id)

script_levels_data = section.script_levels.map(&:summarize_for_edit)
script_levels_data = section.script_levels.map(&:summarize_for_lesson_edit)
assert_equal 3, script_levels_data.count

@update_params['activities'] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,25 @@ Feature: Using the Lesson Edit Page
And I wait until element "#show-container" is visible
And I wait until element ".uitest-bubble" contains text "1"
Then element ".uitest-bubble" contains text "2"

Scenario: Update script level properties
Given I create a levelbuilder named "Levi"
And I create a temp script and lesson
And I view the temp lesson edit page
And I wait until element ".uitest-activity-card" is visible
And element ".uitest-level-token-name" is visible
And I press ".uitest-level-token-name" using jQuery
And I wait until element ".level-token-checkboxes" is visible
And element ".level-token-checkboxes input[type=checkbox]:nth(1)" is not checked
And I press ".level-token-checkboxes input[type=checkbox]:nth(1)" using jQuery
And element ".level-token-checkboxes input[type=checkbox]:nth(1)" is checked

When I click "button[type='submit']" to load a new page
And I wait until element "#show-container" is visible
Then element ".uitest-ProgressPill .fa-check" is visible

When I view the temp lesson edit page
And I wait until element ".uitest-activity-card" is visible
And I press ".uitest-level-token-name" using jQuery
And I wait until element ".level-token-checkboxes" is visible
Then element ".level-token-checkboxes input[type=checkbox]:nth(1)" is checked