From aabfda0a7a3527c069d7a6c9e2e8f78453b77afd Mon Sep 17 00:00:00 2001 From: takahashim Date: Mon, 8 Apr 2024 18:26:08 +0900 Subject: [PATCH 01/11] WIP --- .../decidim/devise/registrations/new.html.erb | 150 +++++++----------- 1 file changed, 59 insertions(+), 91 deletions(-) diff --git a/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb b/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb index 4c1cd5bc7..1a4783b88 100644 --- a/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb +++ b/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb @@ -4,102 +4,70 @@ <%= render "decidim/devise/shared/links" %> <% end %> -
-
-
-
-

<%= t(".sign_up") %>

-

- <%= t(".subtitle") %> -

-

- <%= t(".already_have_an_account?") %> - <%= link_to t(".sign_in"), new_user_session_path %> -

-
+<%= render layout: "layouts/decidim/shared/layout_center" do %> +
+

<%= t("decidim.devise.registrations.new.sign_up") %>

+
+ + + + + + <% cache current_organization do %> <%= render "decidim/devise/shared/omniauth_buttons" %> <% end %> -
-
- - <%= decidim_form_for(@form, namespace: "registration", as: resource_name, url: registration_path(resource_name), html: { class: "register-form new_user", id: "register-form" }) do |f| %> - <%= invisible_captcha %> -
-
- <%= form_required_explanation %> - -
-
- <%= f.text_field :name, help_text: t(".username_help"), autocomplete: "name", placeholder: t(".username_placeholder") %> -
-
- -
-
- <%= f.text_field :nickname, help_text: t(".nickname_help", organization: current_organization.name), prefix: { value: "@", small: 1, large: 1 }, autocomplete: "nickname", placeholder: t(".nickname_placeholder") %> -
-
- -

<%= t(".nickname_notice") %>

- -
- <%= f.email_field :email, autocomplete: "email" %> -
- -
- <%= f.password_field :password, password_field_options_for(:user) %> -
- -
- <%= f.password_field :password_confirmation, password_field_options_for(:user).except(:help_text) %> -
- - - <% if current_organization.available_authorizations&.include?("user_extension") %> - <%= render partial: "user_extension", locals: {f: f} %> - <% end %> - -
-
- -
-
-

<%= t(".tos_title") %>

- -

- <%= strip_tags(translated_attribute(terms_and_conditions_page.content)) %> -

- -
- <%= f.check_box :tos_agreement, label: t(".tos_agreement", link: link_to(t(".terms"), page_path("terms-and-conditions"))) %> -
-
-
- -
-
-

<%= t(".newsletter_title") %>

-
- <%= f.check_box :newsletter, label: t(".newsletter"), checked: @form.newsletter %> -
-
-
- -
-
-
- <%= f.submit t("devise.registrations.new.sign_up"), class: "button expanded" %> -
- <%= yield :devise_links %> -
-
- <% end %> + <%= decidim_form_for(@form, namespace: "registration", as: resource_name, url: registration_path(resource_name), html: { id: "register-form" }) do |f| %> + <%= invisible_captcha %> + +
+ <%= f.text_field :name, help_text: t("decidim.devise.registrations.new.username_help"), autocomplete: "name", placeholder: "John Doe" %> + + <%= f.email_field :email, autocomplete: "email", placeholder: t("placeholder_email", scope: "decidim.devise.shared") %> + + <%= render partial: "decidim/account/password_fields", locals: { form: f, user: :user } %>
-
-
-
+ +
+

<%= t("decidim.devise.registrations.new.tos_title") %>

+ +
+ <% terms_of_service_summary_content_blocks.each do |content_block| %> + <%= cell content_block.manifest.cell, content_block %> + <% end %> +
+ + <%= f.check_box :tos_agreement, label: t("decidim.devise.registrations.new.tos_agreement", link: link_to(t("decidim.devise.registrations.new.terms"), page_path("terms-of-service"))), label_options: { class: "form__wrapper-checkbox-label" } %> +
+ +
+

<%= t("decidim.devise.registrations.new.newsletter_title") %>

