test: add applications settings tests

This commit is contained in:
Jakub P.
2024-09-10 22:00:49 +02:00
committed by Ali BARIN
parent e146793d32
commit 09b2b7350c
14 changed files with 407 additions and 31 deletions

View File

@@ -0,0 +1,40 @@
import { expect } from '@playwright/test';
const { AuthenticatedPage } = require('../authenticated-page');
export class AdminApplicationAuthClientsPage extends AuthenticatedPage {
/**
* @param {import('@playwright/test').Page} page
*/
constructor(page) {
super(page);
this.authClientsTab = this.page.getByText('AUTH CLIENTS');
this.saveButton = this.page.getByTestId('submitButton');
this.successSnackbar = this.page.getByTestId('snackbar-save-admin-apps-settings-success');
this.createFirstAuthClientButton = this.page.getByTestId('no-results');
this.createAuthClientButton = this.page.getByTestId('create-auth-client-button');
this.submitAuthClientFormButton = this.page.getByTestId('submit-auth-client-form');
this.authClientEntry = this.page.getByTestId('auth-client');
}
async openAuthClientsTab() {
this.authClientsTab.click();
}
async openFirstAuthClientCreateForm() {
this.createFirstAuthClientButton.click();
}
async openAuthClientCreateForm() {
this.createAuthClientButton.click();
}
async submitAuthClientForm() {
this.submitAuthClientFormButton.click();
}
async authClientShouldBeVisible(authClientName) {
await expect(this.authClientEntry.filter({ hasText: authClientName })).toBeVisible();
}
}

View File

@@ -0,0 +1,59 @@
const { AuthenticatedPage } = require('../authenticated-page');
const { expect } = require('@playwright/test');
export class AdminApplicationSettingsPage extends AuthenticatedPage {
/**
* @param {import('@playwright/test').Page} page
*/
constructor(page) {
super(page);
this.allowCustomConnectionsSwitch = this.page.locator('[name="allowCustomConnection"]');
this.allowSharedConnectionsSwitch = this.page.locator('[name="shared"]');
this.disableConnectionsSwitch = this.page.locator('[name="disabled"]');
this.saveButton = this.page.getByTestId('submit-button');
this.successSnackbar = this.page.getByTestId('snackbar-save-admin-apps-settings-success');
}
async allowCustomConnections() {
await expect(this.disableConnectionsSwitch).not.toBeChecked();
await this.allowCustomConnectionsSwitch.check();
await this.saveButton.click();
}
async allowSharedConnections() {
await expect(this.disableConnectionsSwitch).not.toBeChecked();
await this.allowSharedConnectionsSwitch.check();
await this.saveButton.click();
}
async disallowConnections() {
await expect(this.disableConnectionsSwitch).not.toBeChecked();
await this.disableConnectionsSwitch.check();
await this.saveButton.click();
}
async disallowCustomConnections() {
await expect(this.disableConnectionsSwitch).toBeChecked();
await this.allowCustomConnectionsSwitch.uncheck();
await this.saveButton.click();
}
async disallowSharedConnections() {
await expect(this.disableConnectionsSwitch).toBeChecked();
await this.allowSharedConnectionsSwitch.uncheck();
await this.saveButton.click();
}
async allowConnections() {
await expect(this.disableConnectionsSwitch).toBeChecked();
await this.disableConnectionsSwitch.uncheck();
await this.saveButton.click();
}
async expectSuccessSnackbarToBeVisible() {
await expect(this.successSnackbar).toHaveCount(1);
await this.successSnackbar.click();
await expect(this.successSnackbar).toHaveCount(0);
}
}

View File

@@ -0,0 +1,32 @@
const { AuthenticatedPage } = require('../authenticated-page');
export class AdminApplicationsPage extends AuthenticatedPage {
screenshotPath = '/admin-settings/apps';
/**
* @param {import('@playwright/test').Page} page
*/
constructor(page) {
super(page);
this.searchInput = page.locator('[id="search-input"]');
this.appRow = page.getByTestId('app-row');
this.appsDrawerLink = page.getByTestId('apps-drawer-link');
this.appsLoader = page.getByTestId('apps-loader');
}
async openApplication(appName) {
await this.searchInput.fill(appName);
await this.appRow.locator(this.page.getByText(appName)).click();
}
async navigateTo() {
await this.profileMenuButton.click();
await this.adminMenuItem.click();
await this.appsDrawerLink.click();
await this.isMounted();
await this.appsLoader.waitFor({
state: 'detached',
});
}
}

View File

@@ -6,6 +6,10 @@ const { AdminRolesPage } = require('./roles-page');
const { AdminCreateRolePage } = require('./create-role-page');
const { AdminEditRolePage } = require('./edit-role-page');
const { AdminApplicationsPage } = require('./applications-page');
const { AdminApplicationSettingsPage } = require('./application-settings-page');
const { AdminApplicationAuthClientsPage } = require('./application-auth-clients-page');
export const adminFixtures = {
adminUsersPage: async ({ page }, use) => {
await use(new AdminUsersPage(page));
@@ -13,17 +17,26 @@ export const adminFixtures = {
adminCreateUserPage: async ({ page }, use) => {
await use(new AdminCreateUserPage(page));
},
adminEditUserPage: async ({page}, use) => {
adminEditUserPage: async ({ page }, use) => {
await use(new AdminEditUserPage(page));
},
adminRolesPage: async ({ page}, use) => {
adminRolesPage: async ({ page }, use) => {
await use(new AdminRolesPage(page));
},
adminEditRolePage: async ({ page}, use) => {
adminEditRolePage: async ({ page }, use) => {
await use(new AdminEditRolePage(page));
},
adminCreateRolePage: async ({ page}, use) => {
adminCreateRolePage: async ({ page }, use) => {
await use(new AdminCreateRolePage(page));
},
adminApplicationsPage: async ({ page }, use) => {
await use(new AdminApplicationsPage(page));
},
adminApplicationSettingsPage: async ({ page }, use) => {
await use(new AdminApplicationSettingsPage(page));
},
adminApplicationAuthClientsPage: async ({ page }, use) => {
await use(new AdminApplicationAuthClientsPage(page));
}
};

View File

@@ -30,6 +30,8 @@ export class FlowEditorPage extends AuthenticatedPage {
this.flowNameInput = this.page
.getByTestId('editableTypographyInput')
.locator('input');
this.flowStep = this.page.getByTestId('flow-step');
}
async createWebhookTrigger(workSynchronously) {
@@ -68,11 +70,11 @@ export class FlowEditorPage extends AuthenticatedPage {
}
async chooseAppAndEvent(appName, eventName) {
await expect(this.appAutocomplete).toHaveCount(1);
await this.appAutocomplete.click();
await this.page.getByRole('option', { name: appName }).click();
await expect(this.eventAutocomplete).toBeVisible();
await this.eventAutocomplete.click();
await expect(this.page.locator('[data-testid="ErrorIcon"]')).toHaveCount(2);
await Promise.all([
this.page.waitForResponse(resp => /(apps\/.*\/actions\/.*\/substeps)/.test(resp.url()) && resp.status() === 200),
this.page.getByRole('option', { name: eventName }).click(),

View File

@@ -1,6 +1,9 @@
const { Client } = require('pg');
const { Pool } = require('pg');
const client = new Client({
const pool = new Pool({
max: 20,
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 2000,
host: process.env.POSTGRES_HOST,
user: process.env.POSTGRES_USERNAME,
port: process.env.POSTGRES_PORT,
@@ -8,4 +11,4 @@ const client = new Client({
database: process.env.POSTGRES_DATABASE
});
exports.client = client;
exports.pgPool = pool;