Merge branch 'main' into AUT-1379
This commit is contained in:
@@ -1,21 +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) {
|
||||
@@ -31,40 +46,131 @@ test.describe('Admin Applications', () => {
|
||||
test('Admin should be able to toggle Application settings', async ({
|
||||
adminApplicationsPage,
|
||||
adminApplicationSettingsPage,
|
||||
page
|
||||
page,
|
||||
}) => {
|
||||
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
|
||||
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(
|
||||
@@ -75,39 +181,61 @@ test.describe('Admin Applications', () => {
|
||||
const triggerStep = flowEditorPage.flowStep.last();
|
||||
await triggerStep.click();
|
||||
|
||||
await flowEditorPage.chooseAppAndEvent("Spotify", "Create Playlist");
|
||||
await flowEditorPage.chooseAppAndEvent('Spotify', 'Create playlist');
|
||||
await flowEditorPage.connectionAutocomplete.click();
|
||||
|
||||
const newConnectionOption = page.getByRole('option').filter({ hasText: 'Add new connection' });
|
||||
const newSharedConnectionOption = page.getByRole('option').filter({ hasText: 'Add new shared connection' });
|
||||
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(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
|
||||
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 adminApplicationAuthClientsPage.openAuthClientsTab();
|
||||
await adminApplicationAuthClientsPage.openFirstAuthClientCreateForm();
|
||||
const authClientForm = page.getByTestId("auth-client-form");
|
||||
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('redditAuthClient');
|
||||
await authClientForm.locator(page.locator('[name="clientId"]')).fill('redditClientId');
|
||||
await authClientForm.locator(page.locator('[name="clientSecret"]')).fill('redditClientSecret');
|
||||
await adminApplicationAuthClientsPage.submitAuthClientForm();
|
||||
await adminApplicationAuthClientsPage.authClientShouldBeVisible('redditAuthClient');
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="name"]'))
|
||||
.fill('redditAuthClient');
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="clientId"]'))
|
||||
.fill('redditClientId');
|
||||
await authClientForm
|
||||
.locator(page.locator('[name="clientSecret"]'))
|
||||
.fill('redditClientSecret');
|
||||
await adminApplicationOAuthClientsPage.submitAuthClientForm();
|
||||
await adminApplicationOAuthClientsPage.authClientShouldBeVisible(
|
||||
'redditAuthClient'
|
||||
);
|
||||
|
||||
await page.goto('/');
|
||||
await page.getByTestId('create-flow-button').click();
|
||||
@@ -119,29 +247,60 @@ test.describe('Admin Applications', () => {
|
||||
const triggerStep = flowEditorPage.flowStep.last();
|
||||
await triggerStep.click();
|
||||
|
||||
await flowEditorPage.chooseAppAndEvent("Reddit", "Create link post");
|
||||
await flowEditorPage.chooseAppAndEvent('Reddit', 'Create link post');
|
||||
await flowEditorPage.connectionAutocomplete.click();
|
||||
|
||||
const newConnectionOption = page.getByRole('option').filter({ hasText: 'Add new connection' });
|
||||
const newSharedConnectionOption = page.getByRole('option').filter({ hasText: 'Add new shared connection' });
|
||||
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(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
|
||||
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(
|
||||
@@ -152,58 +311,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.getByRole('option').filter({ hasText: 'Add new shared connection' });
|
||||
const noConnectionsOption = page.locator('.MuiAutocomplete-noOptions').filter({ hasText: 'No options' });
|
||||
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(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
|
||||
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 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(
|
||||
@@ -214,18 +377,26 @@ test.describe('Admin Applications', () => {
|
||||
const triggerStep = flowEditorPage.flowStep.last();
|
||||
await triggerStep.click();
|
||||
|
||||
await flowEditorPage.chooseAppAndEvent("Mailchimp", "Create campaign");
|
||||
await flowEditorPage.chooseAppAndEvent('Mailchimp', 'Create campaign');
|
||||
await flowEditorPage.connectionAutocomplete.click();
|
||||
await expect(page.getByRole('option').first()).toHaveText('Unnamed');
|
||||
|
||||
const existingConnection = page.getByRole('option').filter({ hasText: 'Unnamed' });
|
||||
const newConnectionOption = page.getByRole('option').filter({ hasText: 'Add new connection' });
|
||||
const newSharedConnectionOption = page.getByRole('option').filter({ hasText: 'Add new shared connection' });
|
||||
const noConnectionsOption = page.locator('.MuiAutocomplete-noOptions').filter({ hasText: 'No options' });
|
||||
const existingConnection = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Unnamed' });
|
||||
const newConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add new connection' });
|
||||
const newOAuthConnectionOption = page
|
||||
.getByRole('option')
|
||||
.filter({ hasText: 'Add connection with OAuth client' });
|
||||
const noConnectionsOption = page
|
||||
.locator('.MuiAutocomplete-noOptions')
|
||||
.filter({ hasText: 'No options' });
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,9 +35,8 @@ test.describe('Role management page', () => {
|
||||
await adminCreateRolePage.closeSnackbar();
|
||||
});
|
||||
|
||||
let roleRow = await test.step(
|
||||
'Make sure role data is correct',
|
||||
async () => {
|
||||
let roleRow =
|
||||
await test.step('Make sure role data is correct', async () => {
|
||||
const roleRow = await adminRolesPage.getRoleRowByName(
|
||||
'Create Edit Test'
|
||||
);
|
||||
@@ -48,8 +47,7 @@ test.describe('Role management page', () => {
|
||||
await expect(roleData.canEdit).toBe(true);
|
||||
await expect(roleData.canDelete).toBe(true);
|
||||
return roleRow;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
await test.step('Edit the role', async () => {
|
||||
await adminRolesPage.clickEditRole(roleRow);
|
||||
@@ -67,9 +65,8 @@ test.describe('Role management page', () => {
|
||||
await adminEditRolePage.closeSnackbar();
|
||||
});
|
||||
|
||||
roleRow = await test.step(
|
||||
'Make sure changes reflected on roles page',
|
||||
async () => {
|
||||
roleRow =
|
||||
await test.step('Make sure changes reflected on roles page', async () => {
|
||||
await adminRolesPage.isMounted();
|
||||
const roleRow = await adminRolesPage.getRoleRowByName(
|
||||
'Create Update Test'
|
||||
@@ -81,8 +78,7 @@ test.describe('Role management page', () => {
|
||||
await expect(roleData.canEdit).toBe(true);
|
||||
await expect(roleData.canDelete).toBe(true);
|
||||
return roleRow;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
await test.step('Delete the role', async () => {
|
||||
await adminRolesPage.clickDeleteRole(roleRow);
|
||||
@@ -184,44 +180,34 @@ test.describe('Role management page', () => {
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminCreateRolePage.closeSnackbar();
|
||||
});
|
||||
await test.step(
|
||||
'Create a new user with the "Delete Role" role',
|
||||
async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill('User Role Test');
|
||||
await adminCreateUserPage.emailInput.fill(
|
||||
'user-role-test@automatisch.io'
|
||||
);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page
|
||||
.getByRole('option', { name: 'Delete Role', exact: true })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await adminCreateUserPage.snackbar.waitFor({
|
||||
state: 'attached',
|
||||
});
|
||||
await adminCreateUserPage.invitationEmailInfoAlert.waitFor({
|
||||
state: 'attached',
|
||||
});
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-create-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
}
|
||||
);
|
||||
await test.step(
|
||||
'Try to delete "Delete Role" role when new user has it',
|
||||
async () => {
|
||||
await adminRolesPage.navigateTo();
|
||||
const row = await adminRolesPage.getRoleRowByName('Delete Role');
|
||||
const modal = await adminRolesPage.clickDeleteRole(row);
|
||||
await modal.deleteButton.click();
|
||||
await expect(modal.deleteAlert).toHaveCount(1);
|
||||
await modal.close();
|
||||
}
|
||||
);
|
||||
|
||||
await test.step('Create a new user with the "Delete Role" role', async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill('User Role Test');
|
||||
await adminCreateUserPage.emailInput.fill(
|
||||
'user-role-test@automatisch.io'
|
||||
);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page
|
||||
.getByRole('option', { name: 'Delete Role', exact: true })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await adminCreateUserPage.invitationEmailInfoAlert.waitFor({
|
||||
state: 'attached',
|
||||
});
|
||||
await adminCreateUserPage.expectCreateUserSuccessAlertToBeVisible();
|
||||
});
|
||||
|
||||
await test.step('Try to delete "Delete Role" role when new user has it', async () => {
|
||||
await adminRolesPage.navigateTo();
|
||||
const row = await adminRolesPage.getRoleRowByName('Delete Role');
|
||||
const modal = await adminRolesPage.clickDeleteRole(row);
|
||||
await modal.deleteButton.click();
|
||||
await expect(modal.deleteAlert).toHaveCount(1);
|
||||
await modal.close();
|
||||
});
|
||||
|
||||
await test.step('Change the role the user has', async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.usersLoader.waitFor({
|
||||
@@ -296,17 +282,10 @@ test.describe('Role management page', () => {
|
||||
.getByRole('option', { name: 'Cannot Delete Role' })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await adminCreateUserPage.snackbar.waitFor({
|
||||
state: 'attached',
|
||||
});
|
||||
await adminCreateUserPage.invitationEmailInfoAlert.waitFor({
|
||||
state: 'attached',
|
||||
});
|
||||
const snackbar = await adminCreateUserPage.getSnackbarData(
|
||||
'snackbar-create-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminCreateUserPage.closeSnackbar();
|
||||
await adminCreateUserPage.expectCreateUserSuccessAlertToBeVisible();
|
||||
});
|
||||
await test.step('Delete this user', async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
@@ -371,17 +350,10 @@ test('Accessibility of role management page', async ({
|
||||
.getByRole('option', { name: 'Basic Test' })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await adminCreateUserPage.snackbar.waitFor({
|
||||
state: 'attached',
|
||||
});
|
||||
await adminCreateUserPage.invitationEmailInfoAlert.waitFor({
|
||||
state: 'attached',
|
||||
});
|
||||
const snackbar = await adminCreateUserPage.getSnackbarData(
|
||||
'snackbar-create-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminCreateUserPage.closeSnackbar();
|
||||
await adminCreateUserPage.expectCreateUserSuccessAlertToBeVisible();
|
||||
});
|
||||
|
||||
await test.step('Logout and login to the basic role user', async () => {
|
||||
@@ -395,42 +367,35 @@ test('Accessibility of role management page', async ({
|
||||
await page.getByTestId('logout-item').click();
|
||||
|
||||
const acceptInvitationPage = new AcceptInvitation(page);
|
||||
|
||||
await acceptInvitationPage.open(acceptInvitatonToken);
|
||||
|
||||
await acceptInvitationPage.acceptInvitation('sample');
|
||||
|
||||
const loginPage = new LoginPage(page);
|
||||
|
||||
// await loginPage.isMounted();
|
||||
await loginPage.login('basic-role-test@automatisch.io', 'sample');
|
||||
await expect(loginPage.loginButton).not.toBeVisible();
|
||||
await expect(page).toHaveURL('/flows');
|
||||
});
|
||||
|
||||
await test.step(
|
||||
'Navigate to the admin settings page and make sure it is blank',
|
||||
async () => {
|
||||
const pageUrl = new URL(page.url());
|
||||
const url = `${pageUrl.origin}/admin-settings/users`;
|
||||
await page.goto(url);
|
||||
await page.waitForTimeout(750);
|
||||
const isUnmounted = await page.evaluate(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
const root = document.querySelector('#root');
|
||||
await test.step('Navigate to the admin settings page and make sure it is blank', async () => {
|
||||
const pageUrl = new URL(page.url());
|
||||
const url = `${pageUrl.origin}/admin-settings/users`;
|
||||
await page.goto(url);
|
||||
await page.waitForTimeout(750);
|
||||
const isUnmounted = await page.evaluate(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
const root = document.querySelector('#root');
|
||||
|
||||
if (root) {
|
||||
// We have react query devtools only in dev env.
|
||||
// In production, there is nothing in root.
|
||||
// That's why `<= 1`.
|
||||
return root.children.length <= 1;
|
||||
}
|
||||
if (root) {
|
||||
// We have react query devtools only in dev env.
|
||||
// In production, there is nothing in root.
|
||||
// That's why `<= 1`.
|
||||
return root.children.length <= 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
await expect(isUnmounted).toBe(true);
|
||||
}
|
||||
);
|
||||
return false;
|
||||
});
|
||||
await expect(isUnmounted).toBe(true);
|
||||
});
|
||||
|
||||
await test.step('Log back into the admin account', async () => {
|
||||
await page.goto('/');
|
||||
|
||||
@@ -5,281 +5,221 @@ const { test, expect } = require('../../fixtures/index');
|
||||
* otherwise tests will fail since users are only *soft*-deleted
|
||||
*/
|
||||
test.describe('User management page', () => {
|
||||
|
||||
test.beforeEach(async ({ adminUsersPage }) => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.closeSnackbar();
|
||||
});
|
||||
|
||||
test(
|
||||
'User creation and deletion process',
|
||||
async ({ adminCreateUserPage, adminEditUserPage, adminUsersPage }) => {
|
||||
adminCreateUserPage.seed(9000);
|
||||
const user = adminCreateUserPage.generateUser();
|
||||
await adminUsersPage.usersLoader.waitFor({
|
||||
state: 'detached' /* Note: state: 'visible' introduces flakiness
|
||||
test('User creation and deletion process', async ({
|
||||
adminCreateUserPage,
|
||||
adminEditUserPage,
|
||||
adminUsersPage,
|
||||
}) => {
|
||||
adminCreateUserPage.seed(9000);
|
||||
const user = adminCreateUserPage.generateUser();
|
||||
await adminUsersPage.usersLoader.waitFor({
|
||||
state: 'detached' /* Note: state: 'visible' introduces flakiness
|
||||
because visibility: hidden is used as part of the state transition in
|
||||
notistack, see
|
||||
https://github.com/iamhosseindhv/notistack/blob/122f47057eb7ce5a1abfe923316cf8475303e99a/src/transitions/Collapse/Collapse.tsx#L110
|
||||
*/
|
||||
*/,
|
||||
});
|
||||
await test.step('Create a user', async () => {
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(user.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(user.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page
|
||||
.getByRole('option', { name: 'Admin' })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await adminCreateUserPage.invitationEmailInfoAlert.waitFor({
|
||||
state: 'attached',
|
||||
});
|
||||
await test.step(
|
||||
'Create a user',
|
||||
async () => {
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(user.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(user.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page.getByRole(
|
||||
'option', { name: 'Admin' }
|
||||
).click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await adminCreateUserPage.invitationEmailInfoAlert.waitFor({
|
||||
state: 'attached'
|
||||
});
|
||||
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-create-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.closeSnackbar();
|
||||
}
|
||||
await adminCreateUserPage.expectCreateUserSuccessAlertToBeVisible();
|
||||
await adminUsersPage.navigateTo();
|
||||
});
|
||||
await test.step('Check the user exists with the expected properties', async () => {
|
||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||
const userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||
const data = await adminUsersPage.getRowData(userRow);
|
||||
await expect(data.email).toBe(user.email);
|
||||
await expect(data.fullName).toBe(user.fullName);
|
||||
await expect(data.role).toBe('Admin');
|
||||
});
|
||||
await test.step('Edit user info and make sure the edit works correctly', async () => {
|
||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||
|
||||
let userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||
await adminUsersPage.clickEditUser(userRow);
|
||||
await adminEditUserPage.waitForLoad(user.fullName);
|
||||
const newUserInfo = adminEditUserPage.generateUser();
|
||||
await adminEditUserPage.fullNameInput.fill(newUserInfo.fullName);
|
||||
await adminEditUserPage.updateButton.click();
|
||||
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-edit-user-success'
|
||||
);
|
||||
await test.step(
|
||||
'Check the user exists with the expected properties',
|
||||
async () => {
|
||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||
const userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||
const data = await adminUsersPage.getRowData(userRow);
|
||||
await expect(data.email).toBe(user.email);
|
||||
await expect(data.fullName).toBe(user.fullName);
|
||||
await expect(data.role).toBe('Admin');
|
||||
}
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
|
||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||
userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||
const rowData = await adminUsersPage.getRowData(userRow);
|
||||
await expect(rowData.fullName).toBe(newUserInfo.fullName);
|
||||
});
|
||||
await test.step('Delete user and check the page confirms this deletion', async () => {
|
||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||
const userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||
await adminUsersPage.clickDeleteUser(userRow);
|
||||
const modal = adminUsersPage.deleteUserModal;
|
||||
await modal.deleteButton.click();
|
||||
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-delete-user-success'
|
||||
);
|
||||
await test.step(
|
||||
'Edit user info and make sure the edit works correctly',
|
||||
async () => {
|
||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
await expect(userRow).not.toBeVisible(false);
|
||||
});
|
||||
});
|
||||
|
||||
let userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||
await adminUsersPage.clickEditUser(userRow);
|
||||
await adminEditUserPage.waitForLoad(user.fullName);
|
||||
const newUserInfo = adminEditUserPage.generateUser();
|
||||
await adminEditUserPage.fullNameInput.fill(newUserInfo.fullName);
|
||||
await adminEditUserPage.updateButton.click();
|
||||
test('Creating a user which has been deleted', async ({
|
||||
adminCreateUserPage,
|
||||
adminUsersPage,
|
||||
}) => {
|
||||
adminCreateUserPage.seed(9100);
|
||||
const testUser = adminCreateUserPage.generateUser();
|
||||
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-edit-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
|
||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||
userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||
const rowData = await adminUsersPage.getRowData(userRow);
|
||||
await expect(rowData.fullName).toBe(newUserInfo.fullName);
|
||||
}
|
||||
);
|
||||
await test.step(
|
||||
'Delete user and check the page confirms this deletion',
|
||||
async () => {
|
||||
await adminUsersPage.findUserPageWithEmail(user.email);
|
||||
const userRow = await adminUsersPage.getUserRowByEmail(user.email);
|
||||
await adminUsersPage.clickDeleteUser(userRow);
|
||||
const modal = adminUsersPage.deleteUserModal;
|
||||
await modal.deleteButton.click();
|
||||
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-delete-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
await expect(userRow).not.toBeVisible(false);
|
||||
}
|
||||
);
|
||||
await test.step('Create the test user', async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page
|
||||
.getByRole('option', { name: 'Admin' })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await adminCreateUserPage.expectCreateUserSuccessAlertToBeVisible();
|
||||
});
|
||||
|
||||
test(
|
||||
'Creating a user which has been deleted',
|
||||
async ({ adminCreateUserPage, adminUsersPage }) => {
|
||||
adminCreateUserPage.seed(9100);
|
||||
const testUser = adminCreateUserPage.generateUser();
|
||||
|
||||
await test.step(
|
||||
'Create the test user',
|
||||
async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page.getByRole(
|
||||
'option', { name: 'Admin' }
|
||||
).click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-create-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
}
|
||||
await test.step('Delete the created user', async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.findUserPageWithEmail(testUser.email);
|
||||
const userRow = await adminUsersPage.getUserRowByEmail(testUser.email);
|
||||
await adminUsersPage.clickDeleteUser(userRow);
|
||||
const modal = adminUsersPage.deleteUserModal;
|
||||
await modal.deleteButton.click();
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-delete-user-success'
|
||||
);
|
||||
await expect(snackbar).not.toBeNull();
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
await expect(userRow).not.toBeVisible(false);
|
||||
});
|
||||
|
||||
await test.step(
|
||||
'Delete the created user',
|
||||
async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.findUserPageWithEmail(testUser.email);
|
||||
const userRow = await adminUsersPage.getUserRowByEmail(testUser.email);
|
||||
await adminUsersPage.clickDeleteUser(userRow);
|
||||
const modal = adminUsersPage.deleteUserModal;
|
||||
await modal.deleteButton.click();
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-delete-user-success'
|
||||
);
|
||||
await expect(snackbar).not.toBeNull();
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
await expect(userRow).not.toBeVisible(false);
|
||||
}
|
||||
);
|
||||
await test.step('Create the user again', async () => {
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page
|
||||
.getByRole('option', { name: 'Admin' })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await expect(adminCreateUserPage.fieldError).toHaveCount(1);
|
||||
});
|
||||
});
|
||||
|
||||
await test.step(
|
||||
'Create the user again',
|
||||
async () => {
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page.getByRole(
|
||||
'option', { name: 'Admin' }
|
||||
).click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
const snackbar = await adminUsersPage.getSnackbarData('snackbar-error');
|
||||
await expect(snackbar.variant).toBe('error');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
test('Creating a user which already exists', async ({
|
||||
adminCreateUserPage,
|
||||
adminUsersPage,
|
||||
page,
|
||||
}) => {
|
||||
adminCreateUserPage.seed(9200);
|
||||
const testUser = adminCreateUserPage.generateUser();
|
||||
|
||||
test(
|
||||
'Creating a user which already exists',
|
||||
async ({ adminCreateUserPage, adminUsersPage, page }) => {
|
||||
adminCreateUserPage.seed(9200);
|
||||
const testUser = adminCreateUserPage.generateUser();
|
||||
await test.step('Create the test user', async () => {
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page
|
||||
.getByRole('option', { name: 'Admin' })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await adminCreateUserPage.expectCreateUserSuccessAlertToBeVisible();
|
||||
});
|
||||
|
||||
await test.step(
|
||||
'Create the test user',
|
||||
async () => {
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page.getByRole(
|
||||
'option', { name: 'Admin' }
|
||||
).click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-create-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
}
|
||||
);
|
||||
await test.step('Create the user again', async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||
const createUserPageUrl = page.url();
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page
|
||||
.getByRole('option', { name: 'Admin' })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
|
||||
await test.step(
|
||||
'Create the user again',
|
||||
async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(testUser.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(testUser.email);
|
||||
const createUserPageUrl = page.url();
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page.getByRole(
|
||||
'option', { name: 'Admin' }
|
||||
).click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await expect(page.url()).toBe(createUserPageUrl);
|
||||
await expect(adminCreateUserPage.fieldError).toHaveCount(1);
|
||||
});
|
||||
});
|
||||
|
||||
await expect(page.url()).toBe(createUserPageUrl);
|
||||
const snackbar = await adminUsersPage.getSnackbarData('snackbar-error');
|
||||
await expect(snackbar.variant).toBe('error');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
test('Editing a user to have the same email as another user should not be allowed', async ({
|
||||
adminCreateUserPage,
|
||||
adminEditUserPage,
|
||||
adminUsersPage,
|
||||
page,
|
||||
}) => {
|
||||
adminCreateUserPage.seed(9300);
|
||||
const user1 = adminCreateUserPage.generateUser();
|
||||
const user2 = adminCreateUserPage.generateUser();
|
||||
await test.step('Create the first user', async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(user1.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(user1.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page
|
||||
.getByRole('option', { name: 'Admin' })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await adminCreateUserPage.expectCreateUserSuccessAlertToBeVisible();
|
||||
});
|
||||
|
||||
test(
|
||||
'Editing a user to have the same email as another user should not be allowed',
|
||||
async ({
|
||||
adminCreateUserPage, adminEditUserPage, adminUsersPage, page
|
||||
}) => {
|
||||
adminCreateUserPage.seed(9300);
|
||||
const user1 = adminCreateUserPage.generateUser();
|
||||
const user2 = adminCreateUserPage.generateUser();
|
||||
await test.step(
|
||||
'Create the first user',
|
||||
async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(user1.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(user1.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page.getByRole(
|
||||
'option', { name: 'Admin' }
|
||||
).click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-create-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
}
|
||||
);
|
||||
await test.step('Create the second user', async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(user2.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(user2.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page
|
||||
.getByRole('option', { name: 'Admin' })
|
||||
.click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
await adminCreateUserPage.expectCreateUserSuccessAlertToBeVisible();
|
||||
});
|
||||
|
||||
await test.step(
|
||||
'Create the second user',
|
||||
async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.createUserButton.click();
|
||||
await adminCreateUserPage.fullNameInput.fill(user2.fullName);
|
||||
await adminCreateUserPage.emailInput.fill(user2.email);
|
||||
await adminCreateUserPage.roleInput.click();
|
||||
await adminCreateUserPage.page.getByRole(
|
||||
'option', { name: 'Admin' }
|
||||
).click();
|
||||
await adminCreateUserPage.createButton.click();
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-create-user-success'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('success');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
}
|
||||
);
|
||||
await test.step('Try editing the second user to have the email of the first user', async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.findUserPageWithEmail(user2.email);
|
||||
let userRow = await adminUsersPage.getUserRowByEmail(user2.email);
|
||||
await adminUsersPage.clickEditUser(userRow);
|
||||
await adminEditUserPage.waitForLoad(user2.fullName);
|
||||
await adminEditUserPage.emailInput.fill(user1.email);
|
||||
const editPageUrl = page.url();
|
||||
await adminEditUserPage.updateButton.click();
|
||||
|
||||
await test.step(
|
||||
'Try editing the second user to have the email of the first user',
|
||||
async () => {
|
||||
await adminUsersPage.navigateTo();
|
||||
await adminUsersPage.findUserPageWithEmail(user2.email);
|
||||
let userRow = await adminUsersPage.getUserRowByEmail(user2.email);
|
||||
await adminUsersPage.clickEditUser(userRow);
|
||||
await adminEditUserPage.waitForLoad(user2.fullName);
|
||||
await adminEditUserPage.emailInput.fill(user1.email);
|
||||
const editPageUrl = page.url();
|
||||
await adminEditUserPage.updateButton.click();
|
||||
|
||||
const snackbar = await adminUsersPage.getSnackbarData(
|
||||
'snackbar-error'
|
||||
);
|
||||
await expect(snackbar.variant).toBe('error');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
await expect(page.url()).toBe(editPageUrl);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
const snackbar = await adminUsersPage.getSnackbarData('snackbar-error');
|
||||
await expect(snackbar.variant).toBe('error');
|
||||
await adminUsersPage.closeSnackbar();
|
||||
await expect(page.url()).toBe(editPageUrl);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user