Skip to content

Commit

Permalink
Add test for updating seo_description
Browse files Browse the repository at this point in the history
  • Loading branch information
szdrasiak committed Apr 18, 2023
1 parent 13ab13a commit 111f83e
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion saleor/graphql/product/tests/mutations/test_product_update.py
Expand Up @@ -278,7 +278,7 @@ def test_update_product_doesnt_clear_description_plaintext_when_no_description(
assert product.description_plaintext == description_plaintext


def test_update_product_seo_fields(
def test_update_product_seo_field_title(
staff_api_client,
non_default_category,
product,
Expand Down Expand Up @@ -316,6 +316,44 @@ def test_update_product_seo_fields(
assert product.seo_title == new_seo_title


def test_update_product_seo_field_description(
staff_api_client,
non_default_category,
product,
other_description_json,
permission_manage_products,
color_attribute,
):
query = MUTATION_UPDATE_PRODUCT
old_seo_title = "old_seo_title"
product.seo_description = "old seo description"
product.seo_title = old_seo_title
product.save(update_fields=["seo_description", "seo_title"])

product_id = graphene.Node.to_global_id("Product", product.pk)
new_seo_description = "new_seo_description"

variables = {
"productId": product_id,
"input": {
"seo": {
"description": new_seo_description,
},
},
}

response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products]
)
content = get_graphql_content(response)
data = content["data"]["productUpdate"]
assert not data["errors"]

product.refresh_from_db()
assert product.seo_description == new_seo_description
assert product.seo_title == old_seo_title


@patch("saleor.plugins.manager.PluginsManager.product_updated")
def test_update_product_with_boolean_attribute_value(
updated_webhook_mock,
Expand Down

0 comments on commit 111f83e

Please sign in to comment.