+ <%= f.check_box :newsletter, label: t("decidim.devise.registrations.new.newsletter"), checked: @form.newsletter, label_options: { class: "form__wrapper-checkbox-label" } %> +
+ +
+ +
+ + + <% end %> +<% end %> + <%= render "decidim/devise/shared/newsletter_modal" %> From 73e351e0cbfde53dbbb3d6b1c2b06229a1067dde Mon Sep 17 00:00:00 2001 From: takahashim Date: Mon, 8 Apr 2024 18:26:33 +0900 Subject: [PATCH 02/11] support user_extension --- .../app/views/decidim/devise/registrations/new.html.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb b/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb index 1a4783b88..6b5c30130 100644 --- a/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb +++ b/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb @@ -38,6 +38,12 @@ <%= f.email_field :email, autocomplete: "email", placeholder: t("placeholder_email", scope: "decidim.devise.shared") %> <%= render partial: "decidim/account/password_fields", locals: { form: f, user: :user } %> + + + <% if current_organization.available_authorizations&.include?("user_extension") %> + <%= render partial: "user_extension", locals: {f: f} %> + <% end %> +
From 3c4be9bd8560a840a843e986465a64ffc5972f80 Mon Sep 17 00:00:00 2001 From: takahashim Date: Mon, 8 Apr 2024 18:50:57 +0900 Subject: [PATCH 03/11] fix locale --- config/locales/ja.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 04ce40568..fe910168e 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -92,7 +92,7 @@ ja: nickname_help: 本人を識別するための任意のアルファベットを入力してください。 nickname_notice: "※ 表示名とアカウントIDが投稿に表示されます。例)共創 歩@ayumi" nickname_placeholder: ayumi - password_help: 半角英数字%{minimun_characters}文字以上で入力してください。単純すぎてはいけません(例:123456)。アカウントIDやメールアドレスと異なる必要があります。 + password_help: 半角英数字%{minimum_characters}文字以上で入力してください。単純すぎてはいけません(例:123456)。アカウントIDやメールアドレスと異なる必要があります。 see_username: アカウントIDを見る subtitle: 参加するにはユーザ登録をしてください。 terms: 利用規約 @@ -303,7 +303,7 @@ ja: message: あなたのアカウントはログインに規定回数以上失敗したため、ロックされています。 passwords: edit: - password_help: "%{minimun_characters} 半角英数字10文字以上で入力してください。単純すぎてはいけません(例:123456)。アカウントIDやメールアドレスと異なる必要があります。" + password_help: "半角英数字%{minimum_characters}文字以上で入力してください。単純すぎてはいけません(例:123456)。アカウントIDやメールアドレスと異なる必要があります。" shared: links: didn_t_receive_confirmation_instructions: ユーザ登録確認メールが届かない方はこちら From 62f1ae8beb8888bdf68548b85b2de0517755e59a Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 9 Apr 2024 01:53:38 +0900 Subject: [PATCH 04/11] add decidim-user_extension --- Gemfile | 2 +- Gemfile.lock | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f393f6393..79426dc4d 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ gem "newrelic_rpm" gem "omniauth-line_login", path: "omniauth-line_login" gem "omniauth-rails_csrf_protection" -# gem "decidim-user_extension", path: "decidim-user_extension" +gem "decidim-user_extension", path: "decidim-user_extension" gem "slack-ruby-client" diff --git a/Gemfile.lock b/Gemfile.lock index 12c8b51f1..f1dca6d30 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,6 +27,14 @@ GIT decidim-admin (~> 0.28.0) decidim-core (~> 0.28.0) +PATH + remote: decidim-user_extension + specs: + decidim-user_extension (0.4.0) + decidim-admin + decidim-core + rails + PATH remote: omniauth-line_login specs: @@ -867,6 +875,7 @@ GEM PLATFORMS aarch64-linux + arm64-darwin-22 arm64-darwin-23 x86_64-linux @@ -879,6 +888,7 @@ DEPENDENCIES decidim-dev (= 0.28.0) decidim-navigation_maps! decidim-term_customizer! + decidim-user_extension! deface dotenv-rails factory_bot_rails From f76c0fded2e08b1e6c47d53314fd2a64ad7d81da Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 9 Apr 2024 01:50:38 +0900 Subject: [PATCH 05/11] fix decidim-user_extension --- .../user_extension_override.html.erb.deface | 2 +- .../entrypoints/decidim_user_extension.scss | 1 + .../entrypoints/decidim_user_extention.scss | 1 - .../user_extension/_show_user_extension.scss | 19 +++++ .../decidim/user_extension/application.css | 15 ---- .../decidim/user_extension/application.scss | 1 + .../_show_user_extension_modal.html.erb | 76 ++++++++++--------- 7 files changed, 62 insertions(+), 53 deletions(-) create mode 100644 decidim-user_extension/app/packs/entrypoints/decidim_user_extension.scss delete mode 100644 decidim-user_extension/app/packs/entrypoints/decidim_user_extention.scss create mode 100644 decidim-user_extension/app/packs/stylesheets/decidim/user_extension/_show_user_extension.scss delete mode 100644 decidim-user_extension/app/packs/stylesheets/decidim/user_extension/application.css create mode 100644 decidim-user_extension/app/packs/stylesheets/decidim/user_extension/application.scss diff --git a/decidim-user_extension/app/overrides/decidim/admin/officializations/index/user_extension_override.html.erb.deface b/decidim-user_extension/app/overrides/decidim/admin/officializations/index/user_extension_override.html.erb.deface index 5786b47f1..aa80c07a0 100644 --- a/decidim-user_extension/app/overrides/decidim/admin/officializations/index/user_extension_override.html.erb.deface +++ b/decidim-user_extension/app/overrides/decidim/admin/officializations/index/user_extension_override.html.erb.deface @@ -1,5 +1,5 @@ <% if allowed_to? :show_user_extension, :user, user: user %> - <%= icon_link_to "person", Decidim::UserExtension::AdminEngine.routes.url_helpers.officializations_show_user_extension_path(user.id), t("show_user_extension", scope: "decidim.admin.officializations.index"), class: "action-icon action-icon--show-user", data: { full_name: user.name, toggle: "show-user-modal" } %> + <%= icon_link_to "user-line", Decidim::UserExtension::AdminEngine.routes.url_helpers.officializations_show_user_extension_path(user.id), t("show_user_extension", scope: "decidim.admin.officializations.index"), class: "action-icon action-icon--show-user", data: { full_name: user.name, dialog_open: "show-user-modal" } %> <% end %> diff --git a/decidim-user_extension/app/packs/entrypoints/decidim_user_extension.scss b/decidim-user_extension/app/packs/entrypoints/decidim_user_extension.scss new file mode 100644 index 000000000..8d3aeda5b --- /dev/null +++ b/decidim-user_extension/app/packs/entrypoints/decidim_user_extension.scss @@ -0,0 +1 @@ +@import "stylesheets/decidim/user_extension/application.scss"; diff --git a/decidim-user_extension/app/packs/entrypoints/decidim_user_extention.scss b/decidim-user_extension/app/packs/entrypoints/decidim_user_extention.scss deleted file mode 100644 index b0da0ebcc..000000000 --- a/decidim-user_extension/app/packs/entrypoints/decidim_user_extention.scss +++ /dev/null @@ -1 +0,0 @@ -@import "../stylesheets/decidim/user_extension/application.css"; \ No newline at end of file diff --git a/decidim-user_extension/app/packs/stylesheets/decidim/user_extension/_show_user_extension.scss b/decidim-user_extension/app/packs/stylesheets/decidim/user_extension/_show_user_extension.scss new file mode 100644 index 000000000..4b5cf516e --- /dev/null +++ b/decidim-user_extension/app/packs/stylesheets/decidim/user_extension/_show_user_extension.scss @@ -0,0 +1,19 @@ +.show_user_extension { + @apply my-4; + + h4 { + @apply text-md w-full text-gray-2 font-semibold mb-2; + } + + > div { + @apply bg-gray-3 mb-2 p-2; + } + + #user_extension + p { + @apply hidden; + } + + #user_extension:empty + p { + @apply block; + } +} diff --git a/decidim-user_extension/app/packs/stylesheets/decidim/user_extension/application.css b/decidim-user_extension/app/packs/stylesheets/decidim/user_extension/application.css deleted file mode 100644 index 0ebd7fe82..000000000 --- a/decidim-user_extension/app/packs/stylesheets/decidim/user_extension/application.css +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS - * files in this directory. Styles in this file should be added after the last require_* statement. - * It is generally better to create a new file per style scope. - * - *= require_tree . - *= require_self - */ diff --git a/decidim-user_extension/app/packs/stylesheets/decidim/user_extension/application.scss b/decidim-user_extension/app/packs/stylesheets/decidim/user_extension/application.scss new file mode 100644 index 000000000..1224c79a8 --- /dev/null +++ b/decidim-user_extension/app/packs/stylesheets/decidim/user_extension/application.scss @@ -0,0 +1 @@ +@import "stylesheets/decidim/user_extension/_show_user_extension.scss"; diff --git a/decidim-user_extension/app/views/decidim/user_extension/admin/officializations/_show_user_extension_modal.html.erb b/decidim-user_extension/app/views/decidim/user_extension/admin/officializations/_show_user_extension_modal.html.erb index cc2859a17..4d2dfb128 100644 --- a/decidim-user_extension/app/views/decidim/user_extension/admin/officializations/_show_user_extension_modal.html.erb +++ b/decidim-user_extension/app/views/decidim/user_extension/admin/officializations/_show_user_extension_modal.html.erb @@ -1,34 +1,33 @@ -
-
-

