mirror of
https://ghfast.top/https://github.com/discourse/discourse-translator.git
synced 2026-05-10 19:02:28 +08:00
Doing some cleanup - `experimental_topic_translation` becomes `experimental_inline_translation` - `translator` becomes `translator_provider` - DualText translation is now Parallel Translation (the feature where translation is appended to the post, rather than shown inline) - Unused `translate_posts_to_languages` removed
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
import { render } from "@ember/test-helpers";
|
|
import { hbs } from "ember-cli-htmlbars";
|
|
import { module, test } from "qunit";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
|
|
module("Integration | Component | translated-post", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test("renders translation when post is translated", async function (assert) {
|
|
this.set("outletArgs", {
|
|
post: {
|
|
isTranslated: true,
|
|
isTranslating: false,
|
|
translatedText: "こんにちは",
|
|
translatedTitle: "良い一日",
|
|
detectedLang: "ja",
|
|
},
|
|
});
|
|
|
|
this.siteSettings.experimental_inline_translation = false;
|
|
this.siteSettings.translator_provider = "Google";
|
|
|
|
await render(hbs`
|
|
<TranslatedPost @outletArgs={{this.outletArgs}} />
|
|
`);
|
|
|
|
assert.dom(".post-translation").exists();
|
|
assert.dom(".topic-attribution").hasText("良い一日");
|
|
assert.dom(".post-attribution").hasText("Translated from ja by Google");
|
|
assert.dom(".cooked").hasText("こんにちは");
|
|
});
|
|
|
|
test("hides translation when experimental_inline_translation is enabled", async function (assert) {
|
|
this.set("outletArgs", {
|
|
post: {
|
|
isTranslated: true,
|
|
isTranslating: false,
|
|
translatedText: "Bonjour monde",
|
|
},
|
|
});
|
|
|
|
this.siteSettings.experimental_inline_translation = true;
|
|
|
|
await render(hbs`
|
|
<TranslatedPost @outletArgs={{this.outletArgs}} />
|
|
`);
|
|
|
|
assert.dom(".topic-attribution").doesNotExist();
|
|
assert.dom(".post-attribution").doesNotExist();
|
|
});
|
|
});
|