require "application_system_test_case"

class Admin::SitesTest < ApplicationSystemTestCase
  setup do
    @site = sites(:one)
  end

  test "visiting the index" do
    visit admin_sites_path
    assert_selector "h1", text: "Sites"
  end

  test "should create site" do
    visit admin_sites_path
    click_on "New site"

    check "Actived" if @site.actived
    fill_in "Name", with: @site.name
    fill_in "Notice", with: @site.notice
    fill_in "Preferences", with: @site.preferences
    check "Selected" if @site.selected
    click_on "Create Site"

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

  test "should update Site" do
    visit admin_site_path(@site)
    click_on "Edit this site", match: :first

    check "Actived" if @site.actived
    fill_in "Name", with: @site.name
    fill_in "Notice", with: @site.notice
    fill_in "Preferences", with: @site.preferences
    check "Selected" if @site.selected
    click_on "Update Site"

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

  test "should destroy Site" do
    visit admin_site_path(@site)
    click_on "Destroy this site", match: :first

    assert_text "Site was successfully destroyed"
  end
end