<%= t(".title") %>

- -
- -
-
+<%= decidim_modal id: "show-user-modal" do %> +
+ <%= icon "information-line" %> +

+ <%= t(".title") %> +

+

<%= t(".description") %>

-
+

<%= t(".full_name") %>

-

-

<%= t(".user_extension") %>

+
+

+
+

+ <%= t(".user_extension") %> +

<%= t(".hidden") %>

- -
- -
-
+
+ +
+<% end %> From 3cde0685e7419fab2d243872c60c02466a9e5369 Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 9 Apr 2024 01:51:26 +0900 Subject: [PATCH 06/11] shakapacker: add load path --- config/shakapacker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/shakapacker.yml b/config/shakapacker.yml index 41c8f7199..65291d8eb 100644 --- a/config/shakapacker.yml +++ b/config/shakapacker.yml @@ -17,6 +17,7 @@ default: &default additional_paths: - node_modules - app/packs + - decidim-user_extension/app/packs # Reload manifest.json on all requests so we reload latest compiled packs cache_manifest: false From 76f90e737db2f2f2e67dbfcbf247aa22c1b2052d Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 9 Apr 2024 01:52:00 +0900 Subject: [PATCH 07/11] load css --- app/packs/stylesheets/decidim/decidim_application.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/packs/stylesheets/decidim/decidim_application.scss b/app/packs/stylesheets/decidim/decidim_application.scss index cbf83c945..b6234b732 100644 --- a/app/packs/stylesheets/decidim/decidim_application.scss +++ b/app/packs/stylesheets/decidim/decidim_application.scss @@ -11,3 +11,5 @@ @import "./cfj/search"; @import "./cfj/media_print"; @import "./cfj/tiptap_html_edit"; + +@import "stylesheets/decidim/user_extension/application"; From e2cff45cc8402487d9032a2c68ef3d9bddf0f66a Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 9 Apr 2024 01:57:41 +0900 Subject: [PATCH 08/11] fix locale --- config/locales/ja.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/ja.yml b/config/locales/ja.yml index fe910168e..7f3ed8cd4 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -94,6 +94,7 @@ ja: nickname_placeholder: ayumi password_help: 半角英数字%{minimum_characters}文字以上で入力してください。単純すぎてはいけません(例:123456)。アカウントIDやメールアドレスと異なる必要があります。 see_username: アカウントIDを見る + sign_in: ログイン subtitle: 参加するにはユーザ登録をしてください。 terms: 利用規約 username_placeholder: 共創 歩 From 7fbf15b24524e28aa813be4e8634921e486c25f9 Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 9 Apr 2024 02:07:37 +0900 Subject: [PATCH 09/11] update view --- .../app/views/decidim/account/show.html.erb | 91 +++++++++++-------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/decidim-user_extension/app/views/decidim/account/show.html.erb b/decidim-user_extension/app/views/decidim/account/show.html.erb index 2c285ddec..2cf0a7d58 100644 --- a/decidim-user_extension/app/views/decidim/account/show.html.erb +++ b/decidim-user_extension/app/views/decidim/account/show.html.erb @@ -1,63 +1,78 @@ -<%= alert_box("", "account-notification hide", true) %> <% add_decidim_page_title(t("profile", scope: "layouts.decidim.user_menu")) %> <% content_for(:subtitle) { t("profile", scope: "layouts.decidim.user_menu") } %> -
- <%= decidim_form_for(@account, url: account_path, method: :put, html: { autocomplete: "on" }) do |f| %> -
- <%= f.upload :avatar %> +<%= render layout: "layouts/decidim/shared/layout_user_profile" do %> + <% if current_user.unconfirmed_email.present? %> + <%# NOTE: announcement cell clean_body method will purge the button %> +
+ +

