Skip to content

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

Add initial test

Adam Janikbe4861c926c5
diff --git a/tests/api/test_page.py b/tests/api/test_page.py
index 7f28fd33bb..5064debf2a 100644
--- a/tests/api/test_page.py
+++ b/tests/api/test_page.py
@@ -210,3 +210,27 @@ def test_paginate_pages(user_api_client, page):
content = get_graphql_content(response)
pages_data = content['data']['pages']
assert len(pages_data['edges']) == 2
+
+
+def test_bulk_publish(staff_api_client, page_list, permission_manage_pages):
+ assert len(page_list) == 2
+ assert not any(page.is_published for page in page_list)
+
+ query = """
+ mutation publishManyPages((ids: [ID]!) {
+ pageBulkPublish(ids: $ids) {
+ count
+ }
+ }
+ """
+ variables = {'ids': [
+ graphene.Node.to_global_id('Page', page.id)
+ for page in page_list]}
+ response = staff_api_client.post_graphql(
+ query, variables, permissions=[permission_manage_pages])
+ content = get_graphql_content(response)
+
+ map(Page.refresh_from_db, page_list)
+ assert content['data']['pageBulkPublish']['count'] == 2
+ assert all(page.is_published for page in page_list)
+
diff --git a/tests/conftest.py b/tests/conftest.py
index dd86d2743b..9dee89071a 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -751,6 +751,20 @@ def page(db):
page = Page.objects.create(**data)
return page
+def page_list(db):
+ data_1 = {
+ 'slug': 'test-url',
+ 'title': 'Test page',
+ 'content': 'test content'}
+ data_2 = {
+ 'slug': 'test-url-2',
+ 'title': 'Test page',
+ 'content': 'test content'}
+ page_1 = Page.objects.create(**data_1)
+ page_2 = Page.objects.create(**data_2)
+ return page_1, page_2
+
@pytest.fixture
def model_form_class():