FEATURE: Add Filter for Webhook Events by Status (#27332)

* FEATURE: Add Filter for Webhook Events by Status

* Fixing multiple issues

* Lint

* Fixing multiple issues

* Change the range of the status for webhook events
This commit is contained in:
Guhyoun Nam
2024-06-07 10:26:00 -05:00
committed by GitHub
parent 970d7e9cd9
commit c13f64d35b
13 changed files with 207 additions and 19 deletions

View File

@ -0,0 +1,37 @@
# frozen_string_literal: true
describe "Admin WebHook Events", type: :system do
fab!(:web_hook)
fab!(:admin)
fab!(:web_hook_event1) { Fabricate(:web_hook_event, web_hook: web_hook, status: 200) }
fab!(:web_hook_event2) { Fabricate(:web_hook_event, web_hook: web_hook, status: 404) }
let(:admin_web_hooks_page) { PageObjects::Pages::AdminWebHookEvents.new }
before { sign_in(admin) }
it "shows all webhook events when filter is on 'All Events'" do
admin_web_hooks_page.visit(web_hook.id)
expect(admin_web_hooks_page).to have_web_hook_event(web_hook_event1.id)
expect(admin_web_hooks_page).to have_web_hook_event(web_hook_event2.id)
end
it "shows only successfully delivered webhook events when filter is on 'Delivered'" do
admin_web_hooks_page.visit(web_hook.id)
admin_web_hooks_page.click_filter_all
admin_web_hooks_page.click_filter_delivered
expect(admin_web_hooks_page).to have_web_hook_event(web_hook_event1.id)
expect(admin_web_hooks_page).to have_no_web_hook_event(web_hook_event2.id)
end
it "shows only webhook events that are failed to deliver when filter is on 'Failed'" do
admin_web_hooks_page.visit(web_hook.id)
admin_web_hooks_page.click_filter_all
admin_web_hooks_page.click_filter_failed
expect(admin_web_hooks_page).to have_no_web_hook_event(web_hook_event1.id)
expect(admin_web_hooks_page).to have_web_hook_event(web_hook_event2.id)
end
end

View File

@ -0,0 +1,32 @@
# frozen_string_literal: true
module PageObjects
module Pages
class AdminWebHookEvents < PageObjects::Pages::Base
def visit(id)
page.visit("/admin/api/web_hooks/#{id}")
self
end
def click_filter_all
find(".select-kit-header", text: "All Events").click
end
def click_filter_delivered
find(".select-kit-row", text: "Delivered").click
end
def click_filter_failed
find(".select-kit-row", text: "Failed").click
end
def has_web_hook_event?(id)
page.has_css?("li .event-id", text: id)
end
def has_no_web_hook_event?(id)
page.has_no_css?("li .event-id", text: id)
end
end
end
end