<commit_before># frozen_string_literal: true

#
# Copyright (C) 2019 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.

require_relative './page_objects/student_assignment_page_v2'
require_relative '../common'

describe 'as a student' do
  include_context "in-process server selenium tests"

  context 'on assignments 2 page' do
    before(:once) do
      Account.default.enable_feature!(:assignments_2_student)
      course_with_student(course: @course, active_all: true)
    end

    context 'assignment details' do
      before(:once) do
        @assignment = @course.assignments.create!(
          name: 'assignment',
          due_at: 5.days.ago,
          points_possible: 10,
          submission_types: 'online_upload'
        )
      end

      before(:each) do
        user_session(@student)
        StudentAssignmentPageV2.visit(@course, @assignment)
      end

      it 'should show submission workflow tracker' do
        expect(StudentAssignmentPageV2.submission_workflow_tracker).to be_displayed
      end

      it 'should show assignment title' do
        expect(StudentAssignmentPageV2.assignment_title(@assignment.title)).to_not be_nil
      end

      it 'available assignment should show details toggle' do
        expect(StudentAssignmentPageV2.details_toggle).to be_displayed
      end

      it 'should show assignment group link' do
        expect(StudentAssignmentPageV2.assignment_group_link).to be_displayed
      end

      it 'should show assignment due date' do
        expect(StudentAssignmentPageV2.due_date_css(@assignment.due_at)).to_not be_nil
      end

      it 'should show how many points possible the assignment is worth' do
        expect(StudentAssignmentPageV2.points_possible_css(@assignment.points_possible)).to_not be_nil
      end

      it 'available assignment should show content tablist' do
        expect(StudentAssignmentPageV2.content_tablist).to be_displayed
      end
    end

    context 'text assignments' do
      before(:once) do
        @assignment = @course.assignments.create!(
          name: 'text assignment',
          due_at: 5.days.ago,
          points_possible: 10,
          submission_types: 'online_text_entry'
        )
      end

      before(:each) do
        user_session(@student)
        StudentAssignmentPageV2.visit(@course, @assignment)
        wait_for_ajaximations
      end

      it 'should be able to be submitted', custom_timeout: 30 do
        StudentAssignmentPageV2.create_text_entry_draft("Hello")
        wait_for_ajaximations
        StudentAssignmentPageV2.submit_assignment
        wait_for_ajaximations
        expect(StudentAssignmentPageV2.text_display_area).to include_text("Hello")
      end

      it 'should be able to be saved as a draft' do
        StudentAssignmentPageV2.create_text_entry_draft("Hello")
        wait_for_ajaximations
        StudentAssignmentPageV2.edit_text_entry_button.click
        expect(StudentAssignmentPageV2.text_draft_contents).to include("Hello")
      end
    end<commit_msg>spec: skip flakey specs for now<commit_after># frozen_string_literal: true

#
# Copyright (C) 2019 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.

require_relative './page_objects/student_assignment_page_v2'
require_relative '../common'

describe 'as a student' do
  include_context "in-process server selenium tests"

  context 'on assignments 2 page' do
    before(:once) do
      Account.default.enable_feature!(:assignments_2_student)
      course_with_student(course: @course, active_all: true)
    end

    context 'assignment details' do
      before(:once) do
        @assignment = @course.assignments.create!(
          name: 'assignment',
          due_at: 5.days.ago,
          points_possible: 10,
          submission_types: 'online_upload'
        )
      end

      before(:each) do
        user_session(@student)
        StudentAssignmentPageV2.visit(@course, @assignment)
      end

      it 'should show submission workflow tracker' do
        expect(StudentAssignmentPageV2.submission_workflow_tracker).to be_displayed
      end

      it 'should show assignment title' do
        expect(StudentAssignmentPageV2.assignment_title(@assignment.title)).to_not be_nil
      end

      it 'available assignment should show details toggle' do
        expect(StudentAssignmentPageV2.details_toggle).to be_displayed
      end

      it 'should show assignment group link' do
        expect(StudentAssignmentPageV2.assignment_group_link).to be_displayed
      end

      it 'should show assignment due date' do
        expect(StudentAssignmentPageV2.due_date_css(@assignment.due_at)).to_not be_nil
      end

      it 'should show how many points possible the assignment is worth' do
        expect(StudentAssignmentPageV2.points_possible_css(@assignment.points_possible)).to_not be_nil
      end

      it 'available assignment should show content tablist' do
        expect(StudentAssignmentPageV2.content_tablist).to be_displayed
      end
    end

    context 'text assignments' do
      before(:once) do
        @assignment = @course.assignments.create!(
          name: '<NAME>',
          due_at: 5.days.ago,
          points_possible: 10,
          submission_types: 'online_text_entry'
        )
      end

      before(:each) do
        user_session(@student)
        StudentAssignmentPageV2.visit(@course, @assignment)
        wait_for_ajaximations
      end

      it 'should be able to be submitted', custom_timeout: 30 do
        skip("Skip for now and fix with LS-2164")
        StudentAssignmentPageV2.create_text_entry_draft("Hello")
        wait_for_ajaximations
        StudentAssignmentPageV2.submit_assignment
        wait_for_ajaximations
        expect(StudentAssignmentPageV2.text_display_area).to include_text("Hello")
      end

      it 'should be able to be saved as a draft' do
        skip("Skip for now and fix with LS-2164")
        StudentAssignmentPageV2.create_text_entry_draft("Hello")
        wait_for_ajaximations
        StudentAssignmentPageV2.edit_text_entry_button.click
        expect(StudentAssignmentPageV2.text_draft_contents).to include("Hello")
      end
    end
{'fraction_non_alphanumeric': 0.06819109840751326, 'fraction_numerical': 0.009527698380291275, 'mean_word_length': 3.1443880428652, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2977433', 'n_tokens_mistral': 2063, 'n_tokens_neox': 2026, 'n_words': 607}