DEV: Spec didn't work correctly with translations (#429)
This commit is contained in:
parent
14020e7095
commit
8eb1e851fc
|
@ -58,26 +58,45 @@ RSpec.describe DiscourseAi::Admin::AiPersonasController do
|
||||||
expect(serializer_persona2["commands"]).to eq([["SearchCommand", { "base_query" => "test" }]])
|
expect(serializer_persona2["commands"]).to eq([["SearchCommand", { "base_query" => "test" }]])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns localized persona names and descriptions" do
|
context "with translations" do
|
||||||
SiteSetting.default_locale = "fr"
|
before do
|
||||||
|
SiteSetting.default_locale = "fr"
|
||||||
|
|
||||||
get "/admin/plugins/discourse-ai/ai_personas.json"
|
TranslationOverride.upsert!(
|
||||||
|
SiteSetting.default_locale,
|
||||||
|
"discourse_ai.ai_bot.personas.general.name",
|
||||||
|
"Général",
|
||||||
|
)
|
||||||
|
TranslationOverride.upsert!(
|
||||||
|
SiteSetting.default_locale,
|
||||||
|
"discourse_ai.ai_bot.personas.general.description",
|
||||||
|
"Général Description",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
TranslationOverride.upsert!(:fr, "discourse_ai.ai_bot.personas.general.name", "Général")
|
after do
|
||||||
TranslationOverride.upsert!(
|
TranslationOverride.revert!(
|
||||||
:fr,
|
SiteSetting.default_locale,
|
||||||
"discourse_ai.ai_bot.personas.general.description",
|
"discourse_ai.ai_bot.personas.general.name",
|
||||||
"Général Description",
|
)
|
||||||
)
|
TranslationOverride.revert!(
|
||||||
|
SiteSetting.default_locale,
|
||||||
|
"discourse_ai.ai_bot.personas.general.description",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
id =
|
it "returns localized persona names and descriptions" do
|
||||||
DiscourseAi::AiBot::Personas::Persona.system_personas[DiscourseAi::AiBot::Personas::General]
|
get "/admin/plugins/discourse-ai/ai_personas.json"
|
||||||
name = I18n.t("discourse_ai.ai_bot.personas.general.name")
|
|
||||||
description = I18n.t("discourse_ai.ai_bot.personas.general.description")
|
|
||||||
persona = response.parsed_body["ai_personas"].find { |p| p["id"] == id }
|
|
||||||
|
|
||||||
expect(persona["name"]).to eq(name)
|
id =
|
||||||
expect(persona["description"]).to eq(description)
|
DiscourseAi::AiBot::Personas::Persona.system_personas[
|
||||||
|
DiscourseAi::AiBot::Personas::General
|
||||||
|
]
|
||||||
|
persona = response.parsed_body["ai_personas"].find { |p| p["id"] == id }
|
||||||
|
|
||||||
|
expect(persona["name"]).to eq("Général")
|
||||||
|
expect(persona["description"]).to eq("Général Description")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue