mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-7360] aca playwright e2e file name rename with .e2e.ts extension (#3738)
* [ACS-7360] authentication updated to e2e.ts * [ACS-7360] copy-move-actions tests updated to e2e.ts * [ACS-7360] create-actions tests updated to e2e.ts * [ACS-7360] folder-rules tests updated to e2e.ts * [ACS-7360] info-drawer tests updates to e2e.ts * [ACS-7360] library-actions tests updated to e2e.ts * [ACS_7360] list-views tests updated to e2e.ts * [ACS-7360] navigation tests updated to e2e.ts * [ACS-7360] pagination tests updated to e2e.ts * [ACS-7360] search tests updated to e2e.ts * [ACS-7360] share-actions tests updated to e2e.ts * [ACS-7360] special-permissions tests updated to e2e.ts * [ACS-7360] viewer tests updated to e2e.ts * [ACS-7360] replaced every .spec.ts and .test.ts with .e2e.ts * [ACS-7360] undo .spec.ts chages for non test files * [ACS-7360] hardcoded credentials sonarcloud fix 1 * [ACS-7360] hardcoded credentials sonarcloud fix 2
This commit is contained in:
201
e2e/playwright/viewer/src/tests/viewer.e2e.ts
Normal file
201
e2e/playwright/viewer/src/tests/viewer.e2e.ts
Normal file
@@ -0,0 +1,201 @@
|
||||
/*!
|
||||
* 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,
|
||||
FavoritesPageApi,
|
||||
FileActionsApi,
|
||||
LoginPage,
|
||||
NodesApi,
|
||||
SharedLinksApi,
|
||||
SitesApi,
|
||||
test,
|
||||
TEST_FILES,
|
||||
timeouts,
|
||||
Utils
|
||||
} from '@alfresco/playwright-shared';
|
||||
import { Site } from '@alfresco/js-api';
|
||||
|
||||
test.describe('viewer file', () => {
|
||||
const username = `user-${Utils.random()}`;
|
||||
const randomDocxName = `${TEST_FILES.DOCX.name}-${Utils.random()}`;
|
||||
const siteUser = `siteUser-${Utils.random()}`;
|
||||
const fileInSite = TEST_FILES.DOCX.name;
|
||||
const siteAdmin = `siteAdmin-${Utils.random()}`;
|
||||
const fileAdmin = TEST_FILES.XLSX.name;
|
||||
let fileAdminId: string;
|
||||
let docLibId: string;
|
||||
let docLibSiteUserId: string;
|
||||
let folderId: string;
|
||||
let fileDocxId: string;
|
||||
let nodesApi: NodesApi;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
test.setTimeout(timeouts.extendedTest);
|
||||
const randomFolderName = `playwright-folder-${Utils.random()}`;
|
||||
const apiClientFactory = new ApiClientFactory();
|
||||
await apiClientFactory.setUpAcaBackend('admin');
|
||||
await apiClientFactory.createUser({ username });
|
||||
nodesApi = await NodesApi.initialize(username, username);
|
||||
const fileActionApi = await FileActionsApi.initialize(username, username);
|
||||
const shareActions = await SharedLinksApi.initialize(username, username);
|
||||
const favoritesActions = await FavoritesPageApi.initialize(username, username);
|
||||
const siteActionsUser = await SitesApi.initialize(username, username);
|
||||
const siteActionsAdmin = await SitesApi.initialize('admin');
|
||||
const fileActionApiAdmin = await FileActionsApi.initialize('admin');
|
||||
const node = await nodesApi.createFolder(randomFolderName);
|
||||
folderId = node.entry.id;
|
||||
const fileDoc = await fileActionApi.uploadFile(TEST_FILES.DOCX.path, randomDocxName, folderId);
|
||||
fileDocxId = fileDoc.entry.id;
|
||||
const consumerFavoritesTotalItems = await favoritesActions.getFavoritesTotalItems(username);
|
||||
await shareActions.shareFileById(fileDocxId);
|
||||
await favoritesActions.addFavoriteById('file', fileDocxId);
|
||||
|
||||
await siteActionsAdmin.createSite(siteAdmin, Site.VisibilityEnum.PRIVATE);
|
||||
docLibId = await siteActionsAdmin.getDocLibId(siteAdmin);
|
||||
fileAdminId = (await fileActionApiAdmin.uploadFile(TEST_FILES.DOCX.path, fileAdmin, docLibId)).entry.id;
|
||||
|
||||
await siteActionsUser.createSite(siteUser, Site.VisibilityEnum.PUBLIC);
|
||||
docLibSiteUserId = await siteActionsUser.getDocLibId(siteUser);
|
||||
await fileActionApi.uploadFile(TEST_FILES.DOCX.path, fileInSite, docLibSiteUserId);
|
||||
|
||||
await Promise.all([
|
||||
favoritesActions.isFavoriteWithRetry(username, fileDocxId, { expect: true }),
|
||||
favoritesActions.waitForApi(username, { expect: consumerFavoritesTotalItems + 2 })
|
||||
]);
|
||||
await shareActions.waitForFilesToBeShared([fileDocxId]);
|
||||
await fileActionApi.waitForNodes(randomDocxName, { expect: 1 });
|
||||
});
|
||||
|
||||
test.beforeEach(async ({ personalFiles, page }) => {
|
||||
const loginPage = new LoginPage(page);
|
||||
await loginPage.loginUser(
|
||||
{ username, password: username },
|
||||
{
|
||||
withNavigation: true,
|
||||
waitForLoading: true
|
||||
}
|
||||
);
|
||||
await personalFiles.navigate({ remoteUrl: `#/personal-files/${folderId}` });
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
await nodesApi.deleteCurrentUserNodes();
|
||||
});
|
||||
|
||||
test('[C279269] Viewer opens on double clicking on a file from Personal Files', async ({ personalFiles }) => {
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
|
||||
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
|
||||
});
|
||||
|
||||
test('[C279270] Viewer opens when clicking the View action for a file', async ({ personalFiles }) => {
|
||||
await personalFiles.dataTable.getRowByName(randomDocxName).click();
|
||||
await personalFiles.acaHeader.viewButton.click();
|
||||
await personalFiles.dataTable.spinnerWaitForReload();
|
||||
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
|
||||
});
|
||||
|
||||
test('[C279283] The viewer general elements are displayed', async ({ personalFiles }) => {
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
|
||||
expect(await personalFiles.viewer.isViewerOpened()).toBe(true);
|
||||
await personalFiles.dataTable.spinnerWaitForReload();
|
||||
expect(await personalFiles.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
|
||||
expect(await personalFiles.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
|
||||
});
|
||||
|
||||
test('[C279271] Close the viewer', async ({ personalFiles }) => {
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
|
||||
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
|
||||
expect(await personalFiles.viewer.getCloseButtonTooltip()).toEqual('Close');
|
||||
await personalFiles.viewer.closeButtonLocator.click();
|
||||
expect(await personalFiles.dataTable.getCellLinkByName(randomDocxName).isVisible(), 'Viewer did not close').toBe(true);
|
||||
});
|
||||
|
||||
test('[C284636] Viewer opens for a file from Recent Files', async ({ personalFiles, recentFilesPage }) => {
|
||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName);
|
||||
expect(await personalFiles.viewer.getCloseButtonTooltip()).toEqual('Close');
|
||||
await recentFilesPage.navigate();
|
||||
await recentFilesPage.reload();
|
||||
await recentFilesPage.dataTable.performClickFolderOrFileToOpen(randomDocxName);
|
||||
expect(await recentFilesPage.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
|
||||
expect(await recentFilesPage.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
|
||||
expect(await recentFilesPage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
|
||||
});
|
||||
|
||||
test('[C279175] Viewer opens for a file from Search Results', async ({ personalFiles, searchPage }) => {
|
||||
await personalFiles.acaHeader.searchButton.click();
|
||||
await searchPage.searchInput.searchButton.click();
|
||||
await searchPage.searchOverlay.checkFilesAndFolders();
|
||||
await searchPage.searchOverlay.searchFor(randomDocxName);
|
||||
await searchPage.reload({ waitUntil: 'domcontentloaded' });
|
||||
await searchPage.dataTable.goThroughPagesLookingForRowWithName(randomDocxName);
|
||||
await searchPage.searchInput.performDoubleClickFolderOrFileToOpen(randomDocxName);
|
||||
expect(await searchPage.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
|
||||
expect(await searchPage.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
|
||||
expect(await searchPage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
|
||||
});
|
||||
|
||||
test('[C279285] Viewer opens when accessing the preview URL for a file', async ({ personalFiles }) => {
|
||||
const previewURL = `#/personal-files/${folderId}/(viewer:view/${fileDocxId})`;
|
||||
await personalFiles.navigate({ remoteUrl: previewURL });
|
||||
await personalFiles.dataTable.spinnerWaitForReload();
|
||||
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
|
||||
expect(await personalFiles.viewer.fileTitleButtonLocator.innerText()).toEqual(randomDocxName);
|
||||
});
|
||||
|
||||
test('[C284635] Viewer opens for a file from Shared Files', async ({ sharedPage }) => {
|
||||
await sharedPage.navigate();
|
||||
await sharedPage.reload({ waitUntil: 'domcontentloaded' });
|
||||
await sharedPage.dataTable.goThroughPagesLookingForRowWithName(randomDocxName);
|
||||
await sharedPage.dataTable.performClickFolderOrFileToOpen(randomDocxName);
|
||||
expect(await sharedPage.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
|
||||
expect(await sharedPage.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
|
||||
expect(await sharedPage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
|
||||
});
|
||||
|
||||
test('[C284634] Viewer opens for a file from Favorites', async ({ favoritePage }) => {
|
||||
await favoritePage.navigate({ waitUntil: 'domcontentloaded' });
|
||||
await favoritePage.dataTable.goThroughPagesLookingForRowWithName(randomDocxName);
|
||||
await favoritePage.dataTable.performClickFolderOrFileToOpen(randomDocxName);
|
||||
expect(await favoritePage.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
|
||||
expect(await favoritePage.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
|
||||
expect(await favoritePage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
|
||||
});
|
||||
|
||||
test('[C279287] Viewer does not open when accessing the preview URL for a file without permissions', async ({ personalFiles }) => {
|
||||
const previewURL = `#/libraries/${docLibId}/(viewer:view/${fileAdminId})`;
|
||||
await personalFiles.navigate({ remoteUrl: `${previewURL}` });
|
||||
expect(await personalFiles.viewer.viewerLocator.isVisible(), 'Viewer should not be opened!').toBe(false);
|
||||
});
|
||||
|
||||
test('[C284633] Viewer opens for a file from File Libraries', async ({ myLibrariesPage }) => {
|
||||
await myLibrariesPage.navigate();
|
||||
await myLibrariesPage.dataTable.performClickFolderOrFileToOpen(siteUser);
|
||||
await myLibrariesPage.dataTable.performClickFolderOrFileToOpen(fileInSite);
|
||||
expect(await myLibrariesPage.viewer.isViewerOpened(), 'Viewer is not opened').toBe(true);
|
||||
expect(await myLibrariesPage.viewer.isCloseButtonDisplayed(), 'Close button is not displayed').toBe(true);
|
||||
expect(await myLibrariesPage.viewer.isFileTitleDisplayed(), 'File title is not displayed').toBe(true);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user