A platform for community discussion. Free, open, simple.
DEV: Post localization improvements (#32869)
Keegan Georgeaf91b0433f9d
diff --git a/app/assets/javascripts/discourse/app/components/post/meta-data/translation-indicator.gjs b/app/assets/javascripts/discourse/app/components/modal/post-translations.gjssimilarity index 53%rename from app/assets/javascripts/discourse/app/components/post/meta-data/translation-indicator.gjsrename to app/assets/javascripts/discourse/app/components/modal/post-translations.gjsindex 5df9e744c8f..0a4a3b23271 100644--- a/app/assets/javascripts/discourse/app/components/post/meta-data/translation-indicator.gjs+++ b/app/assets/javascripts/discourse/app/components/modal/post-translations.gjs@@ -1,23 +1,29 @@import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";import { fn } from "@ember/helper";import { action } from "@ember/object";import { service } from "@ember/service";+import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";import DButton from "discourse/components/d-button";-import icon from "discourse/helpers/d-icon";+import DModal from "discourse/components/d-modal";import { popupAjaxError } from "discourse/lib/ajax-error";import Composer from "discourse/models/composer";import PostLocalization from "discourse/models/post-localization";import TopicLocalization from "discourse/models/topic-localization";import { i18n } from "discourse-i18n";-import DTooltip from "float-kit/components/d-tooltip";-export default class PostMetaDataTranslationIndicator extends Component {+export default class PostTranslationsModal extends Component {@service composer;@service currentUser;@service siteSettings;+ @service dialog;- get postLocalizationsCount() {- return this.args.post?.post_localizations.length;+ @tracked postLocalizations = null;+ @tracked loading = false;++ constructor() {+ super(...arguments);+ this.loadPostLocalizations();}get originalPostContent() {@@ -25,10 +31,25 @@ export default class PostMetaDataTranslationIndicator extends Component {<span class='d-editor-translation-preview-wrapper__header'>${i18n("composer.translations.original_content")}</span>- ${this.args.post.cooked}+ ${this.args.model.post.cooked}</div>`;}+ async loadPostLocalizations() {+ this.loading = true;++ try {+ const { post_localizations } = await PostLocalization.find(+ this.args.model.post.id+ );++ this.postLocalizations = post_localizations;+ this.loading = false;+ } catch (error) {+ popupAjaxError(error);+ }+ }+@actionasync editLocalization(locale) {if (@@ -39,12 +60,14 @@ export default class PostMetaDataTranslationIndicator extends Component {return;}+ this.args.closeModal();+await this.composer.open({action: Composer.ADD_TRANSLATION,draftKey: "translation",warningsDisabled: true,hijackPreview: this.originalPostContent,- post: this.args.post,+ post: this.args.model.post,selectedTranslationLocale: locale.locale,});this.composer.model.set("reply", locale.raw);@@ -53,10 +76,10 @@ export default class PostMetaDataTranslationIndicator extends Component {@actionasync deleteLocalization(locale) {try {- await PostLocalization.destroy(this.args.post.id, locale);+ await PostLocalization.destroy(this.args.model.post.id, locale);- if (this.args.post.firstPost) {- await TopicLocalization.destroy(this.args.post.topic_id, locale);+ if (this.args.model.post.firstPost) {+ await TopicLocalization.destroy(this.args.model.post.topic_id, locale);}} catch (error) {popupAjaxError(error);@@ -65,20 +88,28 @@ export default class PostMetaDataTranslationIndicator extends Component {}}+ @action+ delete(locale) {+ return this.dialog.yesNoConfirm({+ message: i18n("post.localizations.modal.confirm_delete", {+ languageCode: locale,+ }),+ didConfirm: () => {+ return this.deleteLocalization(locale);+ },+ });+ }+<template>- <div class="post-info translations">- <DTooltip- @triggerClass="btn-flat"- @placement="bottom-start"- @arrow={{true}}- @identifier="post-meta-data-translation-indicator"- @interactive={{true}}- >- <:trigger>- <span class="translation-count">{{this.postLocalizationsCount}}</span>- {{icon "globe"}}- </:trigger>- <:content>+ <DModal+ @title={{i18n "post.localizations.modal.title"}}+ @closeModal={{@closeModal}}+ class="post-translations-modal"+ >+ <:body>+ <ConditionalLoadingSpinner @size="large" @condition={{this.loading}} />++ {{#if this.postLocalizations}}<table><thead><tr>@@ -87,29 +118,33 @@ export default class PostMetaDataTranslationIndicator extends Component {</tr></thead><tbody>- {{#each @post.post_localizations as |localization|}}+ {{#each this.postLocalizations as |localization|}}<tr>- <td>{{localization.locale}}</td>- <td>+ <td+ class="post-translations-modal__locale"+ >{{localization.locale}}</td>+ <td class="post-translations-modal__edit-action"><DButtonclass="btn-primary btn-transparent"+ @icon="pencil"@label="post.localizations.table.edit"@action={{fn this.editLocalization localization}}/></td>- <td>+ <td class="post-translations-modal__delete-action"><DButtonclass="btn-danger btn-transparent"+ @icon="trash-can"@label="post.localizations.table.delete"- @action={{fn this.deleteLocalization localization.locale}}+ @action={{fn this.delete localization.locale}}/></td></tr>{{/each}}</tbody></table>- </:content>- </DTooltip>- </div>+ {{/if}}+ </:body>+ </DModal></template>}diff --git a/app/assets/javascripts/discourse/app/components/post/menu/buttons/add-translation.gjs b/app/assets/javascripts/discourse/app/components/post/menu/buttons/add-translation.gjsindex 97b25c09e9f..1fcb24dd444 100644--- a/app/assets/javascripts/discourse/app/components/post/menu/buttons/add-translation.gjs+++ b/app/assets/javascripts/discourse/app/components/post/menu/buttons/add-translation.gjs@@ -1,13 +1,18 @@import Component from "@glimmer/component";import { tracked } from "@glimmer/tracking";+import { array } from "@ember/helper";import { action } from "@ember/object";import { service } from "@ember/service";import DButton from "discourse/components/d-button";+import DropdownMenu from "discourse/components/dropdown-menu";+import PostTranslationsModal from "discourse/components/modal/post-translations";import Composer from "discourse/models/composer";import { i18n } from "discourse-i18n";+import DMenu from "float-kit/components/d-menu";export default class PostMenuAddTranslationButton extends Component {@service composer;+ @service modal;@service currentUser;@service siteSettings;@@ -22,6 +27,29 @@ export default class PostMenuAddTranslationButton extends Component {</div>`;}+ get showTranslationButton() {+ return (+ this.currentUser &&+ this.siteSettings.experimental_content_localization &&+ this.currentUser.can_localize_content+ );+ }++ get viewTranslationLabel() {+ return i18n("post.localizations.view", {+ count: this.args.post.post_localizations_count,+ });+ }++ get showAsMenu() {+ return this.args.post.post_localizations_count > 0;+ }++ @action+ viewTranslations() {+ this.modal.show(PostTranslationsModal, { model: { post: this.args.post } });+ }+@actionasync addTranslation() {if (@@ -41,13 +69,54 @@ export default class PostMenuAddTranslationButton extends Component {});}+ @action+ onRegisterApi(api) {+ this.dMenu = api;+ }+<template>- <DButton- class="post-action-menu__add-translation"- @title="post.localizations.add"- @icon="discourse-add-translation"- @action={{this.addTranslation}}- ...attributes- />+ {{#if this.showTranslationButton}}+ {{#if this.showAsMenu}}+ <DMenu+ ...attributes+ @identifier="post-action-menu-edit-translations"+ @triggers={{array "click"}}+ class="update-translations-menu"+ @title={{i18n "post.localizations.add"}}+ @icon="discourse-add-translation"+ @onRegisterApi={{this.onRegisterApi}}+ @arrow={{false}}+ >+ <:content>+ <DropdownMenu as |dropdown|>+ <dropdown.item class="update-translations-menu__view">+ <DButton+ class="post-action-menu__view-translation"+ @translatedLabel={{this.viewTranslationLabel}}+ @icon="eye"+ @action={{this.viewTranslations}}+ />+ </dropdown.item>+ <dropdown.item class="update-translations-menu__add">+ <DButton+ class="post-action-menu__add-translation"+ @label="post.localizations.add"+ @icon="plus"+ @action={{this.addTranslation}}+ />+ </dropdown.item>+ </DropdownMenu>+ </:content>+ </DMenu>+ {{else}}+ <DButton+ class="post-action-menu__add-translation"+ @title="post.localizations.add"+ @icon="discourse-add-translation"+ @action={{this.addTranslation}}+ ...attributes+ />+ {{/if}}+ {{/if}}</template>}diff --git a/app/assets/javascripts/discourse/app/components/post/meta-data.gjs b/app/assets/javascripts/discourse/app/components/post/meta-data.gjsindex 377988243e5..efba4ae0c69 100644--- a/app/assets/javascripts/discourse/app/components/post/meta-data.gjs+++ b/app/assets/javascripts/discourse/app/components/post/meta-data.gjs@@ -10,7 +10,6 @@ import PostMetaDataPosterName from "./meta-data/poster-name";import PostMetaDataReadIndicator from "./meta-data/read-indicator";import PostMetaDataReplyToTab from "./meta-data/reply-to-tab";import PostMetaDataSelectPost from "./meta-data/select-post";-import PostMetaDataTranslationIndicator from "./meta-data/translation-indicator";import PostMetaDataWhisperIndicator from "./meta-data/whisper-indicator";export default class PostMetaData extends Component {@@ -28,13 +27,6 @@ export default class PostMetaData extends Component {return PostMetaDataReplyToTab.shouldRender(this.args, null, getOwner(this));}- get shouldDisplayTranslationIndicator() {- return (- this.currentUser?.can_debug_localizations &&- this.args.post?.has_post_localizations- );- }-get shouldDisplayLanguage() {return this.args.post.is_localized && this.args.post.language;}@@ -46,10 +38,6 @@ export default class PostMetaData extends Component {{{/if}}<div class="post-infos">- {{#if this.shouldDisplayTranslationIndicator}}- <PostMetaDataTranslationIndicator @post={{@post}} />- {{/if}}-{{#if @post.isWhisper}}<PostMetaDataWhisperIndicator @post={{@post}} />{{/if}}diff --git a/app/assets/javascripts/discourse/app/models/post-localization.js b/app/assets/javascripts/discourse/app/models/post-localization.jsindex 25ca6706506..f336bb40123 100644--- a/app/assets/javascripts/discourse/app/models/post-localization.js+++ b/app/assets/javascripts/discourse/app/models/post-localization.js@@ -2,6 +2,15 @@ import { ajax } from "discourse/lib/ajax";import RestModel from "discourse/models/rest";export default class PostLocalization extends RestModel {+ static find(postId) {+ return ajax(`/post_localizations/${postId}`, {+ type: "GET",+ data: {+ post_id: postId,+ },+ });+ }+static createOrUpdate(postId, locale, raw) {return ajax("/post_localizations/create_or_update", {type: "POST",diff --git a/app/assets/stylesheets/common/base/topic-post.scss b/app/assets/stylesheets/common/base/topic-post.scssindex 29f466c0f99..bc3fcffdb8e 100644--- a/app/assets/stylesheets/common/base/topic-post.scss+++ b/app/assets/stylesheets/common/base/topic-post.scss@@ -1008,31 +1008,6 @@ aside.quote {}}-.post-info.translations {- .fk-d-tooltip__trigger {- &-container {- display: flex;- align-items: center;- }-- .translation-count {- padding-right: 0.25em;- }-- .translation-count,- .d-icon {- color: var(--primary-med-or-secondary-med);- }- }-}--.post-meta-data-translation-indicator-content {- ul {- list-style: none;- margin: 0;- }-}-pre {max-height: 2000px;diff --git a/app/assets/stylesheets/common/components/_index.scss b/app/assets/stylesheets/common/components/_index.scssindex 33980625cfc..503df997990 100644--- a/app/assets/stylesheets/common/components/_index.scss+++ b/app/assets/stylesheets/common/components/_index.scss@@ -35,6 +35,7 @@@import "offline-indicator";@import "pick-files-button";@import "powered-by-discourse";+@import "post-translations";@import "relative-time-picker";@import "add-pm-participants";@import "download-calendar";diff --git a/app/assets/stylesheets/common/components/post-translations.scss b/app/assets/stylesheets/common/components/post-translations.scssnew file mode 100644index 00000000000..6c2a73197f1--- /dev/null+++ b/app/assets/stylesheets/common/components/post-translations.scss@@ -0,0 +1,11 @@+.post-translations-modal {+ table {+ width: 100%;+ }+}++.update-translations-menu {+ .d-icon {+ color: var(--quaternary);+ }+}diff --git a/app/controllers/post_localizations_controller.rb b/app/controllers/post_localizations_controller.rbindex ae3a876d647..d7a0827ee19 100644--- a/app/controllers/post_localizations_controller.rb+++ b/app/controllers/post_localizations_controller.rb@@ -3,6 +3,25 @@class PostLocalizationsController < ApplicationControllerbefore_action :ensure_logged_in+ def show+ guardian.ensure_can_localize_content!++ params.require(%i[post_id])+ localizations = PostLocalization.where(post_id: params[:post_id])++ if localizations+ render json:+ ActiveModel::ArraySerializer.new(+ localizations,+ each_serializer: PostLocalizationSerializer,+ root: false,+ ).as_json,+ status: :ok+ else+ render json_error I18n.t("not_found"), status: :not_found+ end+ end+def create_or_updateguardian.ensure_can_localize_content!diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rbindex 27f8486ef32..f2a874ba8f7 100644--- a/app/serializers/current_user_serializer.rb+++ b/app/serializers/current_user_serializer.rb@@ -77,8 +77,7 @@ class CurrentUserSerializer < BasicUserSerializer:has_unseen_features,:can_see_emails,:use_glimmer_post_stream_mode_auto_mode,- :can_localize_content,- :can_debug_localizations+ :can_localize_content?delegate :user_stat, to: :object, private: truedelegate :any_posts, :draft_count, :pending_posts_count, :read_faq?, to: :user_stat@@ -327,13 +326,11 @@ class CurrentUserSerializer < BasicUserSerializerscope.user.in_any_groups?(SiteSetting.glimmer_post_stream_mode_auto_groups_map)end- def can_localize_content- return false if !SiteSetting.experimental_content_localization- scope.user.in_any_groups?(SiteSetting.experimental_content_localization_allowed_groups_map)+ def can_localize_content?+ scope.can_localize_content?end- def can_debug_localizations- return false if !SiteSetting.experimental_content_localization- scope.user.in_any_groups?(SiteSetting.content_localization_debug_allowed_groups_map)+ def include_can_localize_content?+ SiteSetting.experimental_content_localizationendenddiff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rbindex 74dd724764c..89e9921c534 100644--- a/app/serializers/post_serializer.rb+++ b/app/serializers/post_serializer.rb@@ -96,7 +96,7 @@ class PostSerializer < BasicPostSerializer:mentioned_users,:post_url,:has_post_localizations,- :post_localizations,+ :post_localizations_count,:locale,:is_localized,:language@@ -658,12 +658,16 @@ class PostSerializer < BasicPostSerializerobject.post_localizations.any?end- def post_localizations- ActiveModel::ArraySerializer.new(- object.post_localizations,- each_serializer: PostLocalizationSerializer,- root: false,- ).as_json+ def post_localizations_count+ object.post_localizations.count+ end++ def include_has_post_localizations?+ object&.user&.guardian&.can_localize_content?+ end++ def include_post_localizations_count?+ object&.user&.guardian&.can_localize_content?enddef rawdiff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex edfc2728767..2691c2e611c 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -3919,6 +3919,12 @@ en:edit: "Edit"delete: "Delete"add: "Add new translation"+ view:+ one: "View %{count} translated locale"+ other: "View %{count} translated locales"+ modal:+ title: "Translations for post"+ confirm_delete: "Are you sure you want to delete translations for '%{languageCode}'?"success: "Translations have been updated successfully"errors:diff --git a/config/routes.rb b/config/routes.rbindex 85f2b2f6731..577dde79e37 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -1239,6 +1239,7 @@ Discourse::Application.routes.draw doendend+ get "/post_localizations/:id" => "post_localizations#show"post "/post_localizations/create_or_update", to: "post_localizations#create_or_update"delete "/post_localizations/destroy", to: "post_localizations#destroy"diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 9fb0a929ff8..a77b41f71fe 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -4007,13 +4007,6 @@ experimental:client: truedefault: "1|2" # admin, moderatorarea: "localization"- content_localization_debug_allowed_groups:- type: group_list- list_type: compact- allow_any: false- client: true- default: "1|2" # admin, moderator- hidden: trueexperimental_content_localization_supported_locales:default: ""type: listdiff --git a/spec/requests/api/schemas/json/post_show_response.json b/spec/requests/api/schemas/json/post_show_response.jsonindex 30eb04cf686..85ba81115b4 100644--- a/spec/requests/api/schemas/json/post_show_response.json+++ b/spec/requests/api/schemas/json/post_show_response.json@@ -209,13 +209,6 @@"post_url": {"type": "string"},- "has_post_localizations": {- "type": "boolean"- },- "post_localizations": {- "type": "array",- "items": {}- },"mentioned_users": {"type": "array","items": {}diff --git a/spec/serializers/web_hook_post_serializer_spec.rb b/spec/serializers/web_hook_post_serializer_spec.rbindex 8c24a274bd7..618722dd0b7 100644--- a/spec/serializers/web_hook_post_serializer_spec.rb+++ b/spec/serializers/web_hook_post_serializer_spec.rb@@ -56,8 +56,6 @@ RSpec.describe WebHookPostSerializer do:topic_filtered_posts_count,:topic_archetype,:category_slug,- :has_post_localizations,- :post_localizations,)enddiff --git a/spec/system/page_objects/modals/view_translations_modal.rb b/spec/system/page_objects/modals/view_translations_modal.rbnew file mode 100644index 00000000000..be93eb3c0d4--- /dev/null+++ b/spec/system/page_objects/modals/view_translations_modal.rb@@ -0,0 +1,9 @@+# frozen_string_literal: true++module PageObjects+ module Modals+ class ViewTranslationsModal < PageObjects::Modals::Base+ MODAL_SELECTOR = ".post-translations-modal"+ end+ end+enddiff --git a/spec/system/post_translation_spec.rb b/spec/system/post_translation_spec.rbindex 36dd8a075c6..b3044d2b81c 100644--- a/spec/system/post_translation_spec.rb+++ b/spec/system/post_translation_spec.rb@@ -9,6 +9,7 @@ describe "Post translations", type: :system dolet(:translation_selector) doPageObjects::Components::SelectKit.new(".translation-selector-dropdown")end+ let(:view_translations_modal) { PageObjects::Modals::ViewTranslationsModal.new }before dosign_in(user)@@ -19,46 +20,137 @@ describe "Post translations", type: :system do"read|like|copyLink|flag|edit|bookmark|delete|admin|reply|addTranslation"end- it "should only show the languages listed in the site setting" do- topic_page.visit_topic(topic)- find("#post_#{post.post_number} .post-action-menu__add-translation").click- translation_selector.expand- expect(all(".translation-selector-dropdown .select-kit-collection li").count).to eq(4)- expect(translation_selector).to have_option_value("en")- expect(translation_selector).to have_option_value("fr")- expect(translation_selector).to have_option_value("es")- expect(translation_selector).to have_option_value("pt_BR")- expect(translation_selector).to have_no_option_value("de")- end+ context "when a post does not have translations" do+ it "should only show the languages listed in the site setting" do+ topic_page.visit_topic(topic)+ find("#post_#{post.post_number} .post-action-menu__add-translation").click+ translation_selector.expand+ expect(all(".translation-selector-dropdown .select-kit-collection li").count).to eq(4)+ expect(translation_selector).to have_option_value("en")+ expect(translation_selector).to have_option_value("fr")+ expect(translation_selector).to have_option_value("es")+ expect(translation_selector).to have_option_value("pt_BR")+ expect(translation_selector).to have_no_option_value("de")+ end++ it "always includes the site's default locale in the list of available languages" do+ SiteSetting.default_locale = "de"+ topic_page.visit_topic(topic)+ find("#post_#{post.post_number} .post-action-menu__add-translation").click+ translation_selector.expand+ expect(all(".translation-selector-dropdown .select-kit-collection li").count).to eq(5)+ expect(translation_selector).to have_option_value("de")+ end++ it "allows a user to translate a post" do+ topic_page.visit_topic(topic)+ find("#post_#{post.post_number} .post-action-menu__add-translation").click+ expect(composer).to be_opened+ translation_selector.expand+ translation_selector.select_row_by_value("fr")+ find("#translated-topic-title").fill_in(with: "Ceci est un sujet de test 0")+ composer.fill_content("Bonjour le monde")+ composer.submit+ post.reload+ topic.reload- it "always includes the site's default locale in the list of available languages" do- SiteSetting.default_locale = "de"- topic_page.visit_topic(topic)- find("#post_#{post.post_number} .post-action-menu__add-translation").click- translation_selector.expand- expect(all(".translation-selector-dropdown .select-kit-collection li").count).to eq(5)- expect(translation_selector).to have_option_value("de")+ try_until_success do+ expect(TopicLocalization.exists?(topic_id: topic.id, locale: "fr")).to be true+ expect(PostLocalization.exists?(post_id: post.id, locale: "fr")).to be true+ expect(PostLocalization.find_by(post_id: post.id, locale: "fr").raw).to eq(+ "Bonjour le monde",+ )+ expect(TopicLocalization.find_by(topic_id: topic.id, locale: "fr").title).to eq(+ "Ceci est un sujet de test 0",+ )+ end+ endend- it "allows a user to translate a post" do- topic_page.visit_topic(topic)- find("#post_#{post.post_number} .post-action-menu__add-translation").click- expect(composer).to be_opened- translation_selector.expand- translation_selector.select_row_by_value("fr")- find("#translated-topic-title").fill_in(with: "Ceci est un sujet de test 0")- composer.fill_content("Bonjour le monde")- composer.submit- post.reload- topic.reload-- try_until_success do- expect(TopicLocalization.exists?(topic_id: topic.id, locale: "fr")).to be true- expect(PostLocalization.exists?(post_id: post.id, locale: "fr")).to be true- expect(PostLocalization.find_by(post_id: post.id, locale: "fr").raw).to eq("Bonjour le monde")- expect(TopicLocalization.find_by(topic_id: topic.id, locale: "fr").title).to eq(- "Ceci est un sujet de test 0",+ context "when a post already has translations" do+ fab!(:post_localization) do+ Fabricate(:post_localization, post: post, locale: "fr", raw: "Bonjour le monde")+ end+ let(:confirmation_dialog) { PageObjects::Components::Dialog.new }++ it "allows a user to add a new translation" do+ topic_page.visit_topic(topic)+ find("#post_#{post.post_number} .post-action-menu-edit-translations-trigger").click+ find(".update-translations-menu__add .post-action-menu__add-translation").click+ expect(composer).to be_opened+ translation_selector.expand+ translation_selector.select_row_by_value("es")+ find("#translated-topic-title").fill_in(with: "Este es un tema de prueba 0")+ composer.fill_content("Hola mundo")+ composer.submit+ post.reload+ topic.reload++ try_until_success do+ expect(TopicLocalization.exists?(topic_id: topic.id, locale: "es")).to be true+ expect(PostLocalization.exists?(post_id: post.id, locale: "es")).to be true+ expect(PostLocalization.find_by(post_id: post.id, locale: "es").raw).to eq("Hola mundo")+ expect(TopicLocalization.find_by(topic_id: topic.id, locale: "es").title).to eq(+ "Este es un tema de prueba 0",+ )+ end+ end++ it "allows a user to see locales translated" do+ topic_page.visit_topic(topic)+ find("#post_#{post.post_number} .post-action-menu-edit-translations-trigger").click+ view_translation_button = find(".post-action-menu__view-translation")+ expect(view_translation_button).to be_visible+ expect(view_translation_button).to have_text(+ I18n.t("js.post.localizations.view", { count: 1 }),)++ view_translation_button.click+ expect(view_translations_modal).to be_open+ expect(find(".post-translations-modal__locale")).to have_text("fr")+ end++ it "allows a user to edit a translation" do+ topic_page.visit_topic(topic)+ find("#post_#{post.post_number} .post-action-menu-edit-translations-trigger").click+ find(".post-action-menu__view-translation").click+ find(".post-translations-modal__edit-action .btn").click+ expect(composer).to be_opened+ expect(translation_selector).to have_selected_value("fr")+ find("#translated-topic-title").fill_in(with: "C'est un sujet de test 0.")+ composer.fill_content("Bonjour le monde")+ composer.submit+ post.reload+ topic.reload++ try_until_success do+ expect(TopicLocalization.exists?(topic_id: topic.id, locale: "fr")).to be true+ expect(PostLocalization.exists?(post_id: post.id, locale: "fr")).to be true+ expect(PostLocalization.find_by(post_id: post.id, locale: "fr").raw).to eq(+ "Bonjour le monde",+ )+ expect(TopicLocalization.find_by(topic_id: topic.id, locale: "fr").title).to eq(+ "C'est un sujet de test 0.",+ )+ end+ end++ it "allows a user to delete a translation" do+ topic_page.visit_topic(topic)+ expect(PostLocalization.exists?(post_id: post.id, locale: "fr")).to be true++ find("#post_#{post.post_number} .post-action-menu-edit-translations-trigger").click+ find(".post-action-menu__view-translation").click+ find(".post-translations-modal__delete-action .btn").click+ expect(confirmation_dialog).to be_open+ confirmation_dialog.click_yes++ post.reload+ topic.reload++ try_until_success do+ expect(PostLocalization.exists?(post_id: post.id, locale: "fr")).to be false+ endendendend