diff --git a/.rubocop.yml b/.rubocop.yml index af09f01fd3..8e5ece231a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -90,6 +90,8 @@ Style/HashSyntax: FactoryBot/ConsistentParenthesesStyle: EnforcedStyle: omit_parentheses +FactoryBot/ExcessiveCreateList: + MaxAmount: 50 Minitest/MultipleAssertions: Enabled: false diff --git a/test/system/annotations_test.rb b/test/system/annotations_test.rb index ef212b6c6c..04f9d3cc8b 100644 --- a/test/system/annotations_test.rb +++ b/test/system/annotations_test.rb @@ -37,7 +37,7 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Navigate to code tab' do visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' within '.code-listing' do @code_lines.each { |code_line| assert_text code_line } end @@ -45,7 +45,7 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Submission annotation button is present for each code line' do visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' within '.code-listing' do (1..@code_lines.length).each do |index| @@ -59,7 +59,7 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Click on submission annotation button' do visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' find('tr#line-1').hover find('.annotation-button a').click @@ -74,7 +74,7 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Enter annotation and send' do visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' find('tr#line-1').hover find('.annotation-button a').click @@ -82,7 +82,7 @@ class AnnotationsTest < ApplicationSystemTestCase initial = 'This is a single line comment' within 'form.annotation-submission' do find('textarea.annotation-submission-input').fill_in with: initial - click_button 'Comment' + click_on 'Comment' end within '.annotation' do @@ -94,7 +94,7 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Character counter updates when typing' do visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' find('tr#line-1').hover find('.annotation-button a').click @@ -111,12 +111,12 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Cancel annotation form' do visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' find('tr#line-1').hover find('.annotation-button a').click within 'form.annotation-submission' do - click_button 'Cancel' + click_on 'Cancel' end assert_no_css '.annotation' @@ -127,7 +127,7 @@ class AnnotationsTest < ApplicationSystemTestCase annot = create :annotation, submission: @instance, user: @zeus visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' within '.annotation' do assert_text annot.annotation_text @@ -141,7 +141,7 @@ class AnnotationsTest < ApplicationSystemTestCase within 'form.annotation-submission' do find('textarea.annotation-submission-input').fill_in with: replacement - click_button 'Update' + click_on 'Update' end within '.annotation' do @@ -154,7 +154,7 @@ class AnnotationsTest < ApplicationSystemTestCase annot = create :annotation, submission: @instance, user: @zeus visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' within '.annotation' do assert_text annot.annotation_text @@ -171,22 +171,22 @@ class AnnotationsTest < ApplicationSystemTestCase test 'User moving back and forth over code and tests' do visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' - click_link 'Correctheid' - click_link 'Code' + click_on 'Correctheid' + click_on 'Code' annot = create :annotation, submission: @instance, user: @zeus visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' assert_selector '.annotation', count: 1 within '.annotation' do assert_text annot.annotation_text end - click_link 'Correctheid' - click_link 'Code' + click_on 'Correctheid' + click_on 'Code' assert_selector '.annotation', count: 1 within '.annotation' do @@ -197,7 +197,7 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Edit valid annotation -- Too large input text' do annot = create :annotation, submission: @instance, user: @zeus visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' assert_selector '.annotation', count: 1 within '.annotation' do @@ -224,7 +224,7 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Edit valid annotation -- Zero length input text' do annot = create :annotation, submission: @instance, user: @zeus visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' assert_selector '.annotation', count: 1 within '.annotation' do @@ -237,12 +237,12 @@ class AnnotationsTest < ApplicationSystemTestCase replacement = '' within 'form.annotation-submission' do find('textarea.annotation-submission-input').fill_in with: replacement - click_button 'Update' + click_on 'Update' end # Cancel the form within 'form.annotation-submission' do - click_button 'Cancel' + click_on 'Cancel' end # Check if the view is correct without reloading @@ -253,7 +253,7 @@ class AnnotationsTest < ApplicationSystemTestCase # After reload, make sure no replacing has taken place visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' assert_selector '.annotation', count: 1 within '.annotation' do @@ -265,7 +265,7 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Enter invalid annotation and send - No content' do visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' find('tr#line-1').hover find('.annotation-button a').click @@ -273,26 +273,26 @@ class AnnotationsTest < ApplicationSystemTestCase initial = '' within 'form.annotation-submission' do find('textarea.annotation-submission-input').fill_in with: initial - click_button 'Comment' + click_on 'Comment' # Assuming the update did not go trough # If the creation went trough, the cancel button would not exist anymore - click_button 'Cancel' + click_on 'Cancel' end assert_selector '.annotation', count: 0 # After reload, make sure no creation has taken place visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' assert_selector '.annotation', count: 0 end test 'Enter invalid annotation and send - Content too long' do visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' find('tr#line-1').hover find('.annotation-button a').click @@ -310,14 +310,14 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Enter global annotation' do visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' - click_button 'Add global comment' + click_on 'Add global comment' initial = Faker::Lorem.words(number: 128).join(' ') within 'd-annotation-form' do find('textarea.annotation-submission-input').fill_in with: initial - click_button 'Comment' + click_on 'Comment' end assert_selector '.annotation', count: 1 @@ -328,7 +328,7 @@ class AnnotationsTest < ApplicationSystemTestCase # After reload, make sure creation has taken place visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' assert_selector '.annotation', count: 1 within '.annotation' do @@ -340,7 +340,7 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Edit global annotation' do annot = create :annotation, submission: @instance, user: @zeus, line_nr: nil visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' assert_selector '.annotation', count: 1 within '.annotation' do @@ -354,7 +354,7 @@ class AnnotationsTest < ApplicationSystemTestCase replacement = Faker::Lorem.words(number: 32).join(' ') within 'form.annotation-submission' do find('textarea.annotation-submission-input').fill_in with: replacement - click_button 'Update' + click_on 'Update' end within '.annotation' do assert_no_text old_text @@ -363,7 +363,7 @@ class AnnotationsTest < ApplicationSystemTestCase # After reload, make sure creation has taken place visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' assert_selector '.annotation', count: 1 within '.annotation' do @@ -375,7 +375,7 @@ class AnnotationsTest < ApplicationSystemTestCase test 'Can reply to an annotation' do create :annotation, submission: @instance, user: @zeus visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' thread = find('d-thread') within thread do @@ -388,7 +388,7 @@ class AnnotationsTest < ApplicationSystemTestCase answer_field = find('textarea') answer_field.fill_in with: answer - click_button 'Reply' + click_on 'Reply' assert_selector '.annotation', count: 2 end @@ -398,7 +398,7 @@ class AnnotationsTest < ApplicationSystemTestCase annot = create :annotation, submission: @instance, user: @zeus create :annotation, submission: @instance, user: @zeus, thread_root: annot visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' within 'd-thread' do assert_selector '.annotation', count: 2 @@ -415,7 +415,7 @@ class AnnotationsTest < ApplicationSystemTestCase annot = create :annotation, submission: @instance, user: @zeus create :annotation, submission: @instance, user: @zeus, thread_root: annot visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' within 'd-thread' do assert_selector '.annotation', count: 2 @@ -440,7 +440,7 @@ class AnnotationsTest < ApplicationSystemTestCase create :annotation, submission: @instance, user: @zeus, thread_root: annot create :annotation, submission: @instance, user: @zeus, thread_root: annot visit(submission_path(id: @instance.id)) - click_link 'Code' + click_on 'Code' within 'd-thread' do assert_selector '.annotation', count: 3 diff --git a/test/system/courses_test.rb b/test/system/courses_test.rb index 1ae53a6657..2634335f51 100644 --- a/test/system/courses_test.rb +++ b/test/system/courses_test.rb @@ -25,11 +25,11 @@ class CoursesTest < ApplicationSystemTestCase assert_selector 'd-filter-tabs li:first-child a.active' assert_selector '#courses-table-wrapper tbody tr', count: 2 - find('d-filter-tabs').click_link 'All courses' + find('d-filter-tabs').click_on 'All courses' assert_selector 'd-filter-tabs li:nth-of-type(3) a.active' assert_selector '#courses-table-wrapper tbody tr', count: 4 - find('d-filter-tabs').click_link 'My courses' + find('d-filter-tabs').click_on 'My courses' assert_selector 'd-filter-tabs li:nth-of-type(4) a.active' assert_selector '#courses-table-wrapper tbody tr', count: 1 diff --git a/test/system/feedbacks_test.rb b/test/system/feedbacks_test.rb index 87ebdf9b52..a8e0f2ea06 100644 --- a/test/system/feedbacks_test.rb +++ b/test/system/feedbacks_test.rb @@ -116,7 +116,7 @@ class FeedbacksTest < ApplicationSystemTestCase test 'all zero works' do visit(feedback_path(id: @feedback.id)) - click_button(id: 'zero-button') + click_on(id: 'zero-button') first_input = find(id: "#{@score_item_first.id}-score-form-wrapper").find('.score-input:not(.in-progress)') second_input = find(id: "#{@score_item_second.id}-score-form-wrapper").find('.score-input:not(.in-progress)') @@ -127,7 +127,7 @@ class FeedbacksTest < ApplicationSystemTestCase test 'all max works' do visit(feedback_path(id: @feedback.id)) - click_button(id: 'max-button') + click_on(id: 'max-button') first_input = find(id: "#{@score_item_first.id}-score-form-wrapper").find('.score-input:not(.in-progress)') second_input = find(id: "#{@score_item_second.id}-score-form-wrapper").find('.score-input:not(.in-progress)') diff --git a/test/system/questions_test.rb b/test/system/questions_test.rb index a6ab75629b..9a429eab26 100644 --- a/test/system/questions_test.rb +++ b/test/system/questions_test.rb @@ -27,7 +27,7 @@ class QuestionsTest < ApplicationSystemTestCase test 'Can ask question for each line of the available lines of code' do visit(submission_path(id: @submission.id)) - click_link 'Code' + click_on 'Code' within '.code-listing' do (1..@code_lines.length).each do |index| @@ -42,7 +42,7 @@ class QuestionsTest < ApplicationSystemTestCase assert_css 'form.annotation-submission' # cancel form to limit page space taken within 'form.annotation-submission' do - click_button 'Cancel' + click_on 'Cancel' end end end @@ -51,10 +51,10 @@ class QuestionsTest < ApplicationSystemTestCase test 'Can ask global question about code' do visit(submission_path(id: @submission.id)) - click_link 'Code' + click_on 'Code' within '.code-table' do - click_button 'Ask a question about your code' + click_on 'Ask a question about your code' assert_css 'form.annotation-submission' end @@ -62,12 +62,12 @@ class QuestionsTest < ApplicationSystemTestCase test 'Can submit a question' do visit(submission_path(id: @submission.id)) - click_link 'Code' + click_on 'Code' question = Faker::Lorem.question within '.code-table' do - click_button 'Ask a question about your code' + click_on 'Ask a question about your code' form = find('form.annotation-submission') @@ -76,7 +76,7 @@ class QuestionsTest < ApplicationSystemTestCase text_area.fill_in with: question end - click_button 'Ask question' + click_on 'Ask question' assert_text question # Also acts as sleep until full ajax call is completed @@ -96,7 +96,7 @@ class QuestionsTest < ApplicationSystemTestCase assert_predicate q, :unanswered?, 'Question should start as unanswered' visit(submission_path(id: @submission.id)) - click_link 'Code' + click_on 'Code' thread = find('d-thread') within thread do @@ -120,7 +120,7 @@ class QuestionsTest < ApplicationSystemTestCase assert_predicate q, :unanswered?, 'Question should start as unanswered' visit(submission_path(id: @submission.id)) - click_link 'Code' + click_on 'Code' thread = find('d-thread') within thread do @@ -133,7 +133,7 @@ class QuestionsTest < ApplicationSystemTestCase answer_field = find('textarea') answer_field.fill_in with: answer - click_button 'Reply' + click_on 'Reply' assert_selector '.annotation', count: 2 end @@ -150,7 +150,7 @@ class QuestionsTest < ApplicationSystemTestCase assert_predicate q, :unanswered?, 'Question should start as unanswered' visit(submission_path(id: @submission.id)) - click_link 'Code' + click_on 'Code' thread = find('d-thread') @@ -166,7 +166,7 @@ class QuestionsTest < ApplicationSystemTestCase assert_predicate q, :unanswered?, 'Question should start as unanswered' visit(submission_path(id: @submission.id)) - click_link 'Code' + click_on 'Code' thread = find('d-thread') within thread do @@ -186,7 +186,7 @@ class QuestionsTest < ApplicationSystemTestCase assert_predicate q, :unanswered?, 'Question should start as unanswered' visit(submission_path(id: @submission.id)) - click_link 'Code' + click_on 'Code' thread = find('d-thread') within thread do @@ -197,7 +197,7 @@ class QuestionsTest < ApplicationSystemTestCase assert_selector '.mdi-comment-processing-outline' assert_predicate q.reload, :in_progress?, 'Question should have moved onto in progress status' - click_button 'Cancel' + click_on 'Cancel' assert_selector '.mdi-comment-question-outline' assert_predicate q.reload, :unanswered?, 'Question should have moved onto unanswered status' diff --git a/test/system/saved_annotation_test.rb b/test/system/saved_annotation_test.rb index 3de815612c..e59201e418 100644 --- a/test/system/saved_annotation_test.rb +++ b/test/system/saved_annotation_test.rb @@ -29,7 +29,7 @@ class SavedAnnotationsTest < ApplicationSystemTestCase test 'Staff can save an annotation' do sign_in @staff visit(submission_path(id: @first.id)) - click_link 'Code' + click_on 'Code' find('tr#line-1').hover find('.annotation-button a').click @@ -46,7 +46,7 @@ class SavedAnnotationsTest < ApplicationSystemTestCase find_by_id('check-save-annotation').check assert_equal 'The first five words of', find_by_id('saved-annotation-title').value - click_button 'Comment' + click_on 'Comment' end within '.annotation' do @@ -60,7 +60,7 @@ class SavedAnnotationsTest < ApplicationSystemTestCase test 'Student cannot save an annotation' do sign_in @student visit(submission_path(id: @first.id)) - click_link 'Code' + click_on 'Code' find('tr#line-1').hover find('.annotation-button a').click @@ -71,7 +71,7 @@ class SavedAnnotationsTest < ApplicationSystemTestCase find('textarea.annotation-submission-input').fill_in with: initial assert_no_css '#check-save-annotation' - click_button 'Ask question' + click_on 'Ask question' end within '.annotation' do @@ -87,7 +87,7 @@ class SavedAnnotationsTest < ApplicationSystemTestCase sa = create :saved_annotation, user: @staff, exercise: @first.exercise, course: @course visit(submission_path(id: @first.id)) - click_link 'Code' + click_on 'Code' find('tr#line-1').hover find('.annotation-button a').click @@ -100,7 +100,7 @@ class SavedAnnotationsTest < ApplicationSystemTestCase assert find_field('annotation-text', with: sa.annotation_text) assert_equal sa.annotation_text, find('textarea.annotation-submission-input').value - click_button 'Comment' + click_on 'Comment' end within '.annotation' do diff --git a/test/system/search_test.rb b/test/system/search_test.rb index 6060b9a2dc..f374e62cf4 100644 --- a/test/system/search_test.rb +++ b/test/system/search_test.rb @@ -56,8 +56,8 @@ def assert_path_with_query(path, **query_params) test 'Going to a page with search does not create an extra history entry' do sign_in create(:zeus) visit root_path - click_button 'Toggle drawer' - click_link 'Exercises' + click_on 'Toggle drawer' + click_on 'Exercises' page.assert_current_path activities_path page.go_back