2025-04-10 08:16:31 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PageObjects
|
|
|
|
module Pages
|
|
|
|
class AdminAiFeatures < PageObjects::Pages::Base
|
2025-06-09 16:13:09 -03:00
|
|
|
FEATURES_PAGE = ".ai-features"
|
2025-04-10 08:16:31 -07:00
|
|
|
|
|
|
|
def visit
|
|
|
|
page.visit("/admin/plugins/discourse-ai/ai-features")
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2025-06-09 16:13:09 -03:00
|
|
|
def toggle_configured
|
|
|
|
page.find("#{FEATURES_PAGE} .ai-feature-groups .configured").click
|
2025-04-10 08:16:31 -07:00
|
|
|
end
|
|
|
|
|
2025-06-09 16:13:09 -03:00
|
|
|
def toggle_unconfigured
|
|
|
|
page.find("#{FEATURES_PAGE} .ai-feature-groups .unconfigured").click
|
2025-04-10 08:16:31 -07:00
|
|
|
end
|
|
|
|
|
2025-06-09 16:13:09 -03:00
|
|
|
def has_listed_modules?(count)
|
|
|
|
page.has_css?("#{FEATURES_PAGE} .ai-module", count: count)
|
2025-04-10 08:16:31 -07:00
|
|
|
end
|
|
|
|
|
2025-06-09 16:13:09 -03:00
|
|
|
def has_feature_persona?(feature_name, name)
|
2025-04-10 08:16:31 -07:00
|
|
|
page.has_css?(
|
2025-06-09 16:13:09 -03:00
|
|
|
"#{FEATURES_PAGE} .ai-feature-card[data-feature-name='#{feature_name}'] .ai-feature-card__persona-button .d-button-label",
|
2025-04-10 08:16:31 -07:00
|
|
|
text: name,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2025-06-09 16:13:09 -03:00
|
|
|
def has_feature_groups?(feature_name, groups)
|
|
|
|
listed_groups =
|
|
|
|
page.find(
|
|
|
|
"#{FEATURES_PAGE} .ai-feature-card[data-feature-name='#{feature_name}'] .ai-feature-card__item-groups",
|
|
|
|
)
|
2025-04-10 08:16:31 -07:00
|
|
|
list_items = listed_groups.all("li", visible: true).map(&:text)
|
|
|
|
|
|
|
|
list_items.sort == groups.sort
|
|
|
|
end
|
|
|
|
|
2025-06-09 16:13:09 -03:00
|
|
|
def click_edit_module(module_name)
|
|
|
|
page.find("#{FEATURES_PAGE} .ai-module[data-module-name='#{module_name}'] .edit").click
|
2025-04-10 08:16:31 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|