-
Notifications
You must be signed in to change notification settings - Fork 479
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
Edit vocabulary lessons in dialog #38839
Changes from 6 commits
9b51c8c
1090d17
e7ecaf9
d15df44
c267101
2dc23ab
a32a9f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,10 @@ table { | |
} | ||
} | ||
} | ||
|
||
|
||
.lessons-dropdown { | ||
.Select-menu, .Select-menu-outer { | ||
z-index: 3000 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
%link{href: asset_path('css/lessons.css'), rel: 'stylesheet', type: 'text/css'} | ||
%script{src: webpack_asset_path('js/vocabularies/edit.js'), | ||
data: {vocabularies: @vocabularies.to_json, courseVersionId: @course_version.id, courseName: params[:course_name].to_json}} | ||
data: {vocabularies: @vocabularies.to_json, courseVersionData: {id: @course_version.id, lessons: @course_version.contained_lessons.map {|l| {id: l.id, name: l.name} }}.to_json, courseName: params[:course_name].to_json}} | ||
|
||
#vocabularies-table |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,20 @@ class VocabulariesControllerTest < ActionController::TestCase | |
assert(@response.body.include?('updated definition')) | ||
end | ||
|
||
test "can update lessons from params" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: "can update vocab from params"? |
||
sign_in @levelbuilder | ||
course_version = create :course_version | ||
lesson = create :lesson | ||
vocabulary = create :vocabulary, word: 'word', definition: 'draft definition', course_version: course_version | ||
post :update, params: {id: vocabulary.id, word: 'word', definition: 'updated definition', courseVersionId: course_version.id, lessonIds: [lesson.id].to_json} | ||
assert_response :success | ||
|
||
vocabulary.reload | ||
assert_equal 'updated definition', vocabulary.definition | ||
assert(@response.body.include?('updated definition')) | ||
assert_equal [lesson], vocabulary.lessons | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test looks good! I think it would be a good idea to add a test for saving the lesson after saving the vocab (issue shown in video in other comment). I'm not sure how easy it would be to add a rails unit or integration test, but it should be possible to cover it with a UI test, based on the UI tests we already have for saving the lesson edit page. Up to you whether that belongs in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to look into that bug separately and add tests there. |
||
|
||
test "creating vocabulary that already exists results in error" do | ||
sign_in @levelbuilder | ||
course_version = create :course_version | ||
|
@@ -53,7 +67,7 @@ class VocabulariesControllerTest < ActionController::TestCase | |
get :edit, params: {course_name: unit_group.name} | ||
assert_response :success | ||
assert_equal assigns(:course_version), course_version | ||
assert_equal assigns(:vocabularies), [vocabulary] | ||
assert_equal assigns(:vocabularies), [vocabulary.summarize_for_edit] | ||
end | ||
|
||
test "can load vocab edit page of standalone script course version" do | ||
|
@@ -65,6 +79,6 @@ class VocabulariesControllerTest < ActionController::TestCase | |
get :edit, params: {course_name: script.name} | ||
assert_response :success | ||
assert_equal assigns(:course_version), course_version | ||
assert_equal assigns(:vocabularies), [vocabulary] | ||
assert_equal assigns(:vocabularies), [vocabulary.summarize_for_edit] | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @Hamms has convinced me that these kinds of "brittle expectations" are not very helpful for the following reasons:
Generally, they make tests brittle without adding much value. For now, can I recommend removing lines 111 and 112?
Personally, I think there is some value in still having the "renders default props" test case, because in the event of a later test failure, whether this test case fails can immediately help narrow down the root cause. However, this is only valuable if other test cases go on to test actual business logic (which I am not commenting on one way or another in this comment). So let's leave that in for now, but we may keep it on the table whether to remove "renders default props" test cases entirely in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Add Vocabulary" does actually test business logic because the header is different in different cases. I see the point in removing line 112 so I'll go ahead and do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, great, thank you for pointing that out! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does! But I'd argue that means it should belong in a test that's specifically testing that the header is different in different cases, not be disguised as a test that claims to just be testing our ability to render