Merge branch 'main' into AUT-1372
This commit is contained in:
@@ -2,19 +2,25 @@ import { expect } from '@playwright/test';
|
||||
|
||||
const { AuthenticatedPage } = require('../authenticated-page');
|
||||
|
||||
export class AdminApplicationAuthClientsPage extends AuthenticatedPage {
|
||||
export class AdminApplicationOAuthClientsPage extends AuthenticatedPage {
|
||||
/**
|
||||
* @param {import('@playwright/test').Page} page
|
||||
*/
|
||||
constructor(page) {
|
||||
super(page);
|
||||
|
||||
this.authClientsTab = this.page.getByText('AUTH CLIENTS');
|
||||
this.authClientsTab = this.page.getByTestId('oauth-clients-tab');
|
||||
this.saveButton = this.page.getByTestId('submitButton');
|
||||
this.successSnackbar = this.page.getByTestId('snackbar-save-admin-apps-settings-success');
|
||||
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.createAuthClientButton = this.page.getByTestId(
|
||||
'create-auth-client-button'
|
||||
);
|
||||
this.submitAuthClientFormButton = this.page.getByTestId(
|
||||
'submit-auth-client-form'
|
||||
);
|
||||
this.authClientEntry = this.page.getByTestId('auth-client');
|
||||
}
|
||||
|
||||
@@ -35,6 +41,8 @@ export class AdminApplicationAuthClientsPage extends AuthenticatedPage {
|
||||
}
|
||||
|
||||
async authClientShouldBeVisible(authClientName) {
|
||||
await expect(this.authClientEntry.filter({ hasText: authClientName })).toBeVisible();
|
||||
await expect(
|
||||
this.authClientEntry.filter({ hasText: authClientName })
|
||||
).toBeVisible();
|
||||
}
|
||||
}
|
||||
@@ -8,66 +8,45 @@ export class AdminApplicationSettingsPage extends AuthenticatedPage {
|
||||
constructor(page) {
|
||||
super(page);
|
||||
|
||||
this.allowCustomConnectionsSwitch = this.page.locator(
|
||||
'[name="customConnectionAllowed"]'
|
||||
this.useOnlyPredefinedAuthClients = page.locator(
|
||||
'[name="useOnlyPredefinedAuthClients"]'
|
||||
);
|
||||
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(
|
||||
this.disableConnectionsSwitch = page.locator('[name="disabled"]');
|
||||
this.saveButton = page.getByTestId('submit-button');
|
||||
this.successSnackbar = page.getByTestId(
|
||||
'snackbar-save-admin-apps-settings-success'
|
||||
);
|
||||
}
|
||||
|
||||
async allowCustomConnections() {
|
||||
await expect(this.allowCustomConnectionsSwitch).not.toBeChecked();
|
||||
await this.allowCustomConnectionsSwitch.check();
|
||||
await expect(this.allowCustomConnectionsSwitch).toBeChecked();
|
||||
await this.saveButton.click();
|
||||
async allowUseOnlyPredefinedAuthClients() {
|
||||
await expect(this.useOnlyPredefinedAuthClients).not.toBeChecked();
|
||||
await this.useOnlyPredefinedAuthClients.check();
|
||||
}
|
||||
|
||||
async allowSharedConnections() {
|
||||
await expect(this.allowSharedConnectionsSwitch).not.toBeChecked();
|
||||
await this.allowSharedConnectionsSwitch.check();
|
||||
await expect(this.allowSharedConnectionsSwitch).toBeChecked();
|
||||
await this.saveButton.click();
|
||||
async disallowUseOnlyPredefinedAuthClients() {
|
||||
await expect(this.useOnlyPredefinedAuthClients).toBeChecked();
|
||||
await this.useOnlyPredefinedAuthClients.uncheck();
|
||||
await expect(this.useOnlyPredefinedAuthClients).not.toBeChecked();
|
||||
}
|
||||
|
||||
async disallowConnections() {
|
||||
await expect(this.disableConnectionsSwitch).not.toBeChecked();
|
||||
await this.disableConnectionsSwitch.check();
|
||||
await expect(this.disableConnectionsSwitch).toBeChecked();
|
||||
await this.saveButton.click();
|
||||
}
|
||||
|
||||
async disallowCustomConnections() {
|
||||
await expect(this.allowCustomConnectionsSwitch).toBeChecked();
|
||||
await this.allowCustomConnectionsSwitch.uncheck();
|
||||
await expect(this.allowCustomConnectionsSwitch).not.toBeChecked();
|
||||
await this.saveButton.click();
|
||||
}
|
||||
|
||||
async disallowSharedConnections() {
|
||||
await expect(this.allowSharedConnectionsSwitch).toBeChecked();
|
||||
await this.allowSharedConnectionsSwitch.uncheck();
|
||||
await expect(this.allowSharedConnectionsSwitch).not.toBeChecked();
|
||||
await this.saveButton.click();
|
||||
}
|
||||
|
||||
async allowConnections() {
|
||||
await expect(this.disableConnectionsSwitch).toBeChecked();
|
||||
await this.disableConnectionsSwitch.uncheck();
|
||||
await expect(this.disableConnectionsSwitch).not.toBeChecked();
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
await this.saveButton.click();
|
||||
}
|
||||
|
||||
async expectSuccessSnackbarToBeVisible() {
|
||||
const snackbars = await this.successSnackbar.all();
|
||||
for (const snackbar of snackbars) {
|
||||
await expect(await snackbar.getAttribute('data-snackbar-variant')).toBe(
|
||||
'success'
|
||||
);
|
||||
// await snackbar.click();
|
||||
await expect(snackbar).toBeVisible();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ const { AdminEditRolePage } = require('./edit-role-page');
|
||||
|
||||
const { AdminApplicationsPage } = require('./applications-page');
|
||||
const { AdminApplicationSettingsPage } = require('./application-settings-page');
|
||||
const { AdminApplicationAuthClientsPage } = require('./application-auth-clients-page');
|
||||
const {
|
||||
AdminApplicationOAuthClientsPage,
|
||||
} = require('./application-oauth-clients-page');
|
||||
|
||||
export const adminFixtures = {
|
||||
adminUsersPage: async ({ page }, use) => {
|
||||
@@ -35,8 +37,7 @@ export const adminFixtures = {
|
||||
adminApplicationSettingsPage: async ({ page }, use) => {
|
||||
await use(new AdminApplicationSettingsPage(page));
|
||||
},
|
||||
adminApplicationAuthClientsPage: async ({ page }, use) => {
|
||||
await use(new AdminApplicationAuthClientsPage(page));
|
||||
}
|
||||
adminApplicationOAuthClientsPage: async ({ page }, use) => {
|
||||
await use(new AdminApplicationOAuthClientsPage(page));
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
32
packages/e2e-tests/helpers/db-helpers.js
Normal file
32
packages/e2e-tests/helpers/db-helpers.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const { expect } = require('../fixtures/index');
|
||||
const { pgPool } = require('../fixtures/postgres-config');
|
||||
|
||||
export const insertAppConnection = async (appName) => {
|
||||
const queryUser = {
|
||||
text: 'SELECT * FROM users WHERE email = $1',
|
||||
values: [process.env.LOGIN_EMAIL],
|
||||
};
|
||||
|
||||
try {
|
||||
const queryUserResult = await pgPool.query(queryUser);
|
||||
expect(queryUserResult.rowCount).toEqual(1);
|
||||
|
||||
const createConnection = {
|
||||
text: 'INSERT INTO connections (key, data, user_id, verified, draft) VALUES ($1, $2, $3, $4, $5)',
|
||||
values: [
|
||||
appName,
|
||||
'U2FsdGVkX1+cAtdHwLiuRL4DaK/T1aljeeKyPMmtWK0AmAIsKhYwQiuyQCYJO3mdZ31z73hqF2Y+yj2Kn2/IIpLRqCxB2sC0rCDCZyolzOZ290YcBXSzYRzRUxhoOcZEtwYDKsy8AHygKK/tkj9uv9k6wOe1LjipNik4VmRhKjEYizzjLrJpbeU1oY+qW0GBpPYomFTeNf+MejSSmsUYyYJ8+E/4GeEfaonvsTSwMT7AId98Lck6Vy4wrfgpm7sZZ8xU15/HqXZNc8UCo2iTdw45xj/Oov9+brX4WUASFPG8aYrK8dl/EdaOvr89P8uIofbSNZ25GjJvVF5ymarrPkTZ7djjJXchzpwBY+7GTJfs3funR/vIk0Hq95jgOFFP1liZyqTXSa49ojG3hzojRQ==',
|
||||
queryUserResult.rows[0].id,
|
||||
'true',
|
||||
'false',
|
||||
],
|
||||
};
|
||||
|
||||
const createConnectionResult = await pgPool.query(createConnection);
|
||||
expect(createConnectionResult.rowCount).toBe(1);
|
||||
expect(createConnectionResult.command).toBe('INSERT');
|
||||
} catch (err) {
|
||||
console.error(err.message);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
@@ -1,23 +1,36 @@
|
||||
const { test, expect } = require('../../fixtures/index');
|
||||
const { pgPool } = require('../../fixtures/postgres-config');
|
||||
const { insertAppConnection } = require('../../helpers/db-helpers');
|
||||
|
||||
test.describe('Admin Applications', () => {
|
||||
test.beforeAll(async () => {
|
||||
const deleteAppAuthClients = {
|
||||
text: 'DELETE FROM app_auth_clients WHERE app_key in ($1, $2, $3, $4, $5)',
|
||||
values: ['carbone', 'spotify', 'deepl', 'mailchimp', 'reddit'],
|
||||
const deleteOAuthClients = {
|
||||
text: 'DELETE FROM oauth_clients WHERE app_key in ($1, $2, $3, $4, $5, $6)',
|
||||
values: [
|
||||
'carbone',
|
||||
'spotify',
|
||||
'clickup',
|
||||
'mailchimp',
|
||||
'reddit',
|
||||
'google-drive',
|
||||
],
|
||||
};
|
||||
|
||||
const deleteAppConfigs = {
|
||||
text: 'DELETE FROM app_configs WHERE key in ($1, $2, $3, $4, $5)',
|
||||
values: ['carbone', 'spotify', 'deepl', 'mailchimp', 'reddit'],
|
||||
text: 'DELETE FROM app_configs WHERE key in ($1, $2, $3, $4, $5, $6)',
|
||||
values: [
|
||||
'carbone',
|
||||
'spotify',
|
||||
'clickup',
|
||||
'mailchimp',
|
||||
'reddit',
|
||||
'google-drive',
|
||||
],
|
||||
};
|
||||
|
||||
try {
|
||||
const deleteAppAuthClientsResult = await pgPool.query(
|
||||
deleteAppAuthClients
|
||||
);
|
||||
expect(deleteAppAuthClientsResult.command).toBe('DELETE');
|
||||
const deleteOAuthClientsResult = await pgPool.query(deleteOAuthClients);
|
||||
expect(deleteOAuthClientsResult.command).toBe('DELETE');
|
||||
const deleteAppConfigsResult = await pgPool.query(deleteAppConfigs);
|
||||
expect(deleteAppConfigsResult.command).toBe('DELETE');
|
||||
} catch (err) {
|
||||
@@ -39,35 +52,126 @@ test.describe('Admin Applications', () => {
|
||||
await adminApplicationsPage.openApplication('Carbone');
|
||||
await expect(page.url()).toContain('/admin-settings/apps/carbone/settings');
|
||||
|
||||
await adminApplicationSettingsPage.allowCustomConnections();
|
||||
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
|
||||
await adminApplicationSettingsPage.allowSharedConnections();
|
||||
await adminApplicationSettingsPage.allowUseOnlyPredefinedAuthClients();
|
||||
await adminApplicationSettingsPage.saveSettings();
|
||||
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
|
||||
await adminApplicationSettingsPage.disallowConnections();
|
||||
await adminApplicationSettingsPage.saveSettings();
|
||||
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
|
||||
|
||||
await page.reload();
|
||||
|
||||
await adminApplicationSettingsPage.disallowCustomConnections();
|
||||
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
|
||||
await adminApplicationSettingsPage.disallowSharedConnections();
|
||||
await adminApplicationSettingsPage.disallowUseOnlyPredefinedAuthClients();
|
||||
await adminApplicationSettingsPage.saveSettings();
|
||||
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
|
||||
await adminApplicationSettingsPage.allowConnections();
|
||||
await adminApplicationSettingsPage.saveSettings();
|
||||
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
|
||||
});
|
||||
|
||||
test('should allow only custom connections', async ({
|
||||
adminApplicationsPage,
|
||||
adminApplicationSettingsPage,
|
||||
adminApplicationOAuthClientsPage,
|
||||
flowEditorPage,
|
||||
page,
|
||||
}) => {
|
||||
await insertAppConnection('google-drive');
|
||||
|
||||
// TODO use openApplication method after fix
|
||||
// await adminApplicationsPage.openApplication('Google-Drive');
|
||||
await adminApplicationsPage.searchInput.fill('Google-Drive');
|
||||
await adminApplicationsPage.appRow
|
||||
.locator(page.getByText('Google Drive'))
|
||||
.click();
|
||||
|
||||
await expect(page.url()).toContain(
|
||||
'/admin-settings/apps/google-drive/settings'
|
||||
);
|
||||
|
||||
await expect(
|
||||
adminApplicationSettingsPage.useOnlyPredefinedAuthClients
|
||||
).not.toBeChecked();
|
||||
await expect(
|
||||
adminApplicationSettingsPage.disableConnectionsSwitch
|
||||
).not.toBeChecked();
|
||||
|
||||
await adminApplicationOAuthClientsPage.openAuthClientsTab();
|
||||
await expect(
|
||||
adminApplicationOAuthClientsPage.createFirstAuthClientButton
|
||||
).toHaveCount(1);
|
||||
|
||||
await page.goto('/');
|
||||
await page.getByTestId('create-flow-button').click();
|
||||
await page.waitForURL(
|
||||
/\/editor\/[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}/
|
||||
);
|
||||
|
||||
await expect(flowEditorPage.flowStep).toHaveCount(2);
|
||||
|
||||
await flowEditorPage.chooseAppAndEvent(
|
||||
'Google Drive',
|
||||
'New files in folder'
|
||||
);
|
||||
await flowEditorPage.connectionAutocomplete.click();
|
||||
|
||||
const newConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add new connection' });
|
||||
const newOAuthConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add connection with OAuth client' });
|
||||
const existingConnection = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Unnamed' });
|
||||
|
||||
await expect(await existingConnection.count()).toBeGreaterThan(0);
|
||||
await expect(newConnectionOption).toBeEnabled();
|
||||
await expect(newConnectionOption).toHaveCount(1);
|
||||
await expect(newOAuthConnectionOption).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('should allow only predefined connections and existing custom', async ({
|
||||
adminApplicationsPage,
|
||||
adminApplicationSettingsPage,
|
||||
adminApplicationOAuthClientsPage,
|
||||
flowEditorPage,
|
||||
page,
|
||||
}) => {
|
||||
await insertAppConnection('spotify');
|
||||
|
||||
await adminApplicationsPage.openApplication('Spotify');
|
||||
await expect(page.url()).toContain('/admin-settings/apps/spotify/settings');
|
||||
|
||||
await adminApplicationSettingsPage.allowCustomConnections();
|
||||
await expect(
|
||||
adminApplicationSettingsPage.useOnlyPredefinedAuthClients
|
||||
).not.toBeChecked();
|
||||
await expect(
|
||||
adminApplicationSettingsPage.disableConnectionsSwitch
|
||||
).not.toBeChecked();
|
||||
|
||||
await adminApplicationSettingsPage.allowUseOnlyPredefinedAuthClients();
|
||||
await adminApplicationSettingsPage.saveSettings();
|
||||
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
|
||||
|
||||
await adminApplicationOAuthClientsPage.openAuthClientsTab();
|
||||
await adminApplicationOAuthClientsPage.openFirstAuthClientCreateForm();
|
||||
const authClientForm = page.getByTestId('auth-client-form');
|
||||
await authClientForm.locator(page.getByTestId('switch')).check();
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="name"]'))
|
||||
.fill('spotifyAuthClient');
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="clientId"]'))
|
||||
.fill('spotifyClientId');
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="clientSecret"]'))
|
||||
.fill('spotifyClientSecret');
|
||||
await adminApplicationOAuthClientsPage.submitAuthClientForm();
|
||||
await adminApplicationOAuthClientsPage.authClientShouldBeVisible(
|
||||
'spotifyAuthClient'
|
||||
);
|
||||
|
||||
await page.goto('/');
|
||||
await page.getByTestId('create-flow-button').click();
|
||||
await page.waitForURL(
|
||||
@@ -84,30 +188,41 @@ test.describe('Admin Applications', () => {
|
||||
const newConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add new connection' });
|
||||
const newSharedConnectionOption = page
|
||||
const newOAuthConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add new shared connection' });
|
||||
.filter({ hasText: 'Add connection with OAuth client' });
|
||||
const existingConnection = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Unnamed' });
|
||||
|
||||
await expect(newConnectionOption).toBeEnabled();
|
||||
await expect(newConnectionOption).toHaveCount(1);
|
||||
await expect(newSharedConnectionOption).toHaveCount(0);
|
||||
await expect(await existingConnection.count()).toBeGreaterThan(0);
|
||||
await expect(newConnectionOption).toHaveCount(0);
|
||||
await expect(newOAuthConnectionOption).toBeEnabled();
|
||||
await expect(newOAuthConnectionOption).toHaveCount(1);
|
||||
});
|
||||
|
||||
test('should allow only shared connections', async ({
|
||||
test('should allow all connections', async ({
|
||||
adminApplicationsPage,
|
||||
adminApplicationSettingsPage,
|
||||
adminApplicationAuthClientsPage,
|
||||
adminApplicationOAuthClientsPage,
|
||||
flowEditorPage,
|
||||
page,
|
||||
}) => {
|
||||
await insertAppConnection('reddit');
|
||||
|
||||
await adminApplicationsPage.openApplication('Reddit');
|
||||
await expect(page.url()).toContain('/admin-settings/apps/reddit/settings');
|
||||
|
||||
await adminApplicationSettingsPage.allowSharedConnections();
|
||||
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
|
||||
await expect(
|
||||
adminApplicationSettingsPage.useOnlyPredefinedAuthClients
|
||||
).not.toBeChecked();
|
||||
await expect(
|
||||
adminApplicationSettingsPage.disableConnectionsSwitch
|
||||
).not.toBeChecked();
|
||||
|
||||
await adminApplicationOAuthClientsPage.openAuthClientsTab();
|
||||
await adminApplicationOAuthClientsPage.openFirstAuthClientCreateForm();
|
||||
|
||||
await adminApplicationAuthClientsPage.openAuthClientsTab();
|
||||
await adminApplicationAuthClientsPage.openFirstAuthClientCreateForm();
|
||||
const authClientForm = page.getByTestId('auth-client-form');
|
||||
await authClientForm.locator(page.getByTestId('switch')).check();
|
||||
await authClientForm
|
||||
@@ -119,8 +234,9 @@ test.describe('Admin Applications', () => {
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="clientSecret"]'))
|
||||
.fill('redditClientSecret');
|
||||
await adminApplicationAuthClientsPage.submitAuthClientForm();
|
||||
await adminApplicationAuthClientsPage.authClientShouldBeVisible(
|
||||
|
||||
await adminApplicationOAuthClientsPage.submitAuthClientForm();
|
||||
await adminApplicationOAuthClientsPage.authClientShouldBeVisible(
|
||||
'redditAuthClient'
|
||||
);
|
||||
|
||||
@@ -140,27 +256,54 @@ test.describe('Admin Applications', () => {
|
||||
const newConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add new connection' });
|
||||
const newSharedConnectionOption = page
|
||||
const newOAuthConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add new shared connection' });
|
||||
.filter({ hasText: 'Add connection with OAuth client' });
|
||||
const existingConnection = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Unnamed' });
|
||||
|
||||
await expect(newConnectionOption).toHaveCount(0);
|
||||
await expect(newSharedConnectionOption).toBeEnabled();
|
||||
await expect(newSharedConnectionOption).toHaveCount(1);
|
||||
await expect(await existingConnection.count()).toBeGreaterThan(0);
|
||||
await expect(newConnectionOption).toHaveCount(1);
|
||||
await expect(newOAuthConnectionOption).toBeEnabled();
|
||||
await expect(newOAuthConnectionOption).toHaveCount(1);
|
||||
});
|
||||
|
||||
test('should not allow any connections', async ({
|
||||
test('should not allow new connections but existing custom', async ({
|
||||
adminApplicationsPage,
|
||||
adminApplicationSettingsPage,
|
||||
adminApplicationOAuthClientsPage,
|
||||
flowEditorPage,
|
||||
page,
|
||||
}) => {
|
||||
await adminApplicationsPage.openApplication('DeepL');
|
||||
await expect(page.url()).toContain('/admin-settings/apps/deepl/settings');
|
||||
await insertAppConnection('clickup');
|
||||
|
||||
await adminApplicationsPage.openApplication('ClickUp');
|
||||
await expect(page.url()).toContain('/admin-settings/apps/clickup/settings');
|
||||
|
||||
await adminApplicationSettingsPage.disallowConnections();
|
||||
await adminApplicationSettingsPage.saveSettings();
|
||||
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
|
||||
|
||||
await adminApplicationOAuthClientsPage.openAuthClientsTab();
|
||||
await adminApplicationOAuthClientsPage.openFirstAuthClientCreateForm();
|
||||
|
||||
const authClientForm = page.getByTestId('auth-client-form');
|
||||
await authClientForm.locator(page.getByTestId('switch')).check();
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="name"]'))
|
||||
.fill('clickupAuthClient');
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="clientId"]'))
|
||||
.fill('clickupClientId');
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="clientSecret"]'))
|
||||
.fill('clickupClientSecret');
|
||||
await adminApplicationOAuthClientsPage.submitAuthClientForm();
|
||||
await adminApplicationOAuthClientsPage.authClientShouldBeVisible(
|
||||
'clickupAuthClient'
|
||||
);
|
||||
|
||||
await page.goto('/');
|
||||
await page.getByTestId('create-flow-button').click();
|
||||
await page.waitForURL(
|
||||
@@ -171,68 +314,62 @@ test.describe('Admin Applications', () => {
|
||||
const triggerStep = flowEditorPage.flowStep.last();
|
||||
await triggerStep.click();
|
||||
|
||||
await flowEditorPage.chooseAppAndEvent('DeepL', 'Translate text');
|
||||
await flowEditorPage.chooseAppAndEvent('ClickUp', 'Create folder');
|
||||
await flowEditorPage.connectionAutocomplete.click();
|
||||
|
||||
const newConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add new connection' });
|
||||
const newSharedConnectionOption = page
|
||||
const newOAuthConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add new shared connection' });
|
||||
const noConnectionsOption = page
|
||||
.locator('.MuiAutocomplete-noOptions')
|
||||
.filter({ hasText: 'No options' });
|
||||
.filter({ hasText: 'Add connection with OAuth client' });
|
||||
const existingConnection = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Unnamed' });
|
||||
|
||||
await expect(noConnectionsOption).toHaveCount(1);
|
||||
await expect(await existingConnection.count()).toBeGreaterThan(0);
|
||||
await expect(newConnectionOption).toHaveCount(0);
|
||||
await expect(newSharedConnectionOption).toHaveCount(0);
|
||||
await expect(newOAuthConnectionOption).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('should not allow new connections but only already created', async ({
|
||||
test('should not allow new connections but existing custom even if predefined OAuth clients are enabled', async ({
|
||||
adminApplicationsPage,
|
||||
adminApplicationSettingsPage,
|
||||
adminApplicationOAuthClientsPage,
|
||||
flowEditorPage,
|
||||
page,
|
||||
}) => {
|
||||
const queryUser = {
|
||||
text: 'SELECT * FROM users WHERE email = $1',
|
||||
values: [process.env.LOGIN_EMAIL],
|
||||
};
|
||||
|
||||
try {
|
||||
const queryUserResult = await pgPool.query(queryUser);
|
||||
expect(queryUserResult.rowCount).toEqual(1);
|
||||
|
||||
const createMailchimpConnection = {
|
||||
text: 'INSERT INTO connections (key, data, user_id, verified, draft) VALUES ($1, $2, $3, $4, $5)',
|
||||
values: [
|
||||
'mailchimp',
|
||||
'U2FsdGVkX1+cAtdHwLiuRL4DaK/T1aljeeKyPMmtWK0AmAIsKhYwQiuyQCYJO3mdZ31z73hqF2Y+yj2Kn2/IIpLRqCxB2sC0rCDCZyolzOZ290YcBXSzYRzRUxhoOcZEtwYDKsy8AHygKK/tkj9uv9k6wOe1LjipNik4VmRhKjEYizzjLrJpbeU1oY+qW0GBpPYomFTeNf+MejSSmsUYyYJ8+E/4GeEfaonvsTSwMT7AId98Lck6Vy4wrfgpm7sZZ8xU15/HqXZNc8UCo2iTdw45xj/Oov9+brX4WUASFPG8aYrK8dl/EdaOvr89P8uIofbSNZ25GjJvVF5ymarrPkTZ7djjJXchzpwBY+7GTJfs3funR/vIk0Hq95jgOFFP1liZyqTXSa49ojG3hzojRQ==',
|
||||
queryUserResult.rows[0].id,
|
||||
'true',
|
||||
'false',
|
||||
],
|
||||
};
|
||||
|
||||
const createMailchimpConnectionResult = await pgPool.query(
|
||||
createMailchimpConnection
|
||||
);
|
||||
expect(createMailchimpConnectionResult.rowCount).toBe(1);
|
||||
expect(createMailchimpConnectionResult.command).toBe('INSERT');
|
||||
} catch (err) {
|
||||
console.error(err.message);
|
||||
throw err;
|
||||
}
|
||||
await insertAppConnection('mailchimp');
|
||||
|
||||
await adminApplicationsPage.openApplication('Mailchimp');
|
||||
await expect(page.url()).toContain(
|
||||
'/admin-settings/apps/mailchimp/settings'
|
||||
);
|
||||
|
||||
await adminApplicationSettingsPage.allowUseOnlyPredefinedAuthClients();
|
||||
await adminApplicationSettingsPage.disallowConnections();
|
||||
await adminApplicationSettingsPage.saveSettings();
|
||||
await adminApplicationSettingsPage.expectSuccessSnackbarToBeVisible();
|
||||
|
||||
await adminApplicationOAuthClientsPage.openAuthClientsTab();
|
||||
await adminApplicationOAuthClientsPage.openFirstAuthClientCreateForm();
|
||||
|
||||
const authClientForm = page.getByTestId('auth-client-form');
|
||||
await authClientForm.locator(page.getByTestId('switch')).check();
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="name"]'))
|
||||
.fill('mailchimpAuthClient');
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="clientId"]'))
|
||||
.fill('mailchimpClientId');
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="clientSecret"]'))
|
||||
.fill('mailchimpClientSecret');
|
||||
await adminApplicationOAuthClientsPage.submitAuthClientForm();
|
||||
await adminApplicationOAuthClientsPage.authClientShouldBeVisible(
|
||||
'mailchimpAuthClient'
|
||||
);
|
||||
|
||||
await page.goto('/');
|
||||
await page.getByTestId('create-flow-button').click();
|
||||
await page.waitForURL(
|
||||
@@ -253,9 +390,9 @@ test.describe('Admin Applications', () => {
|
||||
const newConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add new connection' });
|
||||
const newSharedConnectionOption = page
|
||||
const newOAuthConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add new shared connection' });
|
||||
.filter({ hasText: 'Add connection with OAuth client' });
|
||||
const noConnectionsOption = page
|
||||
.locator('.MuiAutocomplete-noOptions')
|
||||
.filter({ hasText: 'No options' });
|
||||
@@ -263,6 +400,6 @@ test.describe('Admin Applications', () => {
|
||||
await expect(await existingConnection.count()).toBeGreaterThan(0);
|
||||
await expect(noConnectionsOption).toHaveCount(0);
|
||||
await expect(newConnectionOption).toHaveCount(0);
|
||||
await expect(newSharedConnectionOption).toHaveCount(0);
|
||||
await expect(newOAuthConnectionOption).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ test.describe('Apps page', () => {
|
||||
test('goes to app page to create a connection', async ({
|
||||
applicationsPage,
|
||||
}) => {
|
||||
// loading app, app config, app auth clients take time
|
||||
// loading app, app config, app oauth clients take time
|
||||
test.setTimeout(60000);
|
||||
|
||||
await applicationsPage.page.getByTestId('app-list-item').first().click();
|
||||
|
||||
Reference in New Issue
Block a user