diff --git a/package-lock.json b/package-lock.json index a9a8536..648c3ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -84,7 +84,7 @@ }, "node_modules/playwright-fixture-for-plugins": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/sequra/playwright-fixture-for-plugins.git#8a5b728005cf1a45ebae5f58669d6899650a2e81", + "resolved": "git+ssh://git@github.com/sequra/playwright-fixture-for-plugins.git#88eb10738a3ba07075a18cac4aa28aa030ed1e7b", "dev": true }, "node_modules/undici-types": { diff --git a/playwright.config.js b/playwright.config.js index 604f6fb..10d49a2 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -55,6 +55,11 @@ export default defineConfig({ use: { ...devices['Desktop Chrome'] }, testMatch: '006-configuration-general.spec.js', }, + { + name: 'configuration-connection', + use: { ...devices['Desktop Chrome'] }, + testMatch: '007-configuration-connection.spec.js', + }, ], }); diff --git a/tests-e2e/fixtures/test.js b/tests-e2e/fixtures/test.js index b38d0e1..a26fcf3 100644 --- a/tests-e2e/fixtures/test.js +++ b/tests-e2e/fixtures/test.js @@ -1,5 +1,5 @@ import { test as baseTest, expect } from "@playwright/test"; -import { DataProvider, GeneralSettingsPage, PaymentMethodsSettingsPage } from "playwright-fixture-for-plugins"; +import { ConnectionSettingsPage, DataProvider, GeneralSettingsPage, OnboardingSettingsPage, PaymentMethodsSettingsPage } from "playwright-fixture-for-plugins"; import BackOffice from "./base/BackOffice"; import SeQuraHelper from "./utils/SeQuraHelper"; import ProductPage from "./pages/ProductPage"; @@ -11,8 +11,10 @@ const test = baseTest.extend({ helper: async ({ page, baseURL, request }, use) => await use(new SeQuraHelper(page, baseURL, expect, request)), paymentMethodsSettingsPage: async ({ page, baseURL, request, backOffice, helper}, use) => await use(new PaymentMethodsSettingsPage(page, baseURL, expect, request, backOffice, helper)), productPage: async ({ page, baseURL, request}, use) => await use(new ProductPage(page, baseURL, expect, request)), + onboardingSettingsPage: async ({ page, baseURL, request, backOffice, helper}, use) => await use(new OnboardingSettingsPage(page, baseURL, expect, request, backOffice, helper)), checkoutPage: async ({ page, baseURL, request}, use) => await use(new CheckoutPage(page, baseURL, expect, request)), generalSettingsPage: async ({ page, baseURL, request, backOffice, helper}, use) => await use(new GeneralSettingsPage(page, baseURL, expect, request, backOffice, helper)), + connectionSettingsPage: async ({ page, baseURL, request, backOffice, helper}, use) => await use(new ConnectionSettingsPage(page, baseURL, expect, request, backOffice, helper)), }); test.afterEach(async ({ page }, testInfo) => { diff --git a/tests-e2e/specs/007-configuration-connection.spec.js b/tests-e2e/specs/007-configuration-connection.spec.js new file mode 100644 index 0000000..20e3a9b --- /dev/null +++ b/tests-e2e/specs/007-configuration-connection.spec.js @@ -0,0 +1,67 @@ +import { test } from '../fixtures/test'; + +test.describe('Connection settings', () => { + + test('Disconnect', async ({ helper, connectionSettingsPage }) => { + // Setup + const { clear_config, dummy_config } = helper.webhooks; + // await helper.executeWebhook({ webhook: clear_config }); // Clear the configuration. + await helper.executeWebhook({ webhook: dummy_config }); // Setup for physical products. + + // Execution + await connectionSettingsPage.goto(); + await connectionSettingsPage.expectLoadingShowAndHide(); + await connectionSettingsPage.disconnect(); + }); + + test('Change', async ({ helper, page, connectionSettingsPage }) => { + // Setup + const { clear_config, dummy_config } = helper.webhooks; + // await helper.executeWebhook({ webhook: clear_config }); // Clear the configuration. + await helper.executeWebhook({ webhook: dummy_config }); // Setup for physical products. + + const credentials = { + username: process.env.SQ_USER_NAME, + password: process.env.SQ_USER_SECRET, + env: 'sandbox' + }; + + const credentialsForServices = { + ...credentials, + username: process.env.SQ_USER_SERVICES_NAME, + password: process.env.SQ_USER_SERVICES_SECRET + }; + + const wrongSandboxCredentials = { ...credentials, password: '1234' }; + const wrongLiveCredentials = { ...credentials, env: 'live' }; + + // Execution + await connectionSettingsPage.goto(); + await connectionSettingsPage.expectLoadingShowAndHide(); + + // Test cancellation of the changes + await connectionSettingsPage.fillForm(wrongSandboxCredentials); + await connectionSettingsPage.cancel(); + await connectionSettingsPage.expectFormToHaveValues(credentials); + + // Test wrong values keeping env in sandbox. + await connectionSettingsPage.fillForm(wrongSandboxCredentials); + await connectionSettingsPage.save(); + await connectionSettingsPage.expectCredentialsErrorToBeVisible(); + + // Test wrong values changing env to live. + await page.reload(); + await connectionSettingsPage.expectLoadingShowAndHide(); + await connectionSettingsPage.fillForm(wrongLiveCredentials); + await connectionSettingsPage.save({ expectLoadingShowAndHide: false }); + await connectionSettingsPage.confirmModal(); + await connectionSettingsPage.expectCredentialsErrorToBeVisible(); + + // Test valid values. + await page.reload(); + await connectionSettingsPage.expectLoadingShowAndHide(); + await connectionSettingsPage.fillForm(credentialsForServices); + await connectionSettingsPage.save({ expectLoadingShowAndHide: true }); + await page.waitForURL(/#onboarding-countries/); + }); +}); \ No newline at end of file