mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-16 04:24:23 +00:00
Moves flatpickr spec into admin folder
This commit is contained in:
44
spec/system/admin/flatpickr_spec.rb
Normal file
44
spec/system/admin/flatpickr_spec.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "system_helper"
|
||||
|
||||
describe "Test Flatpickr" do
|
||||
include AuthenticationHelper
|
||||
include WebHelper
|
||||
|
||||
context "orders" do
|
||||
it "opens the datepicker and closes it using the 'CLOSE' button" do
|
||||
login_as_admin_and_visit 'admin/orders'
|
||||
open_datepicker('.datepicker')
|
||||
# Looks for the close button and click it
|
||||
within(".flatpickr-calendar.open") do
|
||||
expect(page).to have_selector '.shortcut-buttons-flatpickr-buttons'
|
||||
find("button", text: "CLOSE").click
|
||||
end
|
||||
# Should no more have opened flatpickr
|
||||
expect(page).not_to have_selector '.flatpickr-calendar.open'
|
||||
end
|
||||
|
||||
it "opens the datepicker and closes it by clicking outside" do
|
||||
login_as_admin_and_visit 'admin/orders'
|
||||
open_datepicker('.datepicker')
|
||||
find("#admin-menu").click
|
||||
# Should no more have opened flatpickr
|
||||
expect(page).not_to have_selector '.flatpickr-calendar.open'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def open_datepicker(field)
|
||||
# Opens a datepicker
|
||||
find(field).click
|
||||
# Should have opened flatpickr
|
||||
expect(page).to have_selector '.flatpickr-calendar.open'
|
||||
end
|
||||
|
||||
def check_fielddate(field, date)
|
||||
# Check the value is correct
|
||||
expect(find(field, match: :first).value).to eq date.to_datetime.strftime("%Y-%m-%d")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user