decidim-chatbot 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.erb_lint.yml +2134 -0
- data/.github/workflows/website.yml +57 -0
- data/.gitignore +13 -0
- data/.gitlab-ci.yml +204 -0
- data/.node-version +1 -0
- data/.nvmrc +1 -0
- data/.rspec +2 -0
- data/.rubocop.yml +17 -0
- data/.ruby-version +1 -0
- data/.simplecov +36 -0
- data/CONTRIBUTING.md +54 -0
- data/Gemfile +50 -0
- data/Gemfile.lock +1013 -0
- data/LICENSE.md +661 -0
- data/README.md +62 -0
- data/Rakefile +54 -0
- data/app/commands/decidim/chatbot/admin/destroy_item.rb +25 -0
- data/app/commands/decidim/chatbot/admin/menu_items/update_exit.rb +12 -0
- data/app/commands/decidim/chatbot/admin/menu_items/update_login.rb +12 -0
- data/app/commands/decidim/chatbot/admin/menu_items/update_propose_proposals.rb +12 -0
- data/app/commands/decidim/chatbot/admin/menu_items/update_read_blogs.rb +12 -0
- data/app/commands/decidim/chatbot/admin/menu_items/update_read_proposals.rb +12 -0
- data/app/commands/decidim/chatbot/admin/menu_items/update_vote_on_proposal.rb +12 -0
- data/app/commands/decidim/chatbot/admin/notifications/update_manual.rb +12 -0
- data/app/commands/decidim/chatbot/admin/notifications/update_phase.rb +12 -0
- data/app/commands/decidim/chatbot/admin/persist_item.rb +47 -0
- data/app/commands/decidim/chatbot/admin/reorder_items.rb +51 -0
- data/app/commands/decidim/chatbot/admin/send_test_notification.rb +74 -0
- data/app/commands/decidim/chatbot/admin/unsubscribe_user.rb +35 -0
- data/app/commands/decidim/chatbot/admin/update_chatbot.rb +17 -0
- data/app/commands/decidim/chatbot/notifications/deliver.rb +30 -0
- data/app/commands/decidim/chatbot/notifications/enqueue_phase.rb +67 -0
- data/app/commands/decidim/chatbot/notifications/send.rb +115 -0
- data/app/commands/decidim/chatbot/whatsapp/create_from_phone.rb +95 -0
- data/app/commands/decidim/chatbot/whatsapp/sync_phone.rb +56 -0
- data/app/controllers/decidim/api/rest_full/chatbot/base_controller.rb +52 -0
- data/app/controllers/decidim/api/rest_full/chatbot/chatbot_menu_items_controller.rb +49 -0
- data/app/controllers/decidim/api/rest_full/chatbot/chatbot_users_controller.rb +46 -0
- data/app/controllers/decidim/api/rest_full/chatbot/chatbots_controller.rb +40 -0
- data/app/controllers/decidim/chatbot/admin/chatbot_edit.rb +85 -0
- data/app/controllers/decidim/chatbot/admin/chatbots/generals_controller.rb +43 -0
- data/app/controllers/decidim/chatbot/admin/chatbots/menu_items_controller.rb +32 -0
- data/app/controllers/decidim/chatbot/admin/chatbots/notifications_controller.rb +92 -0
- data/app/controllers/decidim/chatbot/admin/chatbots/users/filterable.rb +33 -0
- data/app/controllers/decidim/chatbot/admin/chatbots/users_controller.rb +53 -0
- data/app/controllers/decidim/chatbot/admin/chatbots/whatsapps_controller.rb +59 -0
- data/app/controllers/decidim/chatbot/admin/chatbots_controller.rb +20 -0
- data/app/controllers/decidim/chatbot/admin/items_crud.rb +183 -0
- data/app/forms/decidim/chatbot/admin/chatbot_form.rb +20 -0
- data/app/forms/decidim/chatbot/admin/config_form.rb +20 -0
- data/app/forms/decidim/chatbot/admin/menu_item_form.rb +80 -0
- data/app/forms/decidim/chatbot/admin/menu_items/component_id_form.rb +60 -0
- data/app/forms/decidim/chatbot/admin/menu_items/exit_form.rb +24 -0
- data/app/forms/decidim/chatbot/admin/menu_items/login_form.rb +35 -0
- data/app/forms/decidim/chatbot/admin/menu_items/propose_proposals_form.rb +23 -0
- data/app/forms/decidim/chatbot/admin/menu_items/propose_proposals_labels.rb +53 -0
- data/app/forms/decidim/chatbot/admin/menu_items/read_blogs_form.rb +23 -0
- data/app/forms/decidim/chatbot/admin/menu_items/read_content_labels.rb +51 -0
- data/app/forms/decidim/chatbot/admin/menu_items/read_proposals_form.rb +23 -0
- data/app/forms/decidim/chatbot/admin/menu_items/vote_on_proposal_form.rb +123 -0
- data/app/forms/decidim/chatbot/admin/notification_item_form.rb +111 -0
- data/app/forms/decidim/chatbot/admin/notifications/manual_form.rb +13 -0
- data/app/forms/decidim/chatbot/admin/notifications/phase_form.rb +79 -0
- data/app/forms/decidim/chatbot/admin/notifications/template_fields.rb +60 -0
- data/app/forms/decidim/chatbot/admin/notifications/test_form.rb +179 -0
- data/app/helpers/decidim/chatbot/admin/items_helper.rb +44 -0
- data/app/jobs/decidim/chatbot/chatbot_webhook_job.rb +59 -0
- data/app/jobs/decidim/chatbot/send_notification_job.rb +33 -0
- data/app/models/decidim/chatbot/chatbot.rb +47 -0
- data/app/models/decidim/chatbot/item.rb +99 -0
- data/app/packs/.keep +0 -0
- data/app/presenters/decidim/chatbot/admin_log/chatbot_presenter.rb +42 -0
- data/app/presenters/decidim/chatbot/admin_log/item_presenter.rb +32 -0
- data/app/queries/decidim/chatbot/admin/proposal_vote_mode.rb +41 -0
- data/app/queries/decidim/chatbot/whatsapp_users.rb +58 -0
- data/app/serializers/decidim/api/rest_full/chatbot/chatbot_menu_item_serializer.rb +113 -0
- data/app/serializers/decidim/api/rest_full/chatbot/chatbot_notification_serializer.rb +19 -0
- data/app/serializers/decidim/api/rest_full/chatbot/chatbot_serializer.rb +66 -0
- data/app/serializers/decidim/api/rest_full/chatbot/chatbot_user_identity_serializer.rb +23 -0
- data/app/serializers/decidim/api/rest_full/chatbot/chatbot_user_serializer.rb +28 -0
- data/app/serializers/decidim/api/rest_full/chatbot/chatbot_webhook_serializer.rb +21 -0
- data/app/services/decidim/chatbot/chatbot_webhook_handler.rb +40 -0
- data/app/services/decidim/chatbot/notifications/bindings.rb +87 -0
- data/app/services/decidim/chatbot/whatsapp/body_parameters.rb +29 -0
- data/app/services/decidim/chatbot/whatsapp/graph_client.rb +136 -0
- data/app/services/decidim/chatbot/whatsapp/status_mapper.rb +93 -0
- data/app/services/decidim/chatbot/whatsapp/template_manager_url.rb +35 -0
- data/app/views/decidim/chatbot/admin/chatbots/generals/_menu_preview.html.erb +49 -0
- data/app/views/decidim/chatbot/admin/chatbots/generals/edit.html.erb +79 -0
- data/app/views/decidim/chatbot/admin/chatbots/index.html.erb +50 -0
- data/app/views/decidim/chatbot/admin/chatbots/menu_items/_form.html.erb +2 -0
- data/app/views/decidim/chatbot/admin/chatbots/menu_items/edit.html.erb +2 -0
- data/app/views/decidim/chatbot/admin/chatbots/menu_items/index.html.erb +43 -0
- data/app/views/decidim/chatbot/admin/chatbots/menu_items/new.html.erb +12 -0
- data/app/views/decidim/chatbot/admin/chatbots/notifications/_form.html.erb +4 -0
- data/app/views/decidim/chatbot/admin/chatbots/notifications/_manual_fields.html.erb +8 -0
- data/app/views/decidim/chatbot/admin/chatbots/notifications/_phase_fields.html.erb +6 -0
- data/app/views/decidim/chatbot/admin/chatbots/notifications/edit.html.erb +3 -0
- data/app/views/decidim/chatbot/admin/chatbots/notifications/index.html.erb +40 -0
- data/app/views/decidim/chatbot/admin/chatbots/notifications/new.html.erb +11 -0
- data/app/views/decidim/chatbot/admin/chatbots/notifications/test.html.erb +35 -0
- data/app/views/decidim/chatbot/admin/chatbots/tabs/_whatsapp.html.erb +47 -0
- data/app/views/decidim/chatbot/admin/chatbots/users/_filters.html.erb +23 -0
- data/app/views/decidim/chatbot/admin/chatbots/users/index.html.erb +56 -0
- data/app/views/decidim/chatbot/admin/chatbots/whatsapps/show.html.erb +5 -0
- data/app/views/decidim/chatbot/admin/shared/_item_form.html.erb +64 -0
- data/app/views/decidim/chatbot/admin/shared/_row_actions.html.erb +28 -0
- data/app/views/decidim/chatbot/admin/shared/_tabs_menu.html.erb +13 -0
- data/app/views/decidim/chatbot/admin/shared/_type_fields.html.erb +2 -0
- data/app/views/decidim/chatbot/admin/shared/_type_picker.html.erb +15 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/_component_id.html.erb +9 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/_exit.html.erb +5 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/_login.html.erb +8 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/_manual.html.erb +16 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/_phase.html.erb +46 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/_propose_proposals.html.erb +10 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/_read_blogs.html.erb +16 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/_read_proposals.html.erb +16 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/_vote_on_proposal.html.erb +26 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/vote/_shows_abstention_label.html.erb +7 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/vote/_shows_vote_label.html.erb +7 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/vote/_shows_votes_closed_warning.html.erb +6 -0
- data/app/views/decidim/chatbot/admin/shared/type_fields/vote/_shows_weight_labels.html.erb +15 -0
- data/bin/check +13 -0
- data/bin/ci-setup +38 -0
- data/bin/gen-node-client +112 -0
- data/bin/gen-openapi +248 -0
- data/bin/i18n-tasks +27 -0
- data/bin/postversion +17 -0
- data/config/i18n-tasks.yml +38 -0
- data/config/locales/decidim_chatbot.en.yml +323 -0
- data/config/locales/decidim_chatbot.fr.yml +29 -0
- data/contrib/decidim-node-client/.gitignore +4 -0
- data/contrib/decidim-node-client/.npmignore +1 -0
- data/contrib/decidim-node-client/.openapi-generator/FILES +8 -0
- data/contrib/decidim-node-client/.openapi-generator/VERSION +1 -0
- data/contrib/decidim-node-client/.openapi-generator-ignore +13 -0
- data/contrib/decidim-node-client/.yarnrc.yml +5 -0
- data/contrib/decidim-node-client/README.md +37 -0
- data/contrib/decidim-node-client/api.ts +14193 -0
- data/contrib/decidim-node-client/base.ts +70 -0
- data/contrib/decidim-node-client/common.ts +185 -0
- data/contrib/decidim-node-client/configuration.ts +138 -0
- data/contrib/decidim-node-client/git_push.sh +57 -0
- data/contrib/decidim-node-client/index.ts +16 -0
- data/contrib/decidim-node-client/package.json +49 -0
- data/contrib/decidim-node-client/packup.config.ts +7 -0
- data/contrib/decidim-node-client/tsconfig.json +25 -0
- data/contrib/decidim-node-client/yarn.lock +2367 -0
- data/crowdin.yml +15 -0
- data/db/migrate/20260725120000_create_decidim_chatbot_chatbots.rb +20 -0
- data/db/migrate/20260822120000_create_decidim_chatbot_items.rb +20 -0
- data/db/migrate/20260824120000_add_menu_and_error_copy_to_decidim_chatbot_chatbots.rb +13 -0
- data/db/migrate/20260824140000_add_enabled_to_decidim_chatbot_items.rb +7 -0
- data/decidim-chatbot.gemspec +40 -0
- data/docker-compose.ci.yml +59 -0
- data/docker-compose.yml +47 -0
- data/lib/decidim/chatbot/admin_engine.rb +67 -0
- data/lib/decidim/chatbot/admin_menu.rb +41 -0
- data/lib/decidim/chatbot/default_manifests.rb +91 -0
- data/lib/decidim/chatbot/engine.rb +107 -0
- data/lib/decidim/chatbot/manifest.rb +31 -0
- data/lib/decidim/chatbot/menu_item_label_keys.rb +26 -0
- data/lib/decidim/chatbot/registry.rb +42 -0
- data/lib/decidim/chatbot/rest_full_ability.rb +24 -0
- data/lib/decidim/chatbot/settings_tab.rb +18 -0
- data/lib/decidim/chatbot/test_definitions.rb +352 -0
- data/lib/decidim/chatbot/variable_interpolator.rb +30 -0
- data/lib/decidim/chatbot/version.rb +21 -0
- data/lib/decidim/chatbot/webhook_publisher.rb +29 -0
- data/lib/decidim/chatbot.rb +41 -0
- data/lib/decidim-chatbot.rb +3 -0
- data/lib/tasks/chatbot.rake +64 -0
- data/openapi/openapi.json +37801 -0
- data/openapitools.json +7 -0
- data/package.json +22 -0
- data/prettier.config.js +15 -0
- data/spec/commands/decidim/chatbot/admin/destroy_item_spec.rb +24 -0
- data/spec/commands/decidim/chatbot/admin/persist_item_spec.rb +80 -0
- data/spec/commands/decidim/chatbot/admin/reorder_items_spec.rb +53 -0
- data/spec/commands/decidim/chatbot/admin/send_test_notification_spec.rb +105 -0
- data/spec/commands/decidim/chatbot/admin/unsubscribe_user_spec.rb +46 -0
- data/spec/commands/decidim/chatbot/admin/update_chatbot_spec.rb +56 -0
- data/spec/commands/decidim/chatbot/notifications/enqueue_phase_spec.rb +59 -0
- data/spec/commands/decidim/chatbot/notifications/send_spec.rb +101 -0
- data/spec/commands/decidim/chatbot/whatsapp/create_from_phone_spec.rb +122 -0
- data/spec/commands/decidim/chatbot/whatsapp/sync_phone_spec.rb +110 -0
- data/spec/controllers/decidim/chatbot/admin/chatbots_controller_spec.rb +25 -0
- data/spec/factories/chatbot.rb +44 -0
- data/spec/forms/decidim/chatbot/admin/chatbot_form_spec.rb +41 -0
- data/spec/forms/decidim/chatbot/admin/config_form_spec.rb +30 -0
- data/spec/forms/decidim/chatbot/admin/menu_item_form_spec.rb +49 -0
- data/spec/forms/decidim/chatbot/admin/menu_items/component_id_form_spec.rb +54 -0
- data/spec/forms/decidim/chatbot/admin/menu_items/component_id_forms_spec.rb +512 -0
- data/spec/forms/decidim/chatbot/admin/menu_items/exit_form_spec.rb +39 -0
- data/spec/forms/decidim/chatbot/admin/menu_items/login_form_spec.rb +101 -0
- data/spec/forms/decidim/chatbot/admin/menu_items/propose_proposals_form_prefill_spec.rb +26 -0
- data/spec/forms/decidim/chatbot/admin/menu_items/read_blogs_form_prefill_spec.rb +22 -0
- data/spec/forms/decidim/chatbot/admin/notifications/manual_form_spec.rb +130 -0
- data/spec/forms/decidim/chatbot/admin/notifications/phase_form_spec.rb +79 -0
- data/spec/forms/decidim/chatbot/admin/notifications/test_form_spec.rb +172 -0
- data/spec/jobs/decidim/chatbot/chatbot_webhook_job_spec.rb +47 -0
- data/spec/jobs/decidim/chatbot/send_notification_job_spec.rb +53 -0
- data/spec/lib/decidim/chatbot/engine_spec.rb +44 -0
- data/spec/lib/decidim/chatbot/registry_spec.rb +30 -0
- data/spec/lib/decidim/chatbot/settings_tab_spec.rb +21 -0
- data/spec/lib/decidim/chatbot/variable_interpolator_spec.rb +34 -0
- data/spec/lib/decidim/chatbot/whatsapp/status_mapper_spec.rb +64 -0
- data/spec/lib/decidim/chatbot_spec.rb +59 -0
- data/spec/models/decidim/chatbot/chatbot_spec.rb +23 -0
- data/spec/models/decidim/chatbot/item_spec.rb +88 -0
- data/spec/presenters/decidim/chatbot/admin_log/chatbot_presenter_spec.rb +64 -0
- data/spec/queries/decidim/chatbot/admin/proposal_vote_mode_spec.rb +74 -0
- data/spec/queries/decidim/chatbot/whatsapp_users_spec.rb +57 -0
- data/spec/requests/decidim/api/rest_full/chatbot/chatbot_menu_items_controller_spec.rb +344 -0
- data/spec/requests/decidim/api/rest_full/chatbot/chatbot_users_controller_spec.rb +140 -0
- data/spec/requests/decidim/api/rest_full/chatbot/chatbots_controller_spec.rb +195 -0
- data/spec/requests/decidim/chatbot/admin/chatbots/notifications_controller_spec.rb +44 -0
- data/spec/requests/decidim/chatbot/admin/tenant_isolation_spec.rb +133 -0
- data/spec/requests/decidim/chatbot/admin/unsubscribe_user_spec.rb +28 -0
- data/spec/serializers/decidim/api/rest_full/chatbot/chatbot_menu_item_serializer_spec.rb +321 -0
- data/spec/serializers/decidim/api/rest_full/chatbot/chatbot_serializer_spec.rb +49 -0
- data/spec/serializers/decidim/api/rest_full/chatbot/chatbot_user_serializer_spec.rb +40 -0
- data/spec/services/decidim/chatbot/chatbot_webhook_handler_spec.rb +43 -0
- data/spec/services/decidim/chatbot/notifications/bindings_spec.rb +86 -0
- data/spec/services/decidim/chatbot/whatsapp/body_parameters_spec.rb +22 -0
- data/spec/services/decidim/chatbot/whatsapp/graph_client_spec.rb +205 -0
- data/spec/services/decidim/chatbot/whatsapp/template_manager_url_spec.rb +33 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/support/allow_all_hosts.rb +9 -0
- data/spec/support/chatbot_admin.rb +16 -0
- data/spec/support/decidim_factories.rb +7 -0
- data/spec/support/decidim_system_factories.rb +3 -0
- data/spec/support/devise.rb +5 -0
- data/spec/support/rack_test_system_driver.rb +43 -0
- data/spec/support/whatsapp_graph.rb +15 -0
- data/spec/swagger_helper.rb +47 -0
- data/spec/system/decidim/chatbot/admin/admin_can_send_manual_when_ready_spec.rb +35 -0
- data/spec/system/decidim/chatbot/admin/admin_configures_vote_on_proposal_menu_item_spec.rb +84 -0
- data/spec/system/decidim/chatbot/admin/admin_confirms_send_now_recipient_count_spec.rb +40 -0
- data/spec/system/decidim/chatbot/admin/admin_creates_menu_item_with_demo_field_spec.rb +65 -0
- data/spec/system/decidim/chatbot/admin/admin_creates_phase_and_manual_notifications_spec.rb +52 -0
- data/spec/system/decidim/chatbot/admin/admin_does_not_see_other_org_processes_in_phase_select_spec.rb +27 -0
- data/spec/system/decidim/chatbot/admin/admin_does_not_see_other_organization_chatbots_spec.rb +25 -0
- data/spec/system/decidim/chatbot/admin/admin_is_redirected_when_chatbot_is_disabled_spec.rb +28 -0
- data/spec/system/decidim/chatbot/admin/admin_lists_organization_chatbots_spec.rb +36 -0
- data/spec/system/decidim/chatbot/admin/admin_manual_notification_sends_with_nickname_spec.rb +68 -0
- data/spec/system/decidim/chatbot/admin/admin_navigates_chatbot_main_tabs_spec.rb +52 -0
- data/spec/system/decidim/chatbot/admin/admin_phase_notification_sends_on_step_change_spec.rb +79 -0
- data/spec/system/decidim/chatbot/admin/admin_picks_published_blog_component_spec.rb +205 -0
- data/spec/system/decidim/chatbot/admin/admin_picks_published_participatory_space_spec.rb +45 -0
- data/spec/system/decidim/chatbot/admin/admin_reorders_chatbot_menu_items_spec.rb +29 -0
- data/spec/system/decidim/chatbot/admin/admin_sees_disabled_menu_item_faded_on_the_table_spec.rb +23 -0
- data/spec/system/decidim/chatbot/admin/admin_sees_disabled_notification_item_faded_on_the_table_spec.rb +40 -0
- data/spec/system/decidim/chatbot/admin/admin_sees_notification_facts_and_frozen_template_name_spec.rb +71 -0
- data/spec/system/decidim/chatbot/admin/admin_sees_propose_proposals_defaults_prefilled_spec.rb +119 -0
- data/spec/system/decidim/chatbot/admin/admin_sees_type_specific_fields_spec.rb +89 -0
- data/spec/system/decidim/chatbot/admin/admin_sees_whatsapp_facts_and_can_sync_spec.rb +48 -0
- data/spec/system/decidim/chatbot/admin/admin_sees_whatsapp_template_edit_link_spec.rb +37 -0
- data/spec/system/decidim/chatbot/admin/admin_tests_notification_spec.rb +125 -0
- data/spec/system/decidim/chatbot/admin/admin_unchecks_enabled_on_a_menu_item_spec.rb +30 -0
- data/spec/system/decidim/chatbot/admin/admin_unsubscribes_whatsapp_user_from_chatbot_spec.rb +35 -0
- data/spec/system/decidim/chatbot/admin/admin_updates_welcome_message_from_general_tab_spec.rb +84 -0
- data/spec/system/decidim/chatbot/system/admin_updates_organization_chatbot_settings_spec.rb +33 -0
- data/spec/tasks/chatbot_create_spec.rb +99 -0
- data/spec/tasks/chatbot_sync_spec.rb +90 -0
- data/website/.node-version +1 -0
- data/website/.nvmrc +1 -0
- data/website/docs/developer/_category_.json +4 -0
- data/website/docs/developer/contribute.md +87 -0
- data/website/docs/index.md +42 -0
- data/website/docs/integrate/_category_.json +4 -0
- data/website/docs/integrate/index.md +214 -0
- data/website/docusaurus.config.ts +93 -0
- data/website/package.json +37 -0
- data/website/sidebars.ts +7 -0
- data/website/src/css/custom.css +37 -0
- data/website/static/api-docs.html +2218 -0
- data/website/static/img/logo.svg +1 -0
- data/website/static/openapi.json +37801 -0
- data/website/tsconfig.json +6 -0
- data/website/yarn.lock +9782 -0
- data/yarn.lock +1003 -0
- metadata +424 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin creates phase and manual notifications", driver: :rack_test do
|
|
6
|
+
let(:organization) { create(:organization, available_locales: %w(en fr es)) }
|
|
7
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
8
|
+
let!(:chatbot) { create(:chatbot, organization:) }
|
|
9
|
+
let!(:process) { create(:participatory_process, :published, organization:, title: { "en" => "Town process" }) }
|
|
10
|
+
|
|
11
|
+
before do
|
|
12
|
+
enable_chatbot!(organization)
|
|
13
|
+
switch_to_host(organization.host)
|
|
14
|
+
login_as user, scope: :user
|
|
15
|
+
visit decidim_admin_chatbot.chatbot_notifications_path(chatbot)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "adds a phase row and a manual row" do
|
|
19
|
+
click_on "Add"
|
|
20
|
+
click_on "Phase"
|
|
21
|
+
fill_in "item_template_id_en", with: "1649483436030169"
|
|
22
|
+
expect(page).to have_no_field("item_variables_json_en")
|
|
23
|
+
check "item_use_space_name"
|
|
24
|
+
select "Town process", from: "item_participatory_space_gid"
|
|
25
|
+
within(".item__edit-sticky") { click_on "Save" }
|
|
26
|
+
|
|
27
|
+
phase = chatbot.items.for_scope(:notification).find_by(manifest_name: "phase")
|
|
28
|
+
expect(page).to have_current_path(
|
|
29
|
+
decidim_admin_chatbot.edit_chatbot_notification_path(chatbot, phase),
|
|
30
|
+
ignore_query: true
|
|
31
|
+
)
|
|
32
|
+
expect(page).to have_field("item_template_id_en", with: "1649483436030169")
|
|
33
|
+
|
|
34
|
+
visit decidim_admin_chatbot.chatbot_notifications_path(chatbot)
|
|
35
|
+
click_on "Add"
|
|
36
|
+
click_on "Manual"
|
|
37
|
+
expect(page).to have_content("Meta WhatsApp template ID")
|
|
38
|
+
fill_in "item_template_id_en", with: "1649483436030166"
|
|
39
|
+
fill_in "item_variables_json_en", with: '{"city":"Nairobi"}'
|
|
40
|
+
within(".item__edit-sticky") { click_on "Save" }
|
|
41
|
+
|
|
42
|
+
manual = chatbot.items.for_scope(:notification).find_by(manifest_name: "manual")
|
|
43
|
+
expect(page).to have_current_path(
|
|
44
|
+
decidim_admin_chatbot.edit_chatbot_notification_path(chatbot, manual),
|
|
45
|
+
ignore_query: true
|
|
46
|
+
)
|
|
47
|
+
expect(page).to have_field("item_template_id_en", with: "1649483436030166")
|
|
48
|
+
expect(phase.reload.settings["participatory_space_gid"]).to eq(process.to_gid.to_s)
|
|
49
|
+
expect(phase.settings["template_id"]["en"]).to eq("1649483436030169")
|
|
50
|
+
expect(manual.settings["template_id"]["en"]).to eq("1649483436030166")
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin does not see other-org processes in the phase select", driver: :rack_test do
|
|
6
|
+
let(:organization) { create(:organization, available_locales: %w(en fr es)) }
|
|
7
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
8
|
+
let!(:chatbot) { create(:chatbot, organization:) }
|
|
9
|
+
let!(:own_process) { create(:participatory_process, :published, organization:, title: { "en" => "Own process" }) }
|
|
10
|
+
let!(:foreign_process) do
|
|
11
|
+
create(:participatory_process, :published, organization: create(:organization), title: { "en" => "Foreign process" })
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
before do
|
|
15
|
+
enable_chatbot!(organization)
|
|
16
|
+
switch_to_host(organization.host)
|
|
17
|
+
login_as user, scope: :user
|
|
18
|
+
visit decidim_admin_chatbot.chatbot_notifications_path(chatbot)
|
|
19
|
+
click_on "Add"
|
|
20
|
+
click_on "Phase"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "lists only this organization processes" do
|
|
24
|
+
expect(page).to have_select("item_participatory_space_gid", with_options: ["Own process"])
|
|
25
|
+
expect(page).to have_no_select("item_participatory_space_gid", with_options: ["Foreign process"])
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin does not see other organization chatbots", driver: :rack_test do
|
|
6
|
+
let(:organization) { create(:organization) }
|
|
7
|
+
let(:other) { create(:organization) }
|
|
8
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
9
|
+
let!(:chatbot) { create(:chatbot, organization:, name: { "en" => "Mine" }) }
|
|
10
|
+
let!(:foreign) { create(:chatbot, organization: other, name: { "en" => "Secret bot" }) }
|
|
11
|
+
|
|
12
|
+
before do
|
|
13
|
+
enable_chatbot!(organization)
|
|
14
|
+
enable_chatbot!(other)
|
|
15
|
+
switch_to_host(organization.host)
|
|
16
|
+
login_as user, scope: :user
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "does not list the other organization chatbot" do
|
|
20
|
+
visit decidim_admin_chatbot.root_path
|
|
21
|
+
|
|
22
|
+
expect(page).to have_content("Mine")
|
|
23
|
+
expect(page).to have_no_content("Secret bot")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin is redirected when chatbot is disabled", driver: :rack_test do
|
|
6
|
+
let(:organization) { create(:organization, available_locales: %w(en fr es)) }
|
|
7
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
Decidim::Toggle.save_config!(organization, Decidim::Chatbot::MODULE_NAME, { "enabled" => false })
|
|
11
|
+
switch_to_host(organization.host)
|
|
12
|
+
login_as user, scope: :user
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "redirects away from the chatbot admin and hides the settings menu item" do
|
|
16
|
+
visit decidim_admin_chatbot.root_path
|
|
17
|
+
|
|
18
|
+
expect(page).to have_current_path(decidim.root_path, ignore_query: true)
|
|
19
|
+
expect(page).to have_content("Chatbot is disabled")
|
|
20
|
+
|
|
21
|
+
visit decidim_admin.edit_organization_path
|
|
22
|
+
|
|
23
|
+
expect(page).to have_no_link(
|
|
24
|
+
I18n.t("decidim.chatbot.admin.menu.chatbot"),
|
|
25
|
+
href: decidim_admin_chatbot.root_path
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin lists organization chatbots", driver: :rack_test do
|
|
6
|
+
let(:organization) { create(:organization, available_locales: %w(en fr es)) }
|
|
7
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
8
|
+
let!(:chatbot) do
|
|
9
|
+
create(:chatbot, organization:, whatsapp_phone_number: "+15550009999",
|
|
10
|
+
whatsapp_display_name: "Visible Bot", name: { "en" => "Org bot" })
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
before do
|
|
14
|
+
enable_chatbot!(organization)
|
|
15
|
+
switch_to_host(organization.host)
|
|
16
|
+
login_as user, scope: :user
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "lists organization chatbots without create controls" do
|
|
20
|
+
visit decidim_admin_chatbot.root_path
|
|
21
|
+
|
|
22
|
+
expect(page).to have_content("Chatbot")
|
|
23
|
+
expect(page).to have_content("+15550009999")
|
|
24
|
+
expect(page).to have_content("Visible Bot")
|
|
25
|
+
expect(page).to have_content("Org bot")
|
|
26
|
+
expect(page).to have_no_button("Add")
|
|
27
|
+
expect(page).to have_css("a", text: "Edit")
|
|
28
|
+
|
|
29
|
+
visit decidim_admin.edit_organization_path
|
|
30
|
+
|
|
31
|
+
expect(page).to have_link(
|
|
32
|
+
I18n.t("decidim.chatbot.admin.menu.chatbot"),
|
|
33
|
+
href: decidim_admin_chatbot.root_path
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Manual notification sends personalized nicknames", driver: :rack_test do
|
|
6
|
+
include ActiveJob::TestHelper
|
|
7
|
+
|
|
8
|
+
let(:organization) { create(:organization, available_locales: %w(en)) }
|
|
9
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
10
|
+
let!(:chatbot) { create(:chatbot, organization:, whatsapp_phone_id: "phone-1") }
|
|
11
|
+
let!(:item) do
|
|
12
|
+
create(
|
|
13
|
+
:chatbot_item,
|
|
14
|
+
chatbot:,
|
|
15
|
+
scope: "notification",
|
|
16
|
+
manifest_name: "manual",
|
|
17
|
+
settings: {
|
|
18
|
+
"template_id" => { "en" => "1649483436030170" },
|
|
19
|
+
"variables" => { "en" => { "name" => "%{nickname}" } }
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
let!(:ada) do
|
|
24
|
+
create(
|
|
25
|
+
:user,
|
|
26
|
+
organization:,
|
|
27
|
+
nickname: "blue-panda",
|
|
28
|
+
extended_data: { "whatsapp_phone_number" => "+15550001" }
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
let!(:bob) do
|
|
32
|
+
create(
|
|
33
|
+
:user,
|
|
34
|
+
organization:,
|
|
35
|
+
nickname: "red-fox",
|
|
36
|
+
extended_data: { "whatsapp_phone_number" => "+15550002" }
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
let(:graph) { instance_double(Decidim::Chatbot::Whatsapp::GraphClient, send_template: { "messages" => [] }) }
|
|
40
|
+
|
|
41
|
+
before do
|
|
42
|
+
enable_chatbot!(organization)
|
|
43
|
+
allow(Decidim::Chatbot::Whatsapp::GraphClient).to receive(:new).and_return(graph)
|
|
44
|
+
switch_to_host(organization.host)
|
|
45
|
+
login_as user, scope: :user
|
|
46
|
+
visit decidim_admin_chatbot.edit_chatbot_notification_path(chatbot, item)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "sends the welcome template with each subscriber nickname" do
|
|
50
|
+
perform_enqueued_jobs do
|
|
51
|
+
accept_confirm { click_on "Send now" }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
expect(page).to have_admin_callout("Notification queued to send.")
|
|
55
|
+
expect(graph).to have_received(:send_template).with(
|
|
56
|
+
"phone-1",
|
|
57
|
+
to: "15550001",
|
|
58
|
+
template_id: "1649483436030170",
|
|
59
|
+
parameters: [{ type: "text", parameter_name: "name", text: "blue-panda" }]
|
|
60
|
+
)
|
|
61
|
+
expect(graph).to have_received(:send_template).with(
|
|
62
|
+
"phone-1",
|
|
63
|
+
to: "15550002",
|
|
64
|
+
template_id: "1649483436030170",
|
|
65
|
+
parameters: [{ type: "text", parameter_name: "name", text: "red-fox" }]
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin navigates chatbot main tabs", driver: :rack_test do
|
|
6
|
+
let(:organization) { create(:organization, available_locales: %w(en fr es)) }
|
|
7
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
8
|
+
let!(:chatbot) { create(:chatbot, organization:, name: { "en" => "Org bot" }) }
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
enable_chatbot!(organization)
|
|
12
|
+
switch_to_host(organization.host)
|
|
13
|
+
login_as user, scope: :user
|
|
14
|
+
visit decidim_admin_chatbot.edit_chatbot_general_path(chatbot)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "renders duplicated main tabs and opens WhatsApp on its own URL" do
|
|
18
|
+
expect(page).to have_css(".main-tabs-menu")
|
|
19
|
+
expect(page).to have_css(".main-tabs-menu__tabs")
|
|
20
|
+
expect(page).to have_css(".main-tabs-menu__buttons")
|
|
21
|
+
expect(page).to have_link("General")
|
|
22
|
+
expect(page).to have_link("WhatsApp")
|
|
23
|
+
expect(page).to have_link("Menu")
|
|
24
|
+
expect(page).to have_link("Notification")
|
|
25
|
+
expect(page).to have_link("Users")
|
|
26
|
+
expect(page).to have_no_css("#trigger-whatsapp")
|
|
27
|
+
expect(page).to have_no_css("#panel-whatsapp")
|
|
28
|
+
expect(page).to have_no_css(".item_show__header")
|
|
29
|
+
expect(page).to have_no_link("Back to list")
|
|
30
|
+
expect(page).to have_css(".process-title-content-breadcrumb-container-left", text: "Chatbot")
|
|
31
|
+
expect(page).to have_css(".process-title-content-breadcrumb-container-left", text: "Demo Bot")
|
|
32
|
+
expect(page).to have_css("[data-announcement]",
|
|
33
|
+
text: "You can configure general settings of your chatbot here.")
|
|
34
|
+
|
|
35
|
+
click_on "WhatsApp"
|
|
36
|
+
|
|
37
|
+
expect(page).to have_current_path(decidim_admin_chatbot.chatbot_whatsapp_path(chatbot), ignore_query: true)
|
|
38
|
+
expect(page).to have_css(".main-tabs-menu")
|
|
39
|
+
expect(page).to have_css("[data-announcement]",
|
|
40
|
+
text: "Synced from your WhatsApp Business Profile. Use Sync to refresh them.")
|
|
41
|
+
expect(page).to have_content(chatbot.whatsapp_phone_id)
|
|
42
|
+
|
|
43
|
+
within(".main-tabs-menu") { click_on "Menu" }
|
|
44
|
+
expect(page).to have_css("[data-announcement]", text: "grouped by 3 menu items")
|
|
45
|
+
|
|
46
|
+
within(".main-tabs-menu") { click_on "Notification" }
|
|
47
|
+
expect(page).to have_css("[data-announcement]", text: "Only subscribed users will receive notifications")
|
|
48
|
+
|
|
49
|
+
within(".main-tabs-menu") { click_on "Users" }
|
|
50
|
+
expect(page).to have_css("[data-announcement]", text: "You can unsubscribe user")
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Phase notification sends when participatory process phase changes", driver: :rack_test do
|
|
6
|
+
include ActiveJob::TestHelper
|
|
7
|
+
|
|
8
|
+
let(:organization) { create(:organization, available_locales: %w(en)) }
|
|
9
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
10
|
+
let!(:chatbot) { create(:chatbot, organization:, whatsapp_phone_id: "phone-1") }
|
|
11
|
+
let!(:process) { create(:participatory_process, :published, organization:, title: { "en" => "Town process" }) }
|
|
12
|
+
let!(:introduction_step) do
|
|
13
|
+
create(
|
|
14
|
+
:participatory_process_step,
|
|
15
|
+
participatory_process: process,
|
|
16
|
+
title: { "en" => "Introduction" },
|
|
17
|
+
start_date: 1.month.ago,
|
|
18
|
+
end_date: 1.week.from_now,
|
|
19
|
+
active: true
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
let!(:vote_step) do
|
|
23
|
+
create(
|
|
24
|
+
:participatory_process_step,
|
|
25
|
+
participatory_process: process,
|
|
26
|
+
title: { "en" => "Vote" },
|
|
27
|
+
start_date: 1.week.from_now,
|
|
28
|
+
end_date: 2.months.from_now,
|
|
29
|
+
active: false
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
let!(:item) do
|
|
33
|
+
create(
|
|
34
|
+
:chatbot_item,
|
|
35
|
+
chatbot:,
|
|
36
|
+
scope: "notification",
|
|
37
|
+
manifest_name: "phase",
|
|
38
|
+
settings: {
|
|
39
|
+
"template_id" => { "en" => "1649483436030169" },
|
|
40
|
+
"participatory_space_gid" => process.to_gid.to_s,
|
|
41
|
+
"variables" => { "space_name" => "%{space_name}" }
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
let!(:subscribed) do
|
|
46
|
+
create(
|
|
47
|
+
:user,
|
|
48
|
+
organization:,
|
|
49
|
+
extended_data: { "whatsapp_phone_number" => "+15550001" }
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
let(:graph) { instance_double(Decidim::Chatbot::Whatsapp::GraphClient, send_template: { "messages" => [] }) }
|
|
53
|
+
|
|
54
|
+
before do
|
|
55
|
+
enable_chatbot!(organization)
|
|
56
|
+
allow(Decidim::Chatbot::Whatsapp::GraphClient).to receive(:new).and_return(graph)
|
|
57
|
+
switch_to_host(organization.host)
|
|
58
|
+
login_as user, scope: :user
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "sends the configured template to subscribed users" do
|
|
62
|
+
visit decidim_admin_participatory_processes.participatory_process_steps_path(process)
|
|
63
|
+
|
|
64
|
+
perform_enqueued_jobs do
|
|
65
|
+
within "tr", text: "Vote" do
|
|
66
|
+
find("button[data-controller='dropdown']").click
|
|
67
|
+
click_on "Activate"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
expect(page).to have_content("Participatory process phase successfully activated.")
|
|
72
|
+
expect(graph).to have_received(:send_template).with(
|
|
73
|
+
"phone-1",
|
|
74
|
+
to: "15550001",
|
|
75
|
+
template_id: "1649483436030169",
|
|
76
|
+
parameters: [{ type: "text", parameter_name: "space_name", text: "Town process" }]
|
|
77
|
+
)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin picks a published blog component", driver: :rack_test do
|
|
6
|
+
let(:organization) { create(:organization, available_locales: %w(en fr es)) }
|
|
7
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
8
|
+
let!(:chatbot) { create(:chatbot, organization:) }
|
|
9
|
+
let(:space) { create(:participatory_process, :published, organization:, title: { "en" => "Visible process" }) }
|
|
10
|
+
let!(:blog) { create(:post_component, participatory_space: space, name: { "en" => "News" }) }
|
|
11
|
+
let!(:draft_blog) { create(:post_component, :unpublished, participatory_space: space, name: { "en" => "Draft news" }) }
|
|
12
|
+
let(:hidden_space) { create(:participatory_process, :unpublished, organization:, title: { "en" => "Hidden process" }) }
|
|
13
|
+
let!(:hidden_blog) { create(:post_component, participatory_space: hidden_space, name: { "en" => "Hidden news" }) }
|
|
14
|
+
let!(:proposals) { create(:proposal_component, participatory_space: space, name: { "en" => "Ideas" }) }
|
|
15
|
+
|
|
16
|
+
before do
|
|
17
|
+
enable_chatbot!(organization)
|
|
18
|
+
switch_to_host(organization.host)
|
|
19
|
+
login_as user, scope: :user
|
|
20
|
+
visit decidim_admin_chatbot.chatbot_menu_items_path(chatbot)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "offers a select of published blogs in published spaces" do
|
|
24
|
+
click_on "Add"
|
|
25
|
+
click_on "Read blogs"
|
|
26
|
+
|
|
27
|
+
expect(page).to have_select("Blog Component")
|
|
28
|
+
expect(page).to have_no_field("item_component_id", type: "number")
|
|
29
|
+
expect(page).to have_css("#item_component_id option[value='#{blog.id}']")
|
|
30
|
+
expect(page).to have_no_css("#item_component_id option[value='#{draft_blog.id}']")
|
|
31
|
+
expect(page).to have_no_css("#item_component_id option[value='#{hidden_blog.id}']")
|
|
32
|
+
expect(page).to have_no_css("#item_component_id option[value='#{proposals.id}']")
|
|
33
|
+
|
|
34
|
+
select blog.hierarchy_title, from: "Blog Component"
|
|
35
|
+
fill_in "item_title_en", with: "Read news"
|
|
36
|
+
fill_in "item_menu_button_label_en", with: "Back to menu"
|
|
37
|
+
fill_in "item_read_more_button_label_en", with: "Read more"
|
|
38
|
+
expect(page).to have_field(
|
|
39
|
+
"item_nothing_to_read_label_en",
|
|
40
|
+
with: "There is nothing to read yet, come back later"
|
|
41
|
+
)
|
|
42
|
+
expect(page).to have_content("Button to exit reading blogs and go back to the menu.")
|
|
43
|
+
expect(page).to have_content("Button to read the next blog.")
|
|
44
|
+
expect(page).to have_content("Message shown when there are no blogs left to read.")
|
|
45
|
+
within(".item__edit-sticky") { click_on "Save" }
|
|
46
|
+
|
|
47
|
+
item = chatbot.items.for_scope(:menu).last
|
|
48
|
+
expect(page).to have_current_path(
|
|
49
|
+
decidim_admin_chatbot.edit_chatbot_menu_item_path(chatbot, item),
|
|
50
|
+
ignore_query: true
|
|
51
|
+
)
|
|
52
|
+
expect(page).to have_field("item_title_en", with: "Read news")
|
|
53
|
+
expect(item.manifest_name).to eq("read_blogs")
|
|
54
|
+
expect(item.settings["component_id"]).to eq(blog.id)
|
|
55
|
+
expect(item.settings["menu_button_label"]["en"]).to eq("Back to menu")
|
|
56
|
+
expect(item.settings["read_more_button_label"]["en"]).to eq("Read more")
|
|
57
|
+
expect(item.settings["nothing_to_read_label"]["en"]).to eq("There is nothing to read yet, come back later")
|
|
58
|
+
|
|
59
|
+
expect(page).to have_select("Blog Component")
|
|
60
|
+
fill_in "item_menu_button_label_en", with: "Back to menu"
|
|
61
|
+
fill_in "item_read_more_button_label_en", with: "Read more"
|
|
62
|
+
expect(page).to have_content("Button to exit reading blogs and go back to the menu.")
|
|
63
|
+
expect(page).to have_content("Button to read the next blog.")
|
|
64
|
+
expect(item.reload.settings["menu_button_label"]["en"]).to eq("Back to menu")
|
|
65
|
+
expect(item.settings["read_more_button_label"]["en"]).to eq("Read more")
|
|
66
|
+
expect(item.settings["nothing_to_read_label"]["en"]).to eq("There is nothing to read yet, come back later")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "offers a select of published proposals in published spaces" do
|
|
70
|
+
draft_proposals = create(:proposal_component, :unpublished, participatory_space: space, name: { "en" => "Draft ideas" })
|
|
71
|
+
hidden_proposals = create(:proposal_component, participatory_space: hidden_space, name: { "en" => "Hidden ideas" })
|
|
72
|
+
|
|
73
|
+
click_on "Add"
|
|
74
|
+
click_on "Read proposals"
|
|
75
|
+
|
|
76
|
+
expect(page).to have_select("Proposal Component")
|
|
77
|
+
expect(page).to have_no_field("item_component_id", type: "number")
|
|
78
|
+
expect(page).to have_css("#item_component_id option[value='#{proposals.id}']")
|
|
79
|
+
expect(page).to have_no_css("#item_component_id option[value='#{draft_proposals.id}']")
|
|
80
|
+
expect(page).to have_no_css("#item_component_id option[value='#{hidden_proposals.id}']")
|
|
81
|
+
expect(page).to have_no_css("#item_component_id option[value='#{blog.id}']")
|
|
82
|
+
|
|
83
|
+
select proposals.hierarchy_title, from: "Proposal Component"
|
|
84
|
+
fill_in "item_title_en", with: "Read ideas"
|
|
85
|
+
fill_in "item_menu_button_label_en", with: "Back to menu"
|
|
86
|
+
fill_in "item_read_more_button_label_en", with: "Read more"
|
|
87
|
+
expect(page).to have_field(
|
|
88
|
+
"item_nothing_to_read_label_en",
|
|
89
|
+
with: "There is no proposal yet, come back later"
|
|
90
|
+
)
|
|
91
|
+
expect(page).to have_content("Button to exit reading proposals and go back to the menu.")
|
|
92
|
+
expect(page).to have_content("Button to read the next proposal.")
|
|
93
|
+
expect(page).to have_content("Message shown when there are no proposals left to read.")
|
|
94
|
+
within(".item__edit-sticky") { click_on "Save" }
|
|
95
|
+
|
|
96
|
+
item = chatbot.items.for_scope(:menu).last
|
|
97
|
+
expect(page).to have_current_path(
|
|
98
|
+
decidim_admin_chatbot.edit_chatbot_menu_item_path(chatbot, item),
|
|
99
|
+
ignore_query: true
|
|
100
|
+
)
|
|
101
|
+
expect(page).to have_field("item_title_en", with: "Read ideas")
|
|
102
|
+
expect(item.manifest_name).to eq("read_proposals")
|
|
103
|
+
expect(item.settings["component_id"]).to eq(proposals.id)
|
|
104
|
+
expect(item.settings["menu_button_label"]["en"]).to eq("Back to menu")
|
|
105
|
+
expect(item.settings["read_more_button_label"]["en"]).to eq("Read more")
|
|
106
|
+
expect(item.settings["nothing_to_read_label"]["en"]).to eq("There is no proposal yet, come back later")
|
|
107
|
+
|
|
108
|
+
expect(page).to have_select("Proposal Component")
|
|
109
|
+
fill_in "item_menu_button_label_en", with: "Back to menu"
|
|
110
|
+
fill_in "item_read_more_button_label_en", with: "Read more"
|
|
111
|
+
expect(page).to have_content("Button to exit reading proposals and go back to the menu.")
|
|
112
|
+
expect(page).to have_content("Button to read the next proposal.")
|
|
113
|
+
expect(item.reload.settings["menu_button_label"]["en"]).to eq("Back to menu")
|
|
114
|
+
expect(item.settings["read_more_button_label"]["en"]).to eq("Read more")
|
|
115
|
+
expect(item.settings["nothing_to_read_label"]["en"]).to eq("There is no proposal yet, come back later")
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# rubocop:disable RSpec/ExampleLength -- asserts every propose label on new + save
|
|
119
|
+
it "prefills propose proposal labels on new" do
|
|
120
|
+
click_on "Add"
|
|
121
|
+
click_on "Propose proposals"
|
|
122
|
+
|
|
123
|
+
expect(page).to have_select("Proposal Component")
|
|
124
|
+
expect(page).to have_field("item_default_title_label_en", with: "{{id}} Anonymous proposal")
|
|
125
|
+
expect(page).to have_field("item_body_label_en", with: "Please write your proposal")
|
|
126
|
+
expect(page).to have_field("item_verification_label_en", with: "Thanks, here is your proposal:")
|
|
127
|
+
expect(page).to have_field("item_action_prompt_label_en", with: "What do you want to do with the proposal?")
|
|
128
|
+
expect(page).to have_field("item_save_button_label_en", with: "Save")
|
|
129
|
+
expect(page).to have_field("item_success_label_en", with: "Your proposal has been submitted")
|
|
130
|
+
expect(page).to have_field("item_withdraw_button_label_en", with: "Withdraw")
|
|
131
|
+
expect(page).to have_field("item_withdraw_success_label_en", with: "Your proposal has been withdrawn")
|
|
132
|
+
expect(page).to have_field(
|
|
133
|
+
"item_creation_not_enabled_label_en",
|
|
134
|
+
with: "Proposal creation is not available right now, please come back later."
|
|
135
|
+
)
|
|
136
|
+
expect(page).to have_field("item_title_blank_label_en", with: "cannot be blank")
|
|
137
|
+
expect(page).to have_field("item_body_blank_label_en", with: "cannot be blank")
|
|
138
|
+
expect(page).to have_field("item_title_must_start_with_caps_label_en", with: "must start with a capital letter")
|
|
139
|
+
expect(page).to have_field("item_body_must_start_with_caps_label_en", with: "must start with a capital letter")
|
|
140
|
+
expect(page).to have_field(
|
|
141
|
+
"item_title_too_much_caps_label_en",
|
|
142
|
+
with: "is using too many capital letters (over 25% of the text)"
|
|
143
|
+
)
|
|
144
|
+
expect(page).to have_field(
|
|
145
|
+
"item_body_too_much_caps_label_en",
|
|
146
|
+
with: "is using too many capital letters (over 25% of the text)"
|
|
147
|
+
)
|
|
148
|
+
expect(page).to have_field("item_title_too_short_label_en", with: "is too short (under %{count} characters)")
|
|
149
|
+
expect(page).to have_field("item_body_too_short_label_en", with: "is too short (under %{count} characters)")
|
|
150
|
+
expect(page).to have_field("item_title_too_long_label_en", with: "is too long (maximum is %{count} characters)")
|
|
151
|
+
expect(page).to have_field("item_body_too_long_label_en", with: "is too long (maximum is %{count} characters)")
|
|
152
|
+
expect(page).to have_field(
|
|
153
|
+
"item_title_too_many_marks_label_en",
|
|
154
|
+
with: "is using too many consecutive punctuation marks (e.g. ! and ?)"
|
|
155
|
+
)
|
|
156
|
+
expect(page).to have_field(
|
|
157
|
+
"item_body_too_many_marks_label_en",
|
|
158
|
+
with: "is using too many consecutive punctuation marks (e.g. ! and ?)"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
select proposals.hierarchy_title, from: "Proposal Component"
|
|
162
|
+
fill_in "item_title_en", with: "Propose ideas"
|
|
163
|
+
within(".item__edit-sticky") { click_on "Save" }
|
|
164
|
+
|
|
165
|
+
item = chatbot.items.for_scope(:menu).last
|
|
166
|
+
expect(page).to have_current_path(
|
|
167
|
+
decidim_admin_chatbot.edit_chatbot_menu_item_path(chatbot, item),
|
|
168
|
+
ignore_query: true
|
|
169
|
+
)
|
|
170
|
+
expect(item.manifest_name).to eq("propose_proposals")
|
|
171
|
+
expect(item.settings["component_id"]).to eq(proposals.id)
|
|
172
|
+
expect(item.settings["default_title_label"]["en"]).to eq("{{id}} Anonymous proposal")
|
|
173
|
+
expect(item.settings["body_label"]["en"]).to eq("Please write your proposal")
|
|
174
|
+
expect(item.settings["verification_label"]["en"]).to eq("Thanks, here is your proposal:")
|
|
175
|
+
expect(item.settings["action_prompt_label"]["en"]).to eq("What do you want to do with the proposal?")
|
|
176
|
+
expect(item.settings["save_button_label"]["en"]).to eq("Save")
|
|
177
|
+
expect(item.settings["success_label"]["en"]).to eq("Your proposal has been submitted")
|
|
178
|
+
expect(item.settings["withdraw_button_label"]["en"]).to eq("Withdraw")
|
|
179
|
+
expect(item.settings["withdraw_success_label"]["en"]).to eq("Your proposal has been withdrawn")
|
|
180
|
+
expect(item.settings["creation_not_enabled_label"]["en"]).to eq(
|
|
181
|
+
"Proposal creation is not available right now, please come back later."
|
|
182
|
+
)
|
|
183
|
+
expect(item.settings["title_blank_label"]["en"]).to eq("cannot be blank")
|
|
184
|
+
expect(item.settings["body_blank_label"]["en"]).to eq("cannot be blank")
|
|
185
|
+
expect(item.settings["title_must_start_with_caps_label"]["en"]).to eq("must start with a capital letter")
|
|
186
|
+
expect(item.settings["body_must_start_with_caps_label"]["en"]).to eq("must start with a capital letter")
|
|
187
|
+
expect(item.settings["title_too_much_caps_label"]["en"]).to eq(
|
|
188
|
+
"is using too many capital letters (over 25% of the text)"
|
|
189
|
+
)
|
|
190
|
+
expect(item.settings["body_too_much_caps_label"]["en"]).to eq(
|
|
191
|
+
"is using too many capital letters (over 25% of the text)"
|
|
192
|
+
)
|
|
193
|
+
expect(item.settings["title_too_short_label"]["en"]).to eq("is too short (under %{count} characters)")
|
|
194
|
+
expect(item.settings["body_too_short_label"]["en"]).to eq("is too short (under %{count} characters)")
|
|
195
|
+
expect(item.settings["title_too_long_label"]["en"]).to eq("is too long (maximum is %{count} characters)")
|
|
196
|
+
expect(item.settings["body_too_long_label"]["en"]).to eq("is too long (maximum is %{count} characters)")
|
|
197
|
+
expect(item.settings["title_too_many_marks_label"]["en"]).to eq(
|
|
198
|
+
"is using too many consecutive punctuation marks (e.g. ! and ?)"
|
|
199
|
+
)
|
|
200
|
+
expect(item.settings["body_too_many_marks_label"]["en"]).to eq(
|
|
201
|
+
"is using too many consecutive punctuation marks (e.g. ! and ?)"
|
|
202
|
+
)
|
|
203
|
+
end
|
|
204
|
+
# rubocop:enable RSpec/ExampleLength
|
|
205
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin picks a published participatory space", driver: :rack_test do
|
|
6
|
+
let(:organization) { create(:organization, available_locales: %w(en fr es)) }
|
|
7
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
8
|
+
let!(:chatbot) { create(:chatbot, organization:) }
|
|
9
|
+
let!(:process) { create(:participatory_process, :published, organization:, title: { "en" => "Town process" }) }
|
|
10
|
+
let!(:draft) { create(:participatory_process, :unpublished, organization:, title: { "en" => "Draft process" }) }
|
|
11
|
+
let!(:assembly) { create(:assembly, :published, organization:, title: { "en" => "Town assembly" }) }
|
|
12
|
+
let!(:foreign) { create(:participatory_process, :published, organization: create(:organization), title: { "en" => "Other org" }) }
|
|
13
|
+
|
|
14
|
+
before do
|
|
15
|
+
enable_chatbot!(organization)
|
|
16
|
+
switch_to_host(organization.host)
|
|
17
|
+
login_as user, scope: :user
|
|
18
|
+
visit decidim_admin_chatbot.chatbot_notifications_path(chatbot)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "offers a select of published spaces of every type" do
|
|
22
|
+
click_on "Add"
|
|
23
|
+
click_on "Phase"
|
|
24
|
+
|
|
25
|
+
expect(page).to have_select("item_participatory_space_gid")
|
|
26
|
+
expect(page).to have_no_field("item_participatory_space_gid", type: "text")
|
|
27
|
+
expect(page).to have_select("item_participatory_space_gid", with_options: ["Town process", "Town assembly"])
|
|
28
|
+
labels = page.find_by_id("item_participatory_space_gid").all("option").map(&:text)
|
|
29
|
+
expect(labels).not_to include("Draft process", "Other org")
|
|
30
|
+
|
|
31
|
+
fill_in "item_template_id_en", with: "1649483436030169"
|
|
32
|
+
check "item_use_space_name"
|
|
33
|
+
select "Town process", from: "item_participatory_space_gid"
|
|
34
|
+
within(".item__edit-sticky") { click_on "Save" }
|
|
35
|
+
|
|
36
|
+
item = chatbot.items.for_scope(:notification).last
|
|
37
|
+
expect(page).to have_current_path(
|
|
38
|
+
decidim_admin_chatbot.edit_chatbot_notification_path(chatbot, item),
|
|
39
|
+
ignore_query: true
|
|
40
|
+
)
|
|
41
|
+
expect(page).to have_field("item_template_id_en", with: "1649483436030169")
|
|
42
|
+
expect(item.manifest_name).to eq("phase")
|
|
43
|
+
expect(item.settings["participatory_space_gid"]).to eq(process.to_gid.to_s)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe "Admin reorders chatbot menu items", :js do
|
|
6
|
+
let(:organization) { create(:organization, available_locales: %w(en fr es)) }
|
|
7
|
+
let(:user) { create(:user, :admin, :confirmed, organization:) }
|
|
8
|
+
let!(:chatbot) { create(:chatbot, organization:) }
|
|
9
|
+
let!(:first) { create(:chatbot_item, chatbot:, position: 0, title: { "en" => "First item" }) }
|
|
10
|
+
let!(:second) { create(:chatbot_item, chatbot:, position: 1, title: { "en" => "Second item" }) }
|
|
11
|
+
|
|
12
|
+
before do
|
|
13
|
+
enable_chatbot!(organization)
|
|
14
|
+
switch_to_host(organization.host)
|
|
15
|
+
login_as user, scope: :user
|
|
16
|
+
visit decidim_admin_chatbot.chatbot_menu_items_path(chatbot)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "drag-reorders menu rows" do
|
|
20
|
+
expect(page).to have_css("tbody.draggable-table")
|
|
21
|
+
source = find("tbody.draggable-table tr:first-child td.dragging-handle")
|
|
22
|
+
target = find("tbody.draggable-table tr:last-child")
|
|
23
|
+
source.drag_to(target)
|
|
24
|
+
visit current_path
|
|
25
|
+
expect(page.text.index("Second item")).to be < page.text.index("First item")
|
|
26
|
+
expect(first.reload.position).to eq(1)
|
|
27
|
+
expect(second.reload.position).to eq(0)
|
|
28
|
+
end
|
|
29
|
+
end
|