Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-6668] [ACS-6669] e2e migration - Info Drawer general and library properties tests #3628

Merged
merged 22 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f75255f
[ACS-5882] infoDrawer comments tests migrated to Playwright
datguychen Jan 26, 2024
adb240d
[ACS-5882] fixed issues from pull request comments
datguychen Jan 26, 2024
eeacbf0
Protractor to Playwright info-drawer tests
katarzynakita Feb 1, 2024
ec4b0e9
Protractor to Playwright info-drawer tests
katarzynakita Feb 6, 2024
d2f615c
Fixed general tests
katarzynakita Feb 6, 2024
d2e8957
Fixes for library-properties tests
katarzynakita Feb 8, 2024
f9554a8
Fixes for library-properties tests
katarzynakita Feb 9, 2024
d8f9c1f
[ACS-5882] infoDrawer comments tests migrated to Playwright
datguychen Jan 26, 2024
f20024b
[ACS-5882] fixed issues from pull request comments
datguychen Jan 26, 2024
1e124d4
Protractor to Playwright info-drawer tests
katarzynakita Feb 1, 2024
3f80a17
Fixed general tests
katarzynakita Feb 6, 2024
ea815e7
[ACS-5882] infoDrawer comments tests migrated to Playwright
datguychen Jan 26, 2024
37b582b
Fixed general tests
katarzynakita Feb 6, 2024
d769370
Removed duplicated code from general test
katarzynakita Feb 9, 2024
194eb7e
Reverted lost selectors
katarzynakita Feb 9, 2024
e7e9edb
moved duplicated blocks of code
katarzynakita Feb 9, 2024
edf7000
Fixed duplicated code blocks
katarzynakita Feb 11, 2024
ccc862c
Fixed duplicated blocks
katarzynakita Feb 11, 2024
caa96c8
Fixed after PR comments
katarzynakita Feb 12, 2024
3ae343a
Fixed not.toBeEnabled methods
katarzynakita Feb 12, 2024
18f572c
Fixes after PR comments, removed afterEach blocks
katarzynakita Feb 12, 2024
3ce84af
Changed code blocks order
katarzynakita Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/playwright/info-drawer/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const config: PlaywrightTestConfig<CustomConfig> = {
name: 'Info Drawer',
testDir: './src/tests',
use: {
users: ['hruser', 'admin']
users: []
}
}
]
Expand Down
90 changes: 90 additions & 0 deletions e2e/playwright/info-drawer/src/tests/general.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*!
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { expect } from '@playwright/test';
import { ApiClientFactory, Utils, test, TrashcanApi, NodesApi, FileActionsApi } from '@alfresco/playwright-shared';

test.describe('Info Drawer - General', () => {
let fileActionsApi: FileActionsApi;
let trashcanApi: TrashcanApi;
let nodesApi: NodesApi;

const username = `user1-${Utils.random()}`;

test.beforeEach(async ({ loginPage }) => {
try {
await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true });
} catch (error) {
console.error(`beforeEach failed: ${error}`);
}
});

test.beforeAll(async () => {
try {
const apiClientFactory = new ApiClientFactory();
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
fileActionsApi = await FileActionsApi.initialize(username, username);
trashcanApi = await TrashcanApi.initialize(username, username);
nodesApi = await NodesApi.initialize(username, username);
} catch (error) {
console.error(`beforeAll failed: ${error}`);
}
});

test.afterAll(async () => {
try {
await trashcanApi.emptyTrashcan();
await nodesApi.deleteCurrentUserNodes();
} catch (error) {
console.error(`afterAll failed: ${error}`);
}
});