+ <%= t("decidim.account.email_change.title") %> +

+

+ <%= t("decidim.account.email_change.body1", unconfirmed_email: current_user.unconfirmed_email) %> +

+

+ <%== t( + "decidim.account.email_change.body2", + resend_link: link_to(t("decidim.account.email_change.send_again"), resend_confirmation_instructions_account_path, role: :button, method: :post, remote: true), + cancel_link: link_to(t("decidim.account.email_change.cancel"), cancel_email_change_account_path, role: :button, method: :post, remote: true)) %> +

+
+ <% end %> -
- <% if current_user.unconfirmed_email.present? %> -
-

<%= t("decidim.account.email_change.title") %>

-

<%= t("decidim.account.email_change.body1", unconfirmed_email: current_user.unconfirmed_email) %>

-

- <%== t( - "decidim.account.email_change.body2", - resend_link: link_to(t("decidim.account.email_change.send_again"), resend_confirmation_instructions_account_path, role: :button, method: :post, remote: true), - cancel_link: link_to(t("decidim.account.email_change.cancel"), cancel_email_change_account_path, role: :button, method: :post, remote: true)) %> -

-
- <% end %> + <%= decidim_form_for(@account, url: account_path, method: :put, html: { autocomplete: "on", class: "form-defaults edit_user" }) do |f| %> +
+ <%= f.upload :avatar, button_class: "button button__lg button__transparent-secondary w-full" %> <%= form_required_explanation %> <%= f.text_field :name, autocomplete: "name" %> <%= f.text_field :nickname, autocomplete: "nickname" %> - <%= f.email_field :email, disabled: current_user.unconfirmed_email.present?, autocomplete: "email" %> + <%= f.email_field :email, disabled: current_user.unconfirmed_email.present?, autocomplete: "email", data: { original: current_user.email } %> <%= f.url_field :personal_url, autocomplete: "url" %> <%= f.text_area :about, rows: 5 %> - <%= f.collection_select( - :locale, - @account.organization.available_locales, - :to_s, - ->(locale) {locale_name(locale) } - ) %> -

