MichalKinas 8931a295c6
[ACS-9102] Local ACS deployment for E2Es (#4324)
* [ACS-9102] Local ACS deployment draft

* [ACS-9102] Move ACS deployment to composite action

* [ACS-9102] Remove obsolete checks

* [ACS-9102] Proper secrets for ACS deployment

* [ACS-9102] Add required shell property

* [ACS-9102] Use fixed acs deployment version

* [ACS-9102] Proper acs deployment tag

* [ACS-9102] Add required shell property

* [ACS-9102] Fix helm install params

* [ACS-9102] Remove obsolete checkout

* [ACS-9102] Use more powerful runner for E2Es

* [ACS-9102] Introduce temp secrets

* test curl localhost

* skip n-1 matrix jobs

* test ipv4 first

* [ACS-9102] Adjust Playwright E2E host

* [ACS-9102] Bring back matrix job

* disable unnecessary acs components

* debug ingress after tests run

* [ACS-9102] Fix folder-rules test suite

* [ACS-9102] Fix part of viewer test suite

* [ACS-9102] Additional E2E fixes

* [ACS-9102] fixes for e2es -> empty-list and search

* [ACS-9102] more fixes for e2es and github actions artifacts added for easier debugging

* [ACS-9102] removed artifacts from GHA

* print all logs

* [ACS-9102] Remove outdated secrets

* [ACS-9102] Remove after-e2e action

* do not wait for reindexing

* test on latest runner

* Always debug ingress logs

* avoid sleep waiting for app startup

* cleanup unnecessary action input type

* fixup indent

* test with latest acs alpha

* Revert "do not wait for reindexing"

This reverts commit 86ca54de33a6b5bf1da65202caac5798b5f88d51.

* [ACS-9102] Exclude unstable test cases

* [ACS-9102] Exclude unstable test cases

* [ACS-9102] Exclude unstable test cases

---------

Co-authored-by: Giovanni Toraldo <giovanni.toraldo@hyland.com>
Co-authored-by: Adam Świderski <adam.tomasz.swiderski@gmail.com>
2025-01-15 11:34:03 +01:00

233 lines
11 KiB
TypeScript

/*!
* Copyright © 2005-2024 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,
NodesApi,
SharedLinksApi,
SitesApi,
test,
TEST_FILES,
timeouts,
Utils,
TrashcanApi
} from '@alfresco/aca-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;
let trashcanApi: TrashcanApi;
let siteActionsAdmin: SitesApi;
let siteActionsUser: SitesApi;
test.beforeAll(async () => {
test.setTimeout(timeouts.extendedTest);
const randomFolderName = `viewer-${Utils.random()}`;
const apiClientFactory = new ApiClientFactory();
await apiClientFactory.setUpAcaBackend('admin');
try {
await apiClientFactory.createUser({ username });
} catch (exception) {
if (JSON.parse(exception.message).error.statusCode !== 409) {
throw new Error(`----- beforeAll failed : ${exception}`);
}
}
nodesApi = await NodesApi.initialize(username, username);
const fileActionApi = await FileActionsApi.initialize(username, username);
trashcanApi = await TrashcanApi.initialize(username, username);
const shareActions = await SharedLinksApi.initialize(username, username);
const favoritesActions = await FavoritesPageApi.initialize(username, username);
siteActionsUser = await SitesApi.initialize(username, username);
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);
try {
await siteActionsAdmin.createSite(siteAdmin, Site.VisibilityEnum.PRIVATE);
} catch (exception) {
if (JSON.parse(exception.message).error.statusCode !== 409) {
throw new Error(`----- beforeAll failed : ${exception}`);
}
}
docLibId = await siteActionsAdmin.getDocLibId(siteAdmin);
try {
fileAdminId = (await fileActionApiAdmin.uploadFile(TEST_FILES.DOCX.path, fileAdmin, docLibId)).entry.id;
} catch (exception) {
if (JSON.parse(exception.message).error.statusCode !== 409) {
throw new Error(`----- beforeAll failed : ${exception}`);
}
}
try {
await siteActionsUser.createSite(siteUser, Site.VisibilityEnum.PUBLIC);
} catch (exception) {
if (JSON.parse(exception.message).error.statusCode !== 409) {
throw new Error(`----- beforeAll failed : ${exception}`);
}
}
docLibSiteUserId = await siteActionsUser.getDocLibId(siteUser);
try {
await fileActionApi.uploadFile(TEST_FILES.DOCX.path, fileInSite, docLibSiteUserId);
} catch (exception) {
if (JSON.parse(exception.message).error.statusCode !== 409) {
throw new Error(`----- beforeAll failed : ${exception}`);
}
}
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, loginPage }) => {
await Utils.tryLoginUser(loginPage, username, username, 'beforeEach failed');
await personalFiles.navigate({ remoteUrl: `#/personal-files/${folderId}` });
});
test.afterAll(async () => {
await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed', siteActionsUser, [docLibSiteUserId]);
await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed', siteActionsAdmin, [docLibId]);
});
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();
await expect(personalFiles.dataTable.getCellLinkByName(randomDocxName), 'Viewer did not close').toBeVisible();
});
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.clickSearchButton();
await searchPage.searchOverlay.checkFilesAndFolders();
await searchPage.searchOverlay.searchFor(randomDocxName);
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);
await expect(personalFiles.viewer.fileTitleButtonLocator).toHaveText(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}` });
await expect(personalFiles.viewer.viewerLocator, 'Viewer should not be opened!').toBeHidden();
});
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);
});
});