test('[C268999] Info drawer closes on page refresh', async ({ personalFiles }) => {
const parentFolder = `parent-${Utils.random()}`;
const file1 = `file1-${Utils.random()}.txt`;
const folder1 = `folder1-${Utils.random()}`;
const parentId = (await nodesApi.createFolder(parentFolder)).entry.id;

await nodesApi.createFile(file1, parentId);
await nodesApi.createFolder(folder1, parentId);
await fileActionsApi.waitForNodes(file1, { expect: 1 });
await personalFiles.navigate();
await expect(personalFiles.dataTable.getRowByName(parentFolder)).toBeVisible();
await personalFiles.dataTable.performClickFolderOrFileToOpen(parentFolder);
await personalFiles.dataTable.selectItem(file1);
await personalFiles.acaHeader.viewDetails.click();
await expect(personalFiles.infoDrawer.infoDrawerPanel).toBeVisible();

await personalFiles.reload({ waitUntil: 'load' });
await expect(personalFiles.infoDrawer.infoDrawerPanel).not.toBeVisible();
await personalFiles.dataTable.selectItem(file1);
await personalFiles.acaHeader.viewDetails.click();
await expect(personalFiles.infoDrawer.infoDrawerPanel).toBeVisible();

await personalFiles.reload({ waitUntil: 'load' });
await expect(personalFiles.infoDrawer.infoDrawerPanel).not.toBeVisible();
});
});
256 changes: 256 additions & 0 deletions e2e/playwright/info-drawer/src/tests/library-properties.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
/*!
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

import { expect } from '@playwright/test';
import { ApiClientFactory, Utils, test, SitesApi, QueriesApi, SITE_VISIBILITY, SITE_ROLES } from '@alfresco/playwright-shared';

test.describe('Library properties', () => {
let sitesApi: SitesApi;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sitesApi, username, user2, user3 and site are duplicated in describe for "non manager" - can we reuse instead of duplicating?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved it accordingly, user2 and user3 were not needed on the top

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please let me know if I need to fix the sitesApi too (because I'm not sure how)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katarzynakita I was thinking about something more or less like that structure. Thanks that all these variables like sitesApi, username, user2, user3, site etc. are not duplicated and beforeEach have less duplicated code too. You can also check if rest of code like afterEach etc. won't be possible too to write like that.

But basically in that solution you have one main describe with whole common code and two different describes for each part of e2es like "non manager" and "manager" describes.

test.describe('Library properties', () => {
  let sitesApi: SitesApi;
  let apiClientFactory: ApiClientFactory;

  const username = `user1-${Utils.random()}`;
  const site = {
    name: `site1-${Utils.random()}`,
    id: `site-id-${Utils.random()}`,
    visibility: SITE_VISIBILITY.MODERATED,
    description: 'my site description'
  };

  test.beforeAll(async () => {
    apiClientFactory = new ApiClientFactory();
    await apiClientFactory.setUpAcaBackend('admin');
    await apiClientFactory.createUser({ username });
    sitesApi = await SitesApi.initialize(username, username);
    await sitesApi.createSite(site.name, site.visibility, site.description, site.id);
  });

  test.describe('Manager', () => {
    const siteForUpdate = {
      name: `site2-${Utils.random()}`,
      id: `site-id-${Utils.random()}`,
      visibility: SITE_VISIBILITY.MODERATED,
      description: 'my initial description'
    };
    const siteDup = `site3-${Utils.random()}`;

    test.beforeAll(async () => {
      try {
        await sitesApi.createSite(siteForUpdate.name, siteForUpdate.visibility, siteForUpdate.description, siteForUpdate.id);
        await sitesApi.createSite(siteDup);
      } catch (error) {
        console.error(`beforeAll failed: ${error}`);
      }
    });
  });

  test.describe('Non manager', () => {
    const user2 = `user2-${Utils.random()}`;
    const user3 = `user3-${Utils.random()}`;

    test.beforeAll(async () => {
      try {
        await apiClientFactory.createUser({ username: user2 });
        await apiClientFactory.createUser({ username: user3 });
        await sitesApi.addSiteMember(site.id, user2, SITE_ROLES.SITE_COLLABORATOR.ROLE);
        await sitesApi.addSiteMember(site.id, user3, SITE_ROLES.SITE_MANAGER.ROLE);
      } catch (error) {
        console.error(`beforeAll failed: ${error}`);
      }
    });
  });
});


const username = `user1-${Utils.random()}`;
const site = {
name: `site1-${Utils.random()}`,
id: `site-id-${Utils.random()}`,
visibility: SITE_VISIBILITY.MODERATED,
description: 'my site description'
};
const siteForUpdate = {
name: `site2-${Utils.random()}`,
id: `site-id-${Utils.random()}`,
visibility: SITE_VISIBILITY.MODERATED,
description: 'my initial description'
};
const siteDup = `site3-${Utils.random()}`;

test.beforeEach(async ({ myLibrariesPage, loginPage }) => {
try {
await loginPage.loginUser({ username, password: username }, { withNavigation: true, waitForLoading: true });
await myLibrariesPage.navigate();
} catch (error) {
console.error(` beforeEach failed: ${error}`);
}
});

test.beforeAll(async () => {
try {
const apiClientFactory = new ApiClientFactory();
AleksanderSklorz marked this conversation as resolved.
Show resolved Hide resolved
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });

sitesApi = await SitesApi.initialize(username, username);
await sitesApi.createSite(site.name, site.visibility, site.description, site.id);
await sitesApi.createSite(siteForUpdate.name, siteForUpdate.visibility, siteForUpdate.description, siteForUpdate.id);
await sitesApi.createSite(siteDup);
} catch (error) {
console.error(`beforeAll failed: ${error}`);
}
});

test.afterAll(async () => {
await sitesApi.deleteSites([site.id, siteForUpdate.id, siteDup]);
});

test('[C289336] Info drawer opens for a library', async ({ myLibrariesPage }) => {
await expect(myLibrariesPage.dataTable.getRowByName(site.name)).toBeVisible();
await myLibrariesPage.dataTable.getRowByName(site.name).click();
await myLibrariesPage.acaHeader.viewDetails.click();

await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible();
expect(await myLibrariesPage.libraryDetails.headerTitle.textContent()).toEqual(site.name);
await expect(myLibrariesPage.libraryDetails.propertiesTab).toBeVisible();
await expect(myLibrariesPage.libraryDetails.nameField).toBeVisible();
await expect(myLibrariesPage.libraryDetails.idField).toBeVisible();
await expect(myLibrariesPage.libraryDetails.visibilityField).toBeVisible();
await expect(myLibrariesPage.libraryDetails.descriptionField).toBeVisible();

expect(await myLibrariesPage.libraryDetails.nameField.inputValue()).toEqual(site.name);
expect(await myLibrariesPage.libraryDetails.idField.inputValue()).toEqual(site.id);
expect((await myLibrariesPage.libraryDetails.visibilityField.textContent()).toUpperCase()).toEqual(site.visibility);
expect(await myLibrariesPage.libraryDetails.descriptionField.inputValue()).toEqual(site.description);
await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible();
});

test('[C289338] Editable properties', async ({ myLibrariesPage }) => {
await myLibrariesPage.dataTable.getRowByName(site.name).click();
await myLibrariesPage.acaHeader.viewDetails.click();
await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible();
await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible();

await myLibrariesPage.libraryDetails.editButton.click();
await expect(myLibrariesPage.libraryDetails.nameField).toBeVisible();
await expect(myLibrariesPage.libraryDetails.idField).not.toBeEditable();
await expect(myLibrariesPage.libraryDetails.visibilityField).toBeEditable();
await expect(myLibrariesPage.libraryDetails.descriptionField).toBeEditable();
await expect(myLibrariesPage.libraryDetails.cancelButton).toBeVisible();
await expect(myLibrariesPage.libraryDetails.updateButton).toBeVisible();
await expect(myLibrariesPage.libraryDetails.cancelButton).toBeEnabled();
await expect(myLibrariesPage.libraryDetails.updateButton).toBeDisabled();
});

test('[C289339] Edit site details', async ({ myLibrariesPage }) => {
const siteUpdated = {
name: `site-for-rename-${Utils.random()}`,
visibility: SITE_VISIBILITY.PRIVATE,
description: 'new description'
};

await myLibrariesPage.dataTable.getRowByName(siteForUpdate.name).click();
await myLibrariesPage.acaHeader.viewDetails.click();
await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible();
await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible();

await myLibrariesPage.libraryDetails.editButton.click();
await myLibrariesPage.libraryDetails.nameField.fill(siteUpdated.name);
await myLibrariesPage.libraryDetails.visibilityField.click();
await myLibrariesPage.libraryDetails.selectVisibility(siteUpdated.visibility);
await myLibrariesPage.libraryDetails.descriptionField.fill(siteUpdated.description);
await expect(myLibrariesPage.libraryDetails.updateButton).toBeEnabled();

await myLibrariesPage.libraryDetails.updateButton.click();
expect(await myLibrariesPage.snackBar.message.innerText()).toEqual('Library properties updated');
expect(await myLibrariesPage.dataTable.isItemPresent(siteUpdated.name)).toBe(true);
await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).not.toBeVisible();
expect((await sitesApi.getSite(siteForUpdate.id)).entry.title).toEqual(siteUpdated.name);
expect((await sitesApi.getSite(siteForUpdate.id)).entry.description).toEqual(siteUpdated.description);
expect((await sitesApi.getSite(siteForUpdate.id)).entry.visibility).toEqual(siteUpdated.visibility);
});

test('[C289340] Cancel editing a site', async ({ myLibrariesPage }) => {
const newName = `new-name-${Utils.random}`;
const newDesc = `new desc ${Utils.random}`;

await myLibrariesPage.dataTable.getRowByName(site.name).click();
await myLibrariesPage.acaHeader.viewDetails.click();
await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible();
await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible();

await myLibrariesPage.libraryDetails.editButton.click();
await myLibrariesPage.libraryDetails.nameField.fill(newName);
await myLibrariesPage.libraryDetails.visibilityField.click();
await myLibrariesPage.libraryDetails.selectVisibility(SITE_VISIBILITY.MODERATED);
await myLibrariesPage.libraryDetails.descriptionField.fill(newDesc);
await expect(myLibrariesPage.libraryDetails.updateButton).toBeEnabled();

await myLibrariesPage.libraryDetails.cancelButton.click();
expect(await myLibrariesPage.dataTable.isItemPresent(newName)).toBe(false);
expect(await myLibrariesPage.dataTable.isItemPresent(site.name)).toBe(true);
await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible();
});

test('[C289341] Warning appears when editing the name of the library by entering an existing name', async ({ myLibrariesPage }) => {
const queriesApi = await QueriesApi.initialize(username, username);

await queriesApi.waitForSites(site.name, { expect: 1 });
await myLibrariesPage.dataTable.getRowByName(siteDup).click();
await myLibrariesPage.acaHeader.viewDetails.click();
await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible();
await expect(myLibrariesPage.libraryDetails.editButton).toBeVisible();

await myLibrariesPage.libraryDetails.editButton.click();
await myLibrariesPage.libraryDetails.nameField.fill(site.name);
await expect(myLibrariesPage.libraryDetails.hintMessage).toBeVisible();
expect(await myLibrariesPage.libraryDetails.hintMessage.textContent()).toEqual('Library name already in use');
});

test('[C289342] Site name too long', async ({ myLibrariesPage }) => {
await myLibrariesPage.dataTable.getRowByName(site.name).click();
await myLibrariesPage.acaHeader.viewDetails.click();
await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible();

await myLibrariesPage.libraryDetails.editButton.click();
await myLibrariesPage.libraryDetails.nameField.fill(Utils.string257Long);
await expect(myLibrariesPage.libraryDetails.errorMessage).toBeVisible();
expect((await myLibrariesPage.libraryDetails.errorMessage.textContent()).trim()).toEqual('Use 256 characters or less for title');
await expect(myLibrariesPage.libraryDetails.updateButton).toBeDisabled();
});

test('[C289343] Site description too long', async ({ myLibrariesPage }) => {
await myLibrariesPage.dataTable.getRowByName(site.name).click();
await myLibrariesPage.acaHeader.viewDetails.click();
await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible();

await myLibrariesPage.libraryDetails.editButton.click();
await myLibrariesPage.libraryDetails.descriptionField.fill(Utils.string513Long);
await expect(myLibrariesPage.libraryDetails.errorMessage).toBeVisible();
expect((await myLibrariesPage.libraryDetails.errorMessage.textContent()).trim()).toEqual('Use 512 characters or less for description');
await expect(myLibrariesPage.libraryDetails.updateButton).toBeDisabled();
});
});

test.describe('Non manager', () => {
let sitesApi: SitesApi;

const username = `user1-${Utils.random()}`;
katarzynakita marked this conversation as resolved.
Show resolved Hide resolved
const user2 = `user2-${Utils.random()}`;
const user3 = `user3-${Utils.random()}`;
const site = {
name: `site1-${Utils.random()}`,
id: `site-id-${Utils.random()}`,
visibility: SITE_VISIBILITY.MODERATED,
description: 'my site description'
};

test.beforeAll(async () => {
try {
const apiClientFactory = new ApiClientFactory();
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser({ username });
await apiClientFactory.createUser({ username: user2 });
await apiClientFactory.createUser({ username: user3 });

sitesApi = await SitesApi.initialize(username, username);
await sitesApi.createSite(site.name, site.visibility, site.description, site.id);
await sitesApi.addSiteMember(site.id, user2, SITE_ROLES.SITE_COLLABORATOR.ROLE);
await sitesApi.addSiteMember(site.id, user3, SITE_ROLES.SITE_MANAGER.ROLE);
} catch (error) {
console.error(`beforeAll failed: ${error}`);
}
});

test.afterAll(async () => {
await sitesApi.deleteSites([site.id]);
});

test('[C289337] Info drawer button is not displayed when user is not the library manager', async ({ loginPage, myLibrariesPage }) => {
await loginPage.loginUser({ username: user2, password: user2 }, { withNavigation: true, waitForLoading: true });
await myLibrariesPage.navigate();

await myLibrariesPage.dataTable.getRowByName(site.name).click();
await expect(myLibrariesPage.acaHeader.viewDetails).not.toBeVisible();
});

test('[C289344] Error notification when editing with no rights', async ({ loginPage, myLibrariesPage }) => {
await loginPage.loginUser({ username: user3, password: user3 }, { withNavigation: true, waitForLoading: true });
await myLibrariesPage.navigate();

await myLibrariesPage.dataTable.getRowByName(site.name).click();
await myLibrariesPage.acaHeader.viewDetails.click();
await myLibrariesPage.libraryDetails.editButton.click();
await sitesApi.updateSiteMember(site.id, user3, SITE_ROLES.SITE_CONSUMER.ROLE);
await myLibrariesPage.libraryDetails.descriptionField.fill('new description');
await myLibrariesPage.libraryDetails.updateButton.click();

expect(await myLibrariesPage.snackBar.message.textContent()).toEqual('There was an error updating library properties');
});
});
2 changes: 2 additions & 0 deletions projects/aca-playwright-shared/src/api/api-client-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class ApiClientFactory {
public favorites: FavoritesApi;
public trashCan: TrashcanApi;
public commentsApi: CommentsApi;
public queriesApi: QueriesApi;

constructor() {
this.alfrescoApi = new AlfrescoApi(config);
Expand All @@ -108,6 +109,7 @@ export class ApiClientFactory {
this.favorites = new FavoritesApi(this.alfrescoApi);
this.trashCan = new TrashcanApi(this.alfrescoApi);
this.commentsApi = new CommentsApi(this.alfrescoApi);
this.queriesApi = new QueriesApi(this.alfrescoApi);

return this;
}
Expand Down
1 change: 1 addition & 0 deletions projects/aca-playwright-shared/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ export * from './sites-api';
export * from './node-content-tree';
export * from './search-api';
export * from './trashcan-api';
export * from './queries-api';
Loading
Loading