Skip to content

Commit

Permalink
chore(test): add test for mark answer then delete
Browse files Browse the repository at this point in the history
  • Loading branch information
bivanalhar authored and cysjonathan committed Aug 26, 2024
1 parent e016330 commit c0d46ba
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions spec/features/course/forum/post_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
with_tenant(:instance) do
let(:course) { create(:course) }
let(:forum) { create(:forum, course: course) }
let(:topic) { create(:forum_topic, forum: forum, course: course, topic_type: :question) }
let(:topic) { create(:forum_topic, forum: forum, course: course) }
let(:question_topic) { create(:forum_topic, forum: forum, course: course, topic_type: :question) }
before { login_as(user, scope: :user) }

context 'As a Course Manager' do
Expand Down Expand Up @@ -155,24 +156,35 @@
end

scenario 'I can mark/unmark post as answer' do
post = create(:course_discussion_post, topic: topic.acting_as)
visit course_forum_topic_path(course, forum, topic)
post = create(:course_discussion_post, topic: question_topic.acting_as)
visit course_forum_topic_path(course, forum, question_topic)
wait_for_page
# Mark as answer
within find("div.post_#{post.id}") do
click_button 'Mark as answer'
expect(page).to have_text('Unmark as answer')
end
expect(post.reload).to be_answer
expect(topic.reload).to be_resolved
expect(question_topic.reload).to be_resolved
wait_for_page
# Unmark as answer
within find("div.post_#{post.id}") do
click_button 'Unmark as answer'
expect(page).to have_text('Mark as answer')
end
expect(post.reload).not_to be_answer
expect(topic.reload).not_to be_resolved
expect(question_topic.reload).not_to be_resolved

# Mark as answer and then delete the answer
within find("div.post_#{post.id}") do
click_button 'Mark as answer'
end

find("button.post-delete-#{post.id}").click
accept_prompt

wait_for_page
expect(question_topic.reload).not_to be_resolved
end

scenario 'When anonymous post is not allowed and there are anonymous posts, I can see the authors' do
Expand Down

0 comments on commit c0d46ba

Please sign in to comment.