Merge pull request #2230 from automatisch/AUT-1372

chore: improve playwright pipeline
This commit is contained in:
Ali BARIN
2025-01-30 15:55:33 +01:00
committed by GitHub
18 changed files with 326 additions and 146 deletions

View File

@@ -43,7 +43,8 @@ test.describe('Admin Applications', () => {
await adminApplicationsPage.navigateTo();
});
test('Admin should be able to toggle Application settings', async ({
// TODO skip until https://github.com/automatisch/automatisch/pull/2244
test.skip('Admin should be able to toggle Application settings', async ({
adminApplicationsPage,
adminApplicationSettingsPage,
page,
@@ -181,7 +182,7 @@ 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
@@ -221,6 +222,7 @@ test.describe('Admin Applications', () => {
await adminApplicationOAuthClientsPage.openAuthClientsTab();
await adminApplicationOAuthClientsPage.openFirstAuthClientCreateForm();
const authClientForm = page.getByTestId('auth-client-form');
await authClientForm.locator(page.getByTestId('switch')).check();
await authClientForm
@@ -232,6 +234,7 @@ test.describe('Admin Applications', () => {
await authClientForm
.locator(page.locator('[name="clientSecret"]'))
.fill('redditClientSecret');
await adminApplicationOAuthClientsPage.submitAuthClientForm();
await adminApplicationOAuthClientsPage.authClientShouldBeVisible(
'redditAuthClient'

View File

@@ -22,17 +22,14 @@ test.describe('Role management page', () => {
await adminRolesPage.navigateTo();
await adminRolesPage.createRoleButton.click();
await adminCreateRolePage.isMounted();
await adminCreateRolePage.waitForPermissionsCatalogToVisible();
await adminCreateRolePage.nameInput.fill('Create Edit Test');
await adminCreateRolePage.descriptionInput.fill('Test description');
await adminCreateRolePage.createButton.click();
await adminCreateRolePage.snackbar.waitFor({
state: 'attached',
});
const snackbar = await adminCreateRolePage.getSnackbarData(
'snackbar-create-role-success'
);
await expect(snackbar.variant).toBe('success');
await adminCreateRolePage.closeSnackbar();
});
let roleRow =
@@ -55,14 +52,10 @@ test.describe('Role management page', () => {
await adminEditRolePage.nameInput.fill('Create Update Test');
await adminEditRolePage.descriptionInput.fill('Update test description');
await adminEditRolePage.updateButton.click();
await adminEditRolePage.snackbar.waitFor({
state: 'attached',
});
const snackbar = await adminEditRolePage.getSnackbarData(
'snackbar-edit-role-success'
);
await expect(snackbar.variant).toBe('success');
await adminEditRolePage.closeSnackbar();
});
roleRow =
@@ -87,14 +80,10 @@ test.describe('Role management page', () => {
state: 'attached',
});
await deleteModal.deleteButton.click();
await adminRolesPage.snackbar.waitFor({
state: 'attached',
});
const snackbar = await adminRolesPage.getSnackbarData(
'snackbar-delete-role-success'
);
await expect(snackbar.variant).toBe('success');
await adminRolesPage.closeSnackbar();
await deleteModal.modal.waitFor({
state: 'detached',
});
@@ -169,16 +158,13 @@ test.describe('Role management page', () => {
await test.step('Create a new role', async () => {
await adminRolesPage.createRoleButton.click();
await adminCreateRolePage.isMounted();
await adminCreateRolePage.waitForPermissionsCatalogToVisible();
await adminCreateRolePage.nameInput.fill('Delete Role');
await adminCreateRolePage.createButton.click();
await adminCreateRolePage.snackbar.waitFor({
state: 'attached',
});
const snackbar = await adminCreateRolePage.getSnackbarData(
'snackbar-create-role-success'
);
await expect(snackbar.variant).toBe('success');
await adminCreateRolePage.closeSnackbar();
});
await test.step('Create a new user with the "Delete Role" role', async () => {
@@ -222,14 +208,10 @@ test.describe('Role management page', () => {
.getByRole('option', { name: 'Admin' })
.click();
await adminEditUserPage.updateButton.click();
await adminEditUserPage.snackbar.waitFor({
state: 'attached',
});
const snackbar = await adminEditUserPage.getSnackbarData(
'snackbar-edit-user-success'
);
await expect(snackbar.variant).toBe('success');
await adminEditUserPage.closeSnackbar();
});
await test.step('Delete the original role', async () => {
await adminRolesPage.navigateTo();
@@ -237,14 +219,10 @@ test.describe('Role management page', () => {
const modal = await adminRolesPage.clickDeleteRole(row);
await expect(modal.modal).toBeVisible();
await modal.deleteButton.click();
await adminRolesPage.snackbar.waitFor({
state: 'attached',
});
const snackbar = await adminRolesPage.getSnackbarData(
'snackbar-delete-role-success'
);
await expect(snackbar.variant).toBe('success');
await adminRolesPage.closeSnackbar();
});
});
@@ -258,16 +236,13 @@ test.describe('Role management page', () => {
await test.step('Create a new role', async () => {
await adminRolesPage.createRoleButton.click();
await adminCreateRolePage.isMounted();
await adminCreateRolePage.waitForPermissionsCatalogToVisible();
await adminCreateRolePage.nameInput.fill('Cannot Delete Role');
await adminCreateRolePage.createButton.click();
await adminCreateRolePage.snackbar.waitFor({
state: 'attached',
});
const snackbar = await adminCreateRolePage.getSnackbarData(
'snackbar-create-role-success'
);
await expect(snackbar.variant).toBe('success');
await adminCreateRolePage.closeSnackbar();
});
await test.step('Create a new user with this role', async () => {
await adminUsersPage.navigateTo();
@@ -287,6 +262,7 @@ test.describe('Role management page', () => {
});
await adminCreateUserPage.expectCreateUserSuccessAlertToBeVisible();
});
await test.step('Delete this user', async () => {
await adminUsersPage.navigateTo();
const row = await adminUsersPage.findUserPageWithEmail(
@@ -294,14 +270,10 @@ test.describe('Role management page', () => {
);
const modal = await adminUsersPage.clickDeleteUser(row);
await modal.deleteButton.click();
await adminUsersPage.snackbar.waitFor({
state: 'attached',
});
const snackbar = await adminUsersPage.getSnackbarData(
'snackbar-delete-user-success'
);
await expect(snackbar.variant).toBe('success');
await adminUsersPage.closeSnackbar();
});
await test.step('Try deleting this role', async () => {
await adminRolesPage.navigateTo();
@@ -309,7 +281,6 @@ test.describe('Role management page', () => {
const modal = await adminRolesPage.clickDeleteRole(row);
await modal.deleteButton.click();
await expect(modal.deleteAlert).toHaveCount(1);
await adminRolesPage.closeSnackbar();
});
});
});
@@ -327,16 +298,13 @@ test('Accessibility of role management page', async ({
await adminRolesPage.navigateTo();
await adminRolesPage.createRoleButton.click();
await adminCreateRolePage.isMounted();
await adminCreateRolePage.waitForPermissionsCatalogToVisible();
await adminCreateRolePage.nameInput.fill('Basic Test');
await adminCreateRolePage.createButton.click();
await adminCreateRolePage.snackbar.waitFor({
state: 'attached',
});
const snackbar = await adminCreateRolePage.getSnackbarData(
'snackbar-create-role-success'
);
await expect(snackbar.variant).toBe('success');
await adminCreateRolePage.closeSnackbar();
});
await test.step('Create a new user with the basic role', async () => {
@@ -358,9 +326,7 @@ test('Accessibility of role management page', async ({
await test.step('Logout and login to the basic role user', async () => {
const acceptInvitationLink = await adminCreateUserPage.acceptInvitationLink;
console.log(acceptInvitationLink);
const acceptInvitationUrl = await acceptInvitationLink.textContent();
console.log(acceptInvitationUrl);
const acceptInvitatonToken = acceptInvitationUrl.split('?token=')[1];
await page.getByTestId('profile-menu-button').click();
@@ -416,10 +382,10 @@ test('Accessibility of role management page', async ({
await adminEditUserPage.roleInput.click();
await adminEditUserPage.page.getByRole('option', { name: 'Admin' }).click();
await adminEditUserPage.updateButton.click();
await adminEditUserPage.snackbar.waitFor({
state: 'attached',
});
await adminEditUserPage.closeSnackbar();
const snackbar = await adminEditUserPage.getSnackbarData(
'snackbar-edit-user-success'
);
await expect(snackbar.variant).toBe('success');
});
await test.step('Delete the role', async () => {
@@ -431,14 +397,10 @@ test('Accessibility of role management page', async ({
state: 'attached',
});
await deleteModal.deleteButton.click();
await adminRolesPage.snackbar.waitFor({
state: 'attached',
});
const snackbar = await adminRolesPage.getSnackbarData(
'snackbar-delete-role-success'
);
await expect(snackbar.variant).toBe('success');
await adminRolesPage.closeSnackbar();
await deleteModal.modal.waitFor({
state: 'detached',
});

View File

@@ -7,7 +7,7 @@ const { test, expect } = require('../../fixtures/index');
test.describe('User management page', () => {
test.beforeEach(async ({ adminUsersPage }) => {
await adminUsersPage.navigateTo();
await adminUsersPage.closeSnackbar();
await adminUsersPage.closeAllSnackbars();
});
test('User creation and deletion process', async ({
@@ -36,7 +36,6 @@ test.describe('User management page', () => {
await adminCreateUserPage.invitationEmailInfoAlert.waitFor({
state: 'attached',
});
await adminCreateUserPage.expectCreateUserSuccessAlertToBeVisible();
await adminUsersPage.navigateTo();
});
@@ -62,7 +61,6 @@ test.describe('User management page', () => {
'snackbar-edit-user-success'
);
await expect(snackbar.variant).toBe('success');
await adminUsersPage.closeSnackbar();
await adminUsersPage.findUserPageWithEmail(user.email);
userRow = await adminUsersPage.getUserRowByEmail(user.email);
@@ -80,8 +78,6 @@ test.describe('User management page', () => {
'snackbar-delete-user-success'
);
await expect(snackbar.variant).toBe('success');
await adminUsersPage.closeSnackbar();
await expect(userRow).not.toBeVisible(false);
});
});
@@ -91,7 +87,6 @@ test.describe('User management page', () => {
}) => {
adminCreateUserPage.seed(9100);
const testUser = adminCreateUserPage.generateUser();
await test.step('Create the test user', async () => {
await adminUsersPage.navigateTo();
await adminUsersPage.createUserButton.click();
@@ -117,8 +112,6 @@ test.describe('User management page', () => {
);
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 () => {

View File

@@ -1,24 +1,60 @@
const { request } = require('@playwright/test');
const { test, expect } = require('../../fixtures/index');
const {AddMattermostConnectionModal} = require('../../fixtures/apps/mattermost/add-mattermost-connection-modal');
const {
AddMattermostConnectionModal,
} = require('../../fixtures/apps/mattermost/add-mattermost-connection-modal');
const {
createFlow,
updateFlowName,
getFlow,
updateFlowStep,
testStep,
} = require('../../helpers/flow-api-helper');
const { getToken } = require('../../helpers/auth-api-helper');
test.describe('Pop-up message on connections', () => {
test.beforeEach(async ({ flowEditorPage, page }) => {
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(page.getByTestId('flow-step')).toHaveCount(2);
const apiRequest = await request.newContext();
const tokenJsonResponse = await getToken(apiRequest);
const token = tokenJsonResponse.data.token;
await flowEditorPage.flowName.click();
await flowEditorPage.flowNameInput.fill('PopupFlow');
await flowEditorPage.createWebhookTrigger(true);
let flow = await createFlow(apiRequest, token);
const flowId = flow.data.id;
await updateFlowName(apiRequest, token, flowId);
flow = await getFlow(apiRequest, token, flowId);
const flowSteps = flow.data.steps;
const triggerStepId = flowSteps.find((step) => step.type === 'trigger').id;
const actionStepId = flowSteps.find((step) => step.type === 'action').id;
await flowEditorPage.chooseAppAndEvent('Mattermost', 'Send a message to channel');
await expect(flowEditorPage.continueButton).toHaveCount(1);
await expect(flowEditorPage.continueButton).not.toBeEnabled();
const triggerStep = await updateFlowStep(apiRequest, token, triggerStepId, {
appKey: 'webhook',
key: 'catchRawWebhook',
parameters: {
workSynchronously: false,
},
});
await apiRequest.get(triggerStep.data.webhookUrl);
await testStep(apiRequest, token, triggerStepId);
await updateFlowStep(apiRequest, token, actionStepId, {
appKey: 'mattermost',
key: 'sendMessageToChannel',
});
await testStep(apiRequest, token, actionStepId);
await page.reload();
const flowRow = await page.getByTestId('flow-row').filter({
hasText: flowId,
});
await flowRow.click();
const flowTriggerStep = await page.getByTestId('flow-step').nth(1);
await flowTriggerStep.click();
await page.getByText('Choose connection').click();
await flowEditorPage.connectionAutocomplete.click();
await flowEditorPage.addNewConnectionItem.click(); });
await flowEditorPage.addNewConnectionItem.click();
});
test('should show error to remind to enable pop-up on connection create', async ({
page,
@@ -28,7 +64,7 @@ test.describe('Pop-up message on connections', () => {
// Inject script to override window.open
await page.evaluate(() => {
// eslint-disable-next-line no-undef
window.open = function() {
window.open = function () {
console.log('Popup blocked!');
return null;
};
@@ -37,8 +73,10 @@ test.describe('Pop-up message on connections', () => {
await addMattermostConnectionModal.fillConnectionForm();
await addMattermostConnectionModal.submitConnectionForm();
await expect(page.getByTestId("add-connection-error")).toHaveCount(1);
await expect(page.getByTestId("add-connection-error")).toHaveText('Make sure pop-ups are enabled in your browser.');
await expect(page.getByTestId('add-connection-error')).toHaveCount(1);
await expect(page.getByTestId('add-connection-error')).toHaveText(
'Make sure pop-ups are enabled in your browser.'
);
});
test('should not show pop-up error if pop-ups are enabled on connection create', async ({
@@ -51,13 +89,15 @@ test.describe('Pop-up message on connections', () => {
await addMattermostConnectionModal.submitConnectionForm();
const popup = await popupPromise;
await expect(popup.url()).toContain("mattermost");
await expect(page.getByTestId("add-connection-error")).toHaveCount(0);
await expect(popup.url()).toContain('mattermost');
await expect(page.getByTestId('add-connection-error')).toHaveCount(0);
await test.step('Should show error on failed credentials verification', async () => {
await popup.close();
await expect(page.getByTestId("add-connection-error")).toHaveCount(1);
await expect(page.getByTestId("add-connection-error")).toHaveText('Error occured while verifying credentials!');
await expect(page.getByTestId('add-connection-error')).toHaveCount(1);
await expect(page.getByTestId('add-connection-error')).toHaveText(
'Error occured while verifying credentials!'
);
});
});
});
});

View File

@@ -1,63 +1,48 @@
const { request } = require('@playwright/test');
const { publicTest, expect } = require('../../fixtures/index');
const { AdminUsersPage } = require('../../fixtures/admin/users-page');
const { MyProfilePage } = require('../../fixtures/my-profile-page');
const { LoginPage } = require('../../fixtures/login-page');
const { addUser, acceptInvitation } = require('../../helpers/user-api-helper');
const { getToken } = require('../../helpers/auth-api-helper');
publicTest.describe('My Profile', () => {
let testUser;
publicTest.beforeEach(
async ({ acceptInvitationPage, adminCreateUserPage, loginPage, page }) => {
let acceptInvitationLink;
publicTest.beforeEach(async ({ adminCreateUserPage, loginPage, page }) => {
let addUserResponse;
const apiRequest = await request.newContext();
adminCreateUserPage.seed(
Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)
adminCreateUserPage.seed(
Math.ceil(Math.random() * Number.MAX_SAFE_INTEGER)
);
testUser = adminCreateUserPage.generateUser();
await publicTest.step('create new user', async () => {
const tokenJsonResponse = await getToken(apiRequest);
addUserResponse = await addUser(
apiRequest,
tokenJsonResponse.data.token,
{
fullName: testUser.fullName,
email: testUser.email,
}
);
testUser = adminCreateUserPage.generateUser();
});
const adminUsersPage = new AdminUsersPage(page);
const myProfilePage = new MyProfilePage(page);
await publicTest.step('login as Admin', async () => {
await loginPage.login();
await expect(loginPage.page).toHaveURL('/flows');
await publicTest.step('accept invitation', async () => {
let acceptToken = addUserResponse.data.acceptInvitationUrl.split('=')[1];
await acceptInvitation(apiRequest, {
token: acceptToken,
password: LoginPage.defaultPassword,
});
});
await publicTest.step('create new 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();
});
await publicTest.step('copy invitation link', async () => {
const invitationMessage =
await adminCreateUserPage.acceptInvitationLink;
acceptInvitationLink = await invitationMessage.getAttribute('href');
});
await publicTest.step('logout', async () => {
await myProfilePage.logout();
});
await publicTest.step('accept invitation', async () => {
await page.goto(acceptInvitationLink);
await acceptInvitationPage.acceptInvitation(LoginPage.defaultPassword);
});
await publicTest.step('login as new Admin', async () => {
await loginPage.login(testUser.email, LoginPage.defaultPassword);
await expect(loginPage.loginButton).not.toBeVisible();
await expect(page).toHaveURL('/flows');
});
}
);
await publicTest.step('login as new Admin', async () => {
await loginPage.login(testUser.email, LoginPage.defaultPassword);
await expect(loginPage.loginButton).not.toBeVisible();
await expect(page).toHaveURL('/flows');
});
});
publicTest('user should be able to change own data', async ({ page }) => {
const myProfilePage = new MyProfilePage(page);