require "application_system_test_case"

class OrdersTest < ApplicationSystemTestCase
  setup do
    @order = orders(:one)
  end

  test "visiting the index" do
    visit orders_url
    assert_selector "h1", text: "Orders"
  end

  test "creating a Order" do
    visit orders_url
    click_on "New Order"

    fill_in "Client", with: @order.client_id
    fill_in "Confirmed at", with: @order.confirmed_at
    fill_in "Created by", with: @order.created_by
    fill_in "Due date", with: @order.due_date
    fill_in "Finished at", with: @order.finished_at
    fill_in "Remark", with: @order.remark
    fill_in "Sn", with: @order.sn
    fill_in "Status", with: @order.status
    click_on "Create Order"

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

  test "updating a Order" do
    visit orders_url
    click_on "Edit", match: :first

    fill_in "Client", with: @order.client_id
    fill_in "Confirmed at", with: @order.confirmed_at
    fill_in "Created by", with: @order.created_by
    fill_in "Due date", with: @order.due_date
    fill_in "Finished at", with: @order.finished_at
    fill_in "Remark", with: @order.remark
    fill_in "Sn", with: @order.sn
    fill_in "Status", with: @order.status
    click_on "Update Order"

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

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

    assert_text "Order was successfully destroyed"
  end
end
