Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add a missing test

Ania Warzechace60a2304c3e
diff --git a/saleor/graphql/translations/tests/mutations/test_attribute_value_bulk_transalte.py b/saleor/graphql/translations/tests/mutations/test_attribute_value_bulk_transalte.py
index 5bcfcf363e..177fb937b1 100644
--- a/saleor/graphql/translations/tests/mutations/test_attribute_value_bulk_transalte.py
+++ b/saleor/graphql/translations/tests/mutations/test_attribute_value_bulk_transalte.py
@@ -45,7 +45,7 @@ def test_attribute_value_bulk_translate_creates_translations(
# given
value = color_attribute.values.first()
value_global_id = graphene.Node.to_global_id("AttributeValue", value.id)
- expected_text = "Nowy Kolor" * 250
+ expected_text = "Nowy Kolor"
expected_rich_text = json.dumps(dummy_editorjs(expected_text))
assert value.translations.count() == 0
@@ -94,6 +94,52 @@ def test_attribute_value_bulk_translate_creates_translations(
assert created_webhook_mock.call_count == 2
+@patch("saleor.plugins.manager.PluginsManager.translation_created")
+def test_attribute_value_bulk_translate_creates_name_from_translations_long_text(
+ created_webhook_mock,
+ staff_api_client,
+ plain_text_attribute,
+ permission_manage_translations,
+ settings,
+):
+ # given
+ value = plain_text_attribute.values.first()
+ value_global_id = graphene.Node.to_global_id("AttributeValue", value.id)
+ expected_text = "Nowy Kolor" * 250
+ expected_rich_text = json.dumps(dummy_editorjs(expected_text))
+
+ assert value.translations.count() == 0
+
+ translations = [
+ {
+ "id": value_global_id,
+ "languageCode": LanguageCodeEnum.PL.name,
+ "translationFields": {
+ "plainText": expected_text,
+ },
+ },
+ ]
+
+ # when
+ staff_api_client.user.user_permissions.add(permission_manage_translations)
+ response = staff_api_client.post_graphql(
+ ATTRIBUTE_VALUE_BULK_TRANSLATE_MUTATION,
+ {"translations": translations},
+ )
+ content = get_graphql_content(response)
+ data = content["data"]["attributeValueBulkTranslate"]
+ print(data["results"][0]["translation"])
+
+ # then
+ assert value.translations.count() == 1
+ assert not data["results"][0]["errors"]
+ assert data["count"] == 1
+ assert data["results"][0]["translation"]["name"] == expected_text[:249] + "…"
+ assert data["results"][0]["translation"]["plainText"] == expected_text
+ assert data["results"][0]["translation"]["richText"] == expected_rich_text
+ assert created_webhook_mock.call_count == 1
+
+
@patch("saleor.plugins.manager.PluginsManager.translation_updated")
def test_attribute_value_bulk_translate_updates_translations(
updated_webhook_mock,