<%= t(".available_locales_helper") %>

- <% if current_organization.available_authorizations&.include?("user_extension") %> <%= render partial: "user_extension", locals: {f: f} %> <% end %> - <% if @account.errors[:password].any? || @account.errors[:password_confirmation].any? %> - <%= render partial: "password_fields", locals: { form: f } %> - <% else %> - <% if current_organization.sign_in_enabled? %> -

- -

-
- <%= render partial: "password_fields", locals: { form: f } %> + <%= f.collection_select( + :locale, + @account.organization.available_locales, + :to_s, + ->(locale) { locale_name(locale) }, + help_text: t("available_locales_helper", scope:"decidim.account.show") + ) %> + <% if @account.password.present? %> + <%= render partial: "password_fields", locals: { form: f, user: current_user } %> + <%= render partial: "old_password_field", locals: { form: f, show_help_text: true } %> + <% elsif current_organization.sign_in_enabled? %> +
+ <%= button_tag( + class: "text-lg font-semibold text-secondary underline block cursor-pointer", + id: "accordion-trigger-panel-password", + type: "button", + data: { controls: "panel-password" } + ) do %> + <%= t("change_password", scope:"decidim.account.show") %> + <% end %> +
+ <%= render partial: "password_fields", locals: { form: f, user: current_user } %>
+
+ + <%= content_tag :div, id: "panel-old-password", class: @account.errors[:old_password].any? ? nil : "hidden" do %> + <%= render partial: "old_password_field", locals: { form: f, show_help_text: true } %> <% end %> <% end %> - <%= f.submit t(".update_account") %> +
+ <%= f.submit t("update_account", scope:"decidim.account.show"), class: "button button__sm md:button__lg button__secondary mr-auto !ml-0" %> +
<% end %> -
+<% end %> From c4411373200e6ed54f61ded56c63956a1cdd8c02 Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 9 Apr 2024 02:42:08 +0900 Subject: [PATCH 10/11] fix specs --- spec/system/admin_officializations_user_extension_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/system/admin_officializations_user_extension_spec.rb b/spec/system/admin_officializations_user_extension_spec.rb index 90620632c..d3ccfeffe 100644 --- a/spec/system/admin_officializations_user_extension_spec.rb +++ b/spec/system/admin_officializations_user_extension_spec.rb @@ -46,7 +46,7 @@ let!(:not_officialized) { create(:user, organization:) } before do - within ".secondary-nav" do + within ".sidebar-menu" do click_link "参加者" end end @@ -60,7 +60,7 @@ expect(page).to have_css(".action-icon--show-user") anchor = first("a.action-icon--show-user") - expect(anchor["data-toggle"]).to eq "show-user-modal" + expect(anchor["data-dialog-open"]).to eq "show-user-modal" expect(anchor["title"]).to eq "ユーザー属性を表示" end end @@ -80,7 +80,7 @@ create(:authorization, user:, name: "user_extension", metadata: user_extension) end - within ".secondary-nav" do + within ".sidebar-menu" do click_link "参加者" end end @@ -100,7 +100,7 @@ expect(page).to have_content("本名") expect(page).to have_content("#{user.nickname}_real") - find("button[data-close]").click + find("button[data-dialog-close]").click end end From 9cae951fafdce8790f2a0876cf67e3d1ff0c7ab8 Mon Sep 17 00:00:00 2001 From: takahashim Date: Wed, 10 Apr 2024 23:38:10 +0900 Subject: [PATCH 11/11] fix specs for decidim-comments (comment order) --- spec/system/comment_sort_spec.rb | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/spec/system/comment_sort_spec.rb b/spec/system/comment_sort_spec.rb index 1ae4b07f9..28522efb1 100644 --- a/spec/system/comment_sort_spec.rb +++ b/spec/system/comment_sort_spec.rb @@ -28,18 +28,25 @@ expect(page).to have_no_content("Comments are disabled at this time") expect(page).to have_css(".comment", minimum: 1) - page.find(".order-by .dropdown.menu .is-dropdown-submenu-parent").hover + # click "評価の高い順" within ".comments" do - within ".order-by__dropdown" do - # click_link "古い順" # Opens the dropdown - # click_link "評価の高い順" - page.find_by_id("comments-order-menu-control").click # Opens the dropdown - page.find("#comments-order-chooser-menu li:first-of-type a").click - end + click_link "評価の高い順" end - expect(page).to have_css(".comments > div:nth-child(2)", text: "Most Rated Comment") + # show other page + visit "/" + + # back to resource page + visit resource_path + + expect(page).to have_css(".comment", minimum: 1) + expect(page).to have_css("div.comment-order-by div a.underline", text: "評価の高い順") + + # click "新しい順" + within ".comments" do + click_link "新しい順" + end # show other page visit "/" @@ -48,8 +55,6 @@ visit resource_path expect(page).to have_css(".comment", minimum: 1) - page.find(".order-by .dropdown.menu .is-dropdown-submenu-parent").hover - # expect(page).to have_css("#comments-order-menu-control", text: "評価の高い順") - expect(page).to have_css("#comments-order-menu-control", text: "Best rated") + expect(page).to have_css("div.comment-order-by div a.underline", text: "新しい順") end end