Skip to content

A platform for community discussion. Free, open, simple.

DEV: add watched words system spec

Régis Hanolf4acb43ee761
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