Skip to content

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

Fix tests

Pacu2f42c23d340a8
diff --git a/saleor/dashboard/staff/forms.py b/saleor/dashboard/staff/forms.py
index cbb89d9b82..0702d489df 100644
--- a/saleor/dashboard/staff/forms.py
+++ b/saleor/dashboard/staff/forms.py
@@ -9,7 +9,7 @@ from ..forms import PermissionMultipleChoiceField
class StaffForm(forms.ModelForm):
user_permissions = PermissionMultipleChoiceField(
queryset=get_permissions(),
- widget=forms.CheckboxSelectMultiple,
+ widget=forms.CheckboxSelectMultiple, required=False,
label=pgettext_lazy(
'Label above the permissions choicefield', 'Permissions'))
diff --git a/tests/dashboard/test_staff.py b/tests/dashboard/test_staff.py
index 88ac206e46..a41852f220 100644
--- a/tests/dashboard/test_staff.py
+++ b/tests/dashboard/test_staff.py
@@ -31,7 +31,7 @@ def test_staff_form_create_valid(
def test_staff_form_create_not_valid(admin_client, staff_user):
url = reverse('dashboard:staff-details', kwargs={'pk': staff_user.pk})
- data = {'user_permissions': 1}
+ data = {'csrf': 'examplecsfr'}
admin_client.post(url, data)
staff_user = User.objects.get(pk=staff_user.pk)
assert staff_user.user_permissions.count() == 0
@@ -143,9 +143,12 @@ def test_create_staff_and_set_password(admin_client):
assert new_user.has_usable_password()
-def test_create_staff_from_customer(admin_client, customer_user):
+def test_create_staff_from_customer(
+ admin_client, customer_user, permission_view_product):
url = reverse('dashboard:staff-create')
- data = {'email': customer_user.email}
+ data = {
+ 'email': customer_user.email,
+ 'user_permissions': permission_view_product.pk}
admin_client.post(url, data)
customer_user.refresh_from_db()
assert customer_user.is_staff