Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
[TEST] Should be able to login before email confirmation CORE_1510 (#14676)
Renataee63a38d37f2
diff --git a/saleor/tests/e2e/account/test_should_create_account_without_email_confirmation.py b/saleor/tests/e2e/account/test_should_create_account_without_email_confirmation.pyindex 734457da86..7391461bcb 100644--- a/saleor/tests/e2e/account/test_should_create_account_without_email_confirmation.py+++ b/saleor/tests/e2e/account/test_should_create_account_without_email_confirmation.py@@ -28,6 +28,7 @@ def test_should_create_account_without_email_confirmation_core_1502(test_email = "[email protected]"test_password = "password!"+ redirect_url = ""# Step 1 - Create account for the new customeruser_account = account_register(@@ -35,13 +36,14 @@ def test_should_create_account_without_email_confirmation_core_1502(test_email,test_password,channel_slug,+ redirect_url,)- user_id = user_account["id"]- assert user_account["isActive"] is True+ user_id = user_account["user"]["id"]+ assert user_account["user"]["isActive"] is True# Step 2 - Authenticate as new created userlogin_data = token_create(e2e_not_logged_api_client, test_email, test_password)- assert login_data["id"] == user_id- assert login_data["email"] == test_email+ assert login_data["user"]["id"] == user_id+ assert login_data["user"]["email"] == test_emaildiff --git a/saleor/tests/e2e/account/test_should_login_before_email_confirmation.py b/saleor/tests/e2e/account/test_should_login_before_email_confirmation.pynew file mode 100644index 0000000000..974de7dd04--- /dev/null+++ b/saleor/tests/e2e/account/test_should_login_before_email_confirmation.py@@ -0,0 +1,53 @@+import pytest++from ..channel.utils import create_channel+from ..shop.utils import update_shop_settings+from ..utils import assign_permissions+from .utils import account_register, token_create+++def test_should_login_before_email_confirmation_core_1510(+ e2e_not_logged_api_client,+ e2e_staff_api_client,+ permission_manage_channels,+ permission_manage_settings,+):+ # Before+ permissions = [permission_manage_channels, permission_manage_settings]+ assign_permissions(e2e_staff_api_client, permissions)++ channel_data = create_channel(e2e_staff_api_client)+ channel_slug = channel_data["slug"]++ input_data = {+ "enableAccountConfirmationByEmail": True,+ "allowLoginWithoutConfirmation": True,+ }++ update_shop_settings(e2e_staff_api_client, input_data)++ test_email = "[email protected]"+ test_password = "Password!"+ redirect_url = "https://www.example.com"++ # Step 1 - Create account for the new customer+ user_account = account_register(+ e2e_not_logged_api_client,+ test_email,+ test_password,+ channel_slug,+ redirect_url,+ )++ user_id = user_account["user"]["id"]+ assert user_account["user"]["isActive"] is True+ assert user_account["requiresConfirmation"] is True++ # Step 2 - Login++ login_data = token_create(e2e_not_logged_api_client, test_email, test_password)++ assert login_data["user"]["id"] == user_id+ assert login_data["user"]["isActive"] is True+ assert login_data["user"]["isConfirmed"] is Falsediff --git a/saleor/tests/e2e/account/test_should_not_be_able_to_create_account_with_existing_email.py b/saleor/tests/e2e/account/test_should_not_be_able_to_create_account_with_existing_email.pyindex b122f0166c..4c38ef2d54 100644--- a/saleor/tests/e2e/account/test_should_not_be_able_to_create_account_with_existing_email.py+++ b/saleor/tests/e2e/account/test_should_not_be_able_to_create_account_with_existing_email.py@@ -36,9 +36,9 @@ def test_should_not_be_able_to_create_account_with_existing_email_core_1503(user_password,channel_slug,)- user_id = user_account["id"]+ user_id = user_account["user"]["id"]assert user_id is not None- assert user_account["isActive"] is True+ assert user_account["user"]["isActive"] is True# Step 2 - Create a new account with the same email addressnew_password = "Password1!"diff --git a/saleor/tests/e2e/account/test_should_not_be_able_to_login_with_invalid_credentials.py b/saleor/tests/e2e/account/test_should_not_be_able_to_login_with_invalid_credentials.pyindex cb702515d0..546fdd44f0 100644--- a/saleor/tests/e2e/account/test_should_not_be_able_to_login_with_invalid_credentials.py+++ b/saleor/tests/e2e/account/test_should_not_be_able_to_login_with_invalid_credentials.py@@ -36,9 +36,9 @@ def test_should_not_be_able_to_login_with_invalid_credentials_core_1506(user_password,channel_slug,)- user_id = user_account["id"]+ user_id = user_account["user"]["id"]assert user_id is not None- assert user_account["isActive"] is True+ assert user_account["user"]["isActive"] is True# Step 2 - Login with invalid passwordinvalid_password = "password"diff --git a/saleor/tests/e2e/account/utils/account_register.py b/saleor/tests/e2e/account/utils/account_register.pyindex d959e95b78..df3eb27da8 100644--- a/saleor/tests/e2e/account/utils/account_register.py+++ b/saleor/tests/e2e/account/utils/account_register.py@@ -24,12 +24,14 @@ def raw_account_register(email,password,channel_slug,+ redirect_url=None,):variables = {"input": {"email": email,"password": password,"channel": channel_slug,+ "redirectUrl": redirect_url,}}@@ -47,17 +49,19 @@ def account_register(email,password,channel_slug,+ redirect_url=None,):response = raw_account_register(e2e_not_logged_api_client,email,password,channel_slug,+ redirect_url,)assert response["data"]["accountRegister"]["errors"] == []- data = response["data"]["accountRegister"]["user"]- assert data["id"] is not None- assert data["email"] == email+ data = response["data"]["accountRegister"]+ assert data["user"]["id"] is not None+ assert data["user"]["email"] == emailreturn datadiff --git a/saleor/tests/e2e/account/utils/token_create.py b/saleor/tests/e2e/account/utils/token_create.pyindex fdec2ed886..024f03e929 100644--- a/saleor/tests/e2e/account/utils/token_create.py+++ b/saleor/tests/e2e/account/utils/token_create.py@@ -13,6 +13,8 @@ mutation TokenCreate($email: String!, $password: String!) {user {id+ isActive+ isConfirmed}}}@@ -44,14 +46,14 @@ def token_create(email,password,)+ data = response["data"]["tokenCreate"]+ assert data["errors"] == []- assert response["data"]["tokenCreate"]["errors"] == []+ assert data["token"] is not None+ assert data["refreshToken"] is not None- assert response["data"]["tokenCreate"]["token"] is not None- assert response["data"]["tokenCreate"]["refreshToken"] is not None-- data = response["data"]["tokenCreate"]["user"]- assert data["id"] is not None- assert data["email"] == email+ user = data["user"]+ assert user["id"] is not None+ assert user["email"] == emailreturn data