Skip to content

Commit

Permalink
Add connection settings tests and update related configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
mescalantea committed Feb 7, 2025
1 parent 7b94bc6 commit c4e7f1b
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
],
});

4 changes: 3 additions & 1 deletion tests-e2e/fixtures/test.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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) => {
Expand Down
67 changes: 67 additions & 0 deletions tests-e2e/specs/007-configuration-connection.spec.js
Original file line number Diff line number Diff line change
@@ -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/);
});
});

0 comments on commit c4e7f1b

Please sign in to comment.