require "application_system_test_case"

class QuestionsTest < ApplicationSystemTestCase
  setup do
    @question = questions(:one)
  end

  test "visiting the index" do
    visit questions_url
    assert_selector "h1", text: "Questions"
  end

  test "creating a Question" do
    visit questions_url
    click_on "New Question"

    fill_in "Body", with: @question.body
    fill_in "Created by", with: @question.created_by
    check "Private" if @question.private
    check "Required" if @question.required
    fill_in "Resource type", with: @question.resource_type
    check "Retired" if @question.retired
    fill_in "Updated by", with: @question.updated_by
    click_on "Create Question"

    assert_text "Question was successfully created"
    click_on "Back"
  end

  test "updating a Question" do
    visit questions_url
    click_on "Edit", match: :first

    fill_in "Body", with: @question.body
    fill_in "Created by", with: @question.created_by
    check "Private" if @question.private
    check "Required" if @question.required
    fill_in "Resource type", with: @question.resource_type
    check "Retired" if @question.retired
    fill_in "Updated by", with: @question.updated_by
    click_on "Update Question"

    assert_text "Question was successfully updated"
    click_on "Back"
  end

  test "destroying a Question" do
    visit questions_url
    page.accept_confirm do
      click_on "Destroy", match: :first
    end

    assert_text "Question was successfully destroyed"
  end
end
