From f4acb43ee761821d539dc898770c68e84ddd0042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 30 Apr 2024 19:03:27 +0200 Subject: [PATCH] DEV: add watched words system spec --- spec/system/admin_watched_words_spec.rb | 20 +++++++++++++++ .../page_objects/pages/admin_watched_words.rb | 25 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 spec/system/admin_watched_words_spec.rb create mode 100644 spec/system/page_objects/pages/admin_watched_words.rb diff --git a/spec/system/admin_watched_words_spec.rb b/spec/system/admin_watched_words_spec.rb new file mode 100644 index 00000000000..627f9cce928 --- /dev/null +++ b/spec/system/admin_watched_words_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +describe "Admin Watched Words", type: :system, js: true do + fab!(:current_user) { Fabricate(:admin) } + + before { sign_in(current_user) } + + let(:ww_page) { PageObjects::Pages::AdminWatchedWords.new } + + it "correctly saves watched words" do + ww_page.visit + ww_page.add_word "foo" + + expect(ww_page).to have_word + + ww_page.visit + + expect(ww_page).to have_word + end +end diff --git a/spec/system/page_objects/pages/admin_watched_words.rb b/spec/system/page_objects/pages/admin_watched_words.rb new file mode 100644 index 00000000000..43ca568f498 --- /dev/null +++ b/spec/system/page_objects/pages/admin_watched_words.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module PageObjects + module Pages + class AdminWatchedWords < PageObjects::Pages::Base + def visit + page.visit "admin/customize/watched_words" + self + end + + def add_word(word) + ww = page.find("#watched-words") + ww.find("#watched-words-header").click + ww.find(".filter-input").send_keys(word) + ww.find(".select-kit-row").click + + page.find(".watched-words-detail .btn-primary").click + end + + def has_word? + has_css?(".watched-words-detail .show-words-checkbox") + end + end + end +end