diff --git a/e2e/playwright/copy-move-actions/src/tests/copy.test.ts b/e2e/playwright/copy-move-actions/src/tests/copy.test.ts index 9c98dfac0..f1ba47356 100644 --- a/e2e/playwright/copy-move-actions/src/tests/copy.test.ts +++ b/e2e/playwright/copy-move-actions/src/tests/copy.test.ts @@ -88,6 +88,7 @@ test.describe('Copy actions', () => { }; test('[C217135] Copy a file', async ({ personalFiles }) => { + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFile); await copyContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy(); await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder); @@ -96,6 +97,7 @@ test.describe('Copy actions', () => { }); test('[C291888] Copy a folder with content', async ({ personalFiles }) => { + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); await copyContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy(); await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder); @@ -107,11 +109,13 @@ test.describe('Copy actions', () => { }); test('[C291889] Copy multiple items', async ({ personalFiles }) => { + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); await copyContentInPersonalFiles(personalFiles, [sourceFolder, sourceFile], destinationFolder); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy(); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy(); await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder); await personalFiles.spinner.waitForReload(); + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy(); expect(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy(); }); @@ -119,6 +123,7 @@ test.describe('Copy actions', () => { test('[C217137] Copy a file with a name that already exists on the destination', async ({ personalFiles }) => { await nodesApi.createFile(sourceFile, destinationFolderId); const expectedNameForCopiedFile = sourceFile.replace('.', '-1.'); + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFile); await copyContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy(); await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder); @@ -131,6 +136,7 @@ test.describe('Copy actions', () => { const existingFolderId = (await nodesApi.createFolder(sourceFolder, destinationFolderId)).entry.id; await nodesApi.createFile(sourceFileInsideFolder, existingFolderId); const expectedNameForCopiedFile = sourceFileInsideFolder.replace('.', '-1.'); + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); await copyContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy(); await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder); @@ -145,6 +151,7 @@ test.describe('Copy actions', () => { test('[C217139] Copy locked file', async ({ personalFiles }) => { const lockType = 'ALLOW_OWNER_CHANGES'; await nodesApi.lockNodes([sourceFileId], lockType); + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFile); await copyContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy(); await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder); @@ -155,6 +162,7 @@ test.describe('Copy actions', () => { test('[C217140] Copy folder that contains locked file', async ({ personalFiles }) => { const lockType = 'ALLOW_OWNER_CHANGES'; await nodesApi.lockNodes([sourceFileInsideFolderId], lockType); + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); await copyContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy(); await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder); @@ -166,6 +174,7 @@ test.describe('Copy actions', () => { }); test('[C217171] Undo copy of files', async ({ personalFiles }) => { + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFile); await copyContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder); await personalFiles.snackBar.actionButton.click(); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy(); @@ -175,6 +184,7 @@ test.describe('Copy actions', () => { }); test('[C217172] Undo copy of folders', async ({ personalFiles }) => { + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); await copyContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder); await personalFiles.snackBar.actionButton.click(); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy(); @@ -186,6 +196,7 @@ test.describe('Copy actions', () => { test('[C217173] Undo copy of a file when a file with same name already exists on the destination', async ({ personalFiles }) => { await nodesApi.createFile(sourceFile, destinationFolderId); const expectedNameForCopiedFile = sourceFile.replace('.', '-1.'); + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFile); await copyContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder); await personalFiles.snackBar.actionButton.click(); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy(); @@ -199,6 +210,7 @@ test.describe('Copy actions', () => { const existingFolderId = (await nodesApi.createFolder(sourceFolder, destinationFolderId)).entry.id; await nodesApi.createFile(sourceFileInsideFolder, existingFolderId); const expectedNameForCopiedFile = sourceFileInsideFolder.replace('.', '-1.'); + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); await copyContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder); await personalFiles.snackBar.actionButton.click(); expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy(); diff --git a/e2e/playwright/copy-move-actions/src/tests/move.test.ts b/e2e/playwright/copy-move-actions/src/tests/move.test.ts index 41f5c52c4..7a040bd0f 100644 --- a/e2e/playwright/copy-move-actions/src/tests/move.test.ts +++ b/e2e/playwright/copy-move-actions/src/tests/move.test.ts @@ -22,21 +22,26 @@ * from Hyland Software. If not, see . */ -import { ApiClientFactory, test, Utils, PersonalFilesPage, NodesApi, LoginPage } from '@alfresco/playwright-shared'; +import { ApiClientFactory, test, Utils, PersonalFilesPage, NodesApi, LoginPage, TrashcanApi } from '@alfresco/playwright-shared'; import { expect } from '@playwright/test'; test.describe('Move actions', () => { let nodesApi: NodesApi; + let trashcanApi: TrashcanApi; const username = `user-${Utils.random()}`; + let sourceFileId: string; + let sourceFileInsideFolderId: string; + let destinationFolderId: string; + let sourceFile: string; let sourceFileInsideFolder: string; let sourceFolder: string; let destinationFolder: string; - let sourceFileId: string; - let sourceFileInsideFolderId: string; - let destinationFolderId: string; + test.afterAll(async ({ nodesApiAction }) => { + await Utils.deleteNodesSitesEmptyTrashcan(nodesApiAction, trashcanApi, 'afterAll failed'); + }); test.beforeAll(async () => { try { @@ -47,12 +52,6 @@ test.describe('Move actions', () => { } catch {} }); - test.afterAll(async ({ nodesApiAction }) => { - try { - await nodesApiAction.deleteCurrentUserNodes(); - } catch {} - }); - test.beforeEach(async ({ personalFiles, page }) => { sourceFile = `source-file-${Utils.random()}.txt`; sourceFileInsideFolder = `source-file-inside-folder-${Utils.random()}.txt`; @@ -60,21 +59,13 @@ test.describe('Move actions', () => { destinationFolder = `destination-folder-${Utils.random()}`; const loginPage = new LoginPage(page); - try { - await loginPage.loginUser( - { username, password: username }, - { - withNavigation: true, - waitForLoading: true - } - ); - destinationFolderId = (await nodesApi.createFolder(destinationFolder)).entry.id; - const sourceFolderId = (await nodesApi.createFolder(sourceFolder)).entry.id; - sourceFileInsideFolderId = (await nodesApi.createFile(sourceFileInsideFolder, sourceFolderId)).entry.id; - sourceFileId = (await nodesApi.createFile(sourceFile)).entry.id; + await Utils.tryLoginUser(loginPage, username, username, 'beforeEach failed'); + destinationFolderId = (await nodesApi.createFolder(destinationFolder)).entry.id; + const sourceFolderId = (await nodesApi.createFolder(sourceFolder)).entry.id; + sourceFileInsideFolderId = (await nodesApi.createFile(sourceFileInsideFolder, sourceFolderId)).entry.id; + sourceFileId = (await nodesApi.createFile(sourceFile)).entry.id; - await personalFiles.navigate(); - } catch {} + await personalFiles.navigate(); }); const moveContentInPersonalFiles = async (personalFilesPage: PersonalFilesPage, sourceFileList: string[], destinationName: string) => { @@ -83,6 +74,7 @@ test.describe('Move actions', () => { }; test('[C217316] Move a file', async ({ personalFiles }) => { + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFile); await moveContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder); const msg = await personalFiles.snackBar.message.innerText(); expect.soft(msg).toContain('Moved 1 item.'); @@ -92,19 +84,8 @@ test.describe('Move actions', () => { expect(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy(); }); - test('[C217317] Move a folder with content', async ({ personalFiles }) => { - await moveContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder); - const msg = await personalFiles.snackBar.message.innerText(); - expect.soft(msg).toContain('Moved 1 item.'); - await personalFiles.snackBar.closeIcon.click(); - expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeFalsy(); - await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder); - expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy(); - await personalFiles.dataTable.performClickFolderOrFileToOpen(sourceFolder); - expect(await personalFiles.dataTable.isItemPresent(sourceFileInsideFolder)).toBeTruthy(); - }); - test('[C291958] Move multiple items', async ({ personalFiles }) => { + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); await moveContentInPersonalFiles(personalFiles, [sourceFolder, sourceFile], destinationFolder); const msg = await personalFiles.snackBar.message.innerText(); expect.soft(msg).toContain('Moved 2 items.'); @@ -119,6 +100,7 @@ test.describe('Move actions', () => { test('[C217318] Move a file with a name that already exists on the destination', async ({ personalFiles }) => { await nodesApi.createFile(sourceFile, destinationFolderId); const expectedNameForCopiedFile = sourceFile.replace('.', '-1.'); + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFile); await moveContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder); const msg = await personalFiles.snackBar.message.innerText(); expect.soft(msg).toContain('Move unsuccessful, a file with the same name already exists.'); @@ -133,6 +115,7 @@ test.describe('Move actions', () => { const existingFolderId = (await nodesApi.createFolder(sourceFolder, destinationFolderId)).entry.id; await nodesApi.createFile(sourceFileInsideFolder, existingFolderId); const expectedNameForCopiedFile = sourceFileInsideFolder.replace('.', '-1.'); + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); await moveContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder); const msg = await personalFiles.snackBar.message.innerText(); expect.soft(msg).toContain('Move unsuccessful, a file with the same name already exists.'); @@ -148,6 +131,7 @@ test.describe('Move actions', () => { test('[C217320] Move locked file', async ({ personalFiles }) => { const lockType = 'ALLOW_OWNER_CHANGES'; await nodesApi.lockNodes([sourceFileId], lockType); + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFile); await moveContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder); const msg = await personalFiles.snackBar.message.innerText(); expect.soft(msg).toContain('Moved 1 item.'); @@ -157,21 +141,8 @@ test.describe('Move actions', () => { expect.soft(await personalFiles.dataTable.isItemPresent(sourceFile)).toBeTruthy(); }); - test('[C217321] Move folder that contains locked file', async ({ personalFiles }) => { - const lockType = 'ALLOW_OWNER_CHANGES'; - await nodesApi.lockNodes([sourceFileInsideFolderId], lockType); - await moveContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder); - const msg = await personalFiles.snackBar.message.innerText(); - expect.soft(msg).toContain('Moved 1 item.'); - await personalFiles.snackBar.closeIcon.click(); - expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeFalsy(); - await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder); - expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy(); - await personalFiles.dataTable.performClickFolderOrFileToOpen(sourceFolder); - expect(await personalFiles.dataTable.isItemPresent(sourceFileInsideFolder)).toBeTruthy(); - }); - test('[C217324] Undo move files', async ({ personalFiles, trashPage }) => { + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFile); await moveContentInPersonalFiles(personalFiles, [sourceFile], destinationFolder); await personalFiles.snackBar.actionButton.click(); await personalFiles.spinner.waitForReload(); @@ -183,6 +154,7 @@ test.describe('Move actions', () => { }); test('[C217325] Undo move of folders', async ({ personalFiles, trashPage }) => { + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); await moveContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder); await personalFiles.snackBar.actionButton.click(); await personalFiles.spinner.waitForReload(); @@ -192,4 +164,38 @@ test.describe('Move actions', () => { await trashPage.navigate(); expect(await trashPage.dataTable.isItemPresent(sourceFolder)).toBeFalsy(); }); + + async function moveFolderWithContent(personalFiles: PersonalFilesPage, lockedFile: boolean) { + if (lockedFile) { + const lockType = 'ALLOW_OWNER_CHANGES'; + await nodesApi.lockNodes([sourceFileInsideFolderId], lockType); + } + await Utils.reloadPageIfRowNotVisible(personalFiles, sourceFolder); + await moveContentInPersonalFiles(personalFiles, [sourceFolder], destinationFolder); + const msg = await personalFiles.snackBar.message.innerText(); + expect.soft(msg).toContain('Moved 1 item.'); + await personalFiles.snackBar.closeIcon.click(); + expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeFalsy(); + await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolder); + expect.soft(await personalFiles.dataTable.isItemPresent(sourceFolder)).toBeTruthy(); + await personalFiles.dataTable.performClickFolderOrFileToOpen(sourceFolder); + expect(await personalFiles.dataTable.isItemPresent(sourceFileInsideFolder)).toBeTruthy(); + } + + [ + { + id: 'C217317', + testTitle: `Move a folder with content`, + lockedFile: false + }, + { + id: 'C217321', + testTitle: 'Move folder that contains locked file', + lockedFile: true + } + ].forEach((testCase) => { + test(`[${testCase.id}] ${testCase.testTitle}`, async ({ personalFiles }) => { + await moveFolderWithContent(personalFiles, testCase.lockedFile); + }); + }); }); diff --git a/e2e/playwright/info-drawer/src/tests/comments.spec.ts b/e2e/playwright/info-drawer/src/tests/comments.spec.ts index 38c859801..c03ef9ae7 100755 --- a/e2e/playwright/info-drawer/src/tests/comments.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/comments.spec.ts @@ -60,6 +60,7 @@ test.describe('Info Drawer - Comments', () => { await nodesApi.createFolder(personalFolderName); await fileActionsApi.waitForNodes(personalFolderName, { expect: 1 }); await personalFiles.navigate(); + await Utils.reloadPageIfRowNotVisible(personalFiles, personalFolderName); await expect(personalFiles.dataTable.getRowByName(personalFolderName)).toBeVisible(); await personalFiles.dataTable.getRowByName(personalFolderName).click(); await personalFiles.acaHeader.viewDetails.click(); diff --git a/e2e/playwright/info-drawer/src/tests/file-folder-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/file-folder-properties.spec.ts index 35a1e3e37..753434f78 100755 --- a/e2e/playwright/info-drawer/src/tests/file-folder-properties.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/file-folder-properties.spec.ts @@ -57,6 +57,7 @@ test.describe('Info Drawer - File Folder Properties', () => { await nodesApi.createFolder(defaultTabsFolderName); await fileActionsApi.waitForNodes(defaultTabsFolderName, { expect: 1 }); await personalFiles.navigate(); + await Utils.reloadPageIfRowNotVisible(personalFiles, defaultTabsFolderName); await expect(personalFiles.dataTable.getRowByName(defaultTabsFolderName)).toBeVisible(); await personalFiles.dataTable.getRowByName(defaultTabsFolderName).click(); await personalFiles.acaHeader.viewDetails.click(); @@ -72,6 +73,7 @@ test.describe('Info Drawer - File Folder Properties', () => { await nodesApi.createFolder(expandDetailsFolderName); await fileActionsApi.waitForNodes(expandDetailsFolderName, { expect: 1 }); await personalFiles.navigate(); + await Utils.reloadPageIfRowNotVisible(personalFiles, expandDetailsFolderName); await expect(personalFiles.dataTable.getRowByName(expandDetailsFolderName)).toBeVisible(); await personalFiles.dataTable.getRowByName(expandDetailsFolderName).click(); await personalFiles.acaHeader.viewDetails.click(); diff --git a/e2e/playwright/info-drawer/src/tests/file-preview.spec.ts b/e2e/playwright/info-drawer/src/tests/file-preview.spec.ts index c72e39c9a..1a1d939f6 100755 --- a/e2e/playwright/info-drawer/src/tests/file-preview.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/file-preview.spec.ts @@ -70,6 +70,7 @@ test.describe('File preview', () => { await fileActionsApi.uploadFileWithRename(TEST_FILES.PDF.path, fileName, '-my-'); await fileActionsApi.waitForNodes(fileName, { expect: 1 }); await personalFiles.navigate(); + await Utils.reloadPageIfRowNotVisible(personalFiles, fileName); await personalFiles.dataTable.getRowByName(fileName).click(); await personalFiles.acaHeader.viewButton.click(); await checkFileContent(personalFiles.page, 1, 'This is a small demonstration'); diff --git a/e2e/playwright/info-drawer/src/tests/general.spec.ts b/e2e/playwright/info-drawer/src/tests/general.spec.ts index 2593785a4..d50559045 100644 --- a/e2e/playwright/info-drawer/src/tests/general.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/general.spec.ts @@ -63,6 +63,7 @@ test.describe('Info Drawer - General', () => { await nodesApi.createFolder(folder1, parentId); await fileActionsApi.waitForNodes(file1, { expect: 1 }); await personalFiles.navigate(); + await Utils.reloadPageIfRowNotVisible(personalFiles, parentFolder); await expect(personalFiles.dataTable.getRowByName(parentFolder)).toBeVisible(); await personalFiles.dataTable.performClickFolderOrFileToOpen(parentFolder); await personalFiles.dataTable.selectItem(file1); diff --git a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts index 040a57ba8..9be7bc799 100644 --- a/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/library-properties.spec.ts @@ -182,6 +182,7 @@ test.describe('Library properties', () => { }); test('[C289343] Site description too long', async ({ myLibrariesPage }) => { + await Utils.reloadPageIfRowNotVisible(myLibrariesPage, site.name); await myLibrariesPage.dataTable.getRowByName(site.name).click(); await myLibrariesPage.acaHeader.viewDetails.click(); await expect(myLibrariesPage.libraryDetails.infoDrawerPanel).toBeVisible(); diff --git a/e2e/playwright/library-actions/playwright.config.ts b/e2e/playwright/library-actions/playwright.config.ts index 5dc01cfaa..a42317aa2 100644 --- a/e2e/playwright/library-actions/playwright.config.ts +++ b/e2e/playwright/library-actions/playwright.config.ts @@ -34,9 +34,7 @@ const config: PlaywrightTestConfig = { { name: 'Library Actions', testDir: './src/tests', - use: { - users: ['hruser'] - } + use: {} } ] }; diff --git a/e2e/playwright/library-actions/src/tests/library-actions.spec.ts b/e2e/playwright/library-actions/src/tests/library-actions.spec.ts index 3d58b32c4..4eabb8a81 100644 --- a/e2e/playwright/library-actions/src/tests/library-actions.spec.ts +++ b/e2e/playwright/library-actions/src/tests/library-actions.spec.ts @@ -90,7 +90,7 @@ test.describe('Library actions ', () => { let user2SitesApi: SitesApi; test.beforeAll(async () => { - test.setTimeout(timeouts.extendedLongTest); + test.setTimeout(timeouts.globalSpec); const apiClientFactory = new ApiClientFactory(); const username1 = `user-${Utils.random()}`; const siteRoles = [ @@ -184,7 +184,8 @@ test.describe('Library actions ', () => { } }); - test('[C290106] Leave a library from My Libraries', async () => { + test('[C290106] Leave a library from My Libraries', async ({ myLibrariesPage }) => { + await Utils.reloadPageIfRowNotVisible(myLibrariesPage, user1Library1); await expect(libraryTable.getCellByColumnNameAndRowItem(user1Library1, managerRole)).toBeVisible(); await libraryTable.performActionFromExpandableMenu(user1Library1, leaveLibraryButton); await expect.soft(confirmDialog.getDialogTitle('Leave this library?')).toBeVisible(); @@ -196,14 +197,16 @@ test.describe('Library actions ', () => { await expect(libraryTable.getRowByName(user1Library1)).not.toBeVisible(); }); - test('[C290111] Cancel Leave Library', async () => { + test('[C290111] Cancel Leave Library', async ({ myLibrariesPage }) => { + await Utils.reloadPageIfRowNotVisible(myLibrariesPage, user1Library5); await expect(libraryTable.getCellByColumnNameAndRowItem(user1Library5, managerRole)).toBeVisible(); await libraryTable.performActionFromExpandableMenu(user1Library5, leaveLibraryButton); await confirmDialog.cancelButton.click(); await expect(libraryTable.getCellByColumnNameAndRowItem(user1Library5, managerRole)).toBeVisible(); }); - test('[C290107] Leave a library - failure notification', async () => { + test('[C290107] Leave a library - failure notification', async ({ myLibrariesPage }) => { + await Utils.reloadPageIfRowNotVisible(myLibrariesPage, user2Library1); await expect(libraryTable.getCellByColumnNameAndRowItem(user2Library1, managerRole)).toBeVisible(); await libraryTable.performActionFromExpandableMenu(user2Library1, leaveLibraryButton); await confirmDialog.okButton.click(); @@ -211,7 +214,8 @@ test.describe('Library actions ', () => { await expect(libraryTable.getCellByColumnNameAndRowItem(user2Library1, managerRole)).toBeVisible(); }); - test('[C289974] Mark library as favorite from My Libraries', async () => { + test('[C289974] Mark library as favorite from My Libraries', async ({ myLibrariesPage }) => { + await Utils.reloadPageIfRowNotVisible(myLibrariesPage, adminLibrary3); await expect(libraryTable.getCellByColumnNameAndRowItem(adminLibrary3, contributorRole)).toBeVisible(); await libraryTable.getCellByColumnNameAndRowItem(adminLibrary3, contributorRole).click(); await myLibrariesHeader.clickMoreActions(); @@ -221,7 +225,7 @@ test.describe('Library actions ', () => { }); test('[C289975] Remove library from favorites from My Libraries', async ({ myLibrariesPage }) => { - await myLibrariesPage.reload({ waitUntil: domContentLoadedString }); + await Utils.reloadPageIfRowNotVisible(myLibrariesPage, user2Library2); await expect(libraryTable.getRowByName(user2Library2)).toBeVisible(); await libraryTable.getRowByName(user2Library2).click(); await myLibrariesPage.page.waitForTimeout(1000); @@ -232,9 +236,10 @@ test.describe('Library actions ', () => { expect(await libraryMenu.isMenuItemVisible(favoriteButton)).toBe(true); }); - test('[C289988] Delete a library from My Libraries', async ({ trashPage }) => { + test('[C289988] Delete a library from My Libraries', async ({ trashPage, myLibrariesPage }) => { const trashTable = trashPage.dataTable; + await Utils.reloadPageIfRowNotVisible(myLibrariesPage, user2Library5Delete); await expect(libraryTable.getRowByName(user2Library5Delete)).toBeVisible(); await libraryTable.getRowByName(user2Library5Delete).click(); await myLibrariesHeader.clickMoreActions(); @@ -264,6 +269,7 @@ test.describe('Library actions ', () => { test('[C290105] Join a public library from Favorite Libraries', async ({ favoriteLibrariesPage }) => { await favoritesApi.addFavoriteById(siteString, adminLibrary1); await favoriteLibrariesPage.navigate(); + await Utils.reloadPageIfRowNotVisible(favoriteLibrariesPage, adminLibrary1); await libraryTable.performActionFromExpandableMenu(adminLibrary1, joinButton); await expect.soft(snackBar.getByMessageLocator(libraryJoinedMessage)).toBeVisible(); await expect(libraryTable.getCellByColumnNameAndRowItem(adminLibrary1, consumerRole)).toBeVisible(); @@ -272,12 +278,13 @@ test.describe('Library actions ', () => { test('[C290109] Join a moderated library from Favorite Libraries', async ({ favoriteLibrariesPage }) => { await favoritesApi.addFavoriteById(siteString, adminModerateLibrary1); await favoriteLibrariesPage.navigate(); + await Utils.reloadPageIfRowNotVisible(favoriteLibrariesPage, adminModerateLibrary1); await expect(libraryTable.getCellByColumnNameAndRowItem(adminModerateLibrary1, notMemberString)).toBeVisible(); await libraryTable.performActionFromExpandableMenu(adminModerateLibrary1, joinButton); await expect.soft(snackBar.getByMessageLocator(requestToJoinMessage)).toBeVisible(); await expect(libraryTable.getCellByColumnNameAndRowItem(adminModerateLibrary1, notMemberString)).toBeVisible(); await adminSitesApi.approveSiteMembershipRequest(adminModerateLibrary1, username2); - await favoriteLibrariesPage.navigate(); + await favoriteLibrariesPage.page.reload({ waitUntil: 'load' }); await expect(libraryTable.getCellByColumnNameAndRowItem(adminModerateLibrary1, consumerRole)).toBeVisible(); }); @@ -285,6 +292,7 @@ test.describe('Library actions ', () => { const confirmDialog = favoriteLibrariesPage.confirmDialogComponent; await favoritesApi.addFavoriteById(siteString, user1Library2); await favoriteLibrariesPage.navigate(); + await Utils.reloadPageIfRowNotVisible(favoriteLibrariesPage, user1Library2); await expect(libraryTable.getCellByColumnNameAndRowItem(user1Library2, contributorRole)).toBeVisible(); await libraryTable.performActionFromExpandableMenu(user1Library2, leaveLibraryButton); await confirmDialog.okButton.click(); @@ -297,6 +305,7 @@ test.describe('Library actions ', () => { await favoritesApi.addFavoriteById(siteString, adminModerateLibrary3); await favoriteLibrariesPage.navigate(); + await Utils.reloadPageIfRowNotVisible(favoriteLibrariesPage, adminModerateLibrary3); await expect(libraryTable.getCellByColumnNameAndRowItem(adminModerateLibrary3, notMemberString)).toBeVisible(); await libraryTable.performActionFromExpandableMenu(adminModerateLibrary3, cancelJoinRequestButton); await expect.soft(snackBar.getByMessageLocator(cancelJoinRequestMessage)).toBeVisible(); @@ -309,6 +318,7 @@ test.describe('Library actions ', () => { const libraryMenu = favoriteLibrariesPage.matMenu; await favoriteLibrariesPage.navigate({ waitUntil: domContentLoadedString }); + await Utils.reloadPageIfRowNotVisible(favoriteLibrariesPage, user2Library3); await expect(libraryTable.getRowByName(user2Library3)).toBeVisible(); await libraryTable.getRowByName(user2Library3).click(); await myLibrariesHeader.clickMoreActions(); @@ -322,6 +332,7 @@ test.describe('Library actions ', () => { const trashTable = trashPage.dataTable; await favoriteLibrariesPage.navigate(); + await Utils.reloadPageIfRowNotVisible(favoriteLibrariesPage, user2Library6Delete); await expect(libraryTable.getRowByName(user2Library6Delete)).toBeVisible(); await libraryTable.getRowByName(user2Library6Delete).click(); await myLibrariesHeader.clickMoreActions(); @@ -349,6 +360,7 @@ test.describe('Library actions ', () => { test('[C306959] Join a public library from Search Results', async ({ searchPage }) => { await searchPage.navigate({ remoteUrl: `#/search-libraries;q=${adminLibrary2}` }); await searchPage.reload({ waitUntil: loadString }); + await Utils.reloadPageIfRowNotVisible(searchPage, adminLibrary2); await expect(libraryTable.getCellByColumnNameAndRowItem(adminLibrary2, notMemberString)).toBeVisible(); await libraryTable.performActionFromExpandableMenu(adminLibrary2, joinButton); await expect.soft(snackBar.getByMessageLocator(libraryJoinedMessage)).toBeVisible(); @@ -357,6 +369,7 @@ test.describe('Library actions ', () => { test('[C306960] Join a moderated library from Search Results', async ({ myLibrariesPage, searchPage }) => { await searchPage.navigate({ remoteUrl: `#/search-libraries;q=${adminModerateLibrary2}` }); + await Utils.reloadPageIfRowNotVisible(searchPage, adminModerateLibrary2); await expect(libraryTable.getCellByColumnNameAndRowItem(adminModerateLibrary2, notMemberString)).toBeVisible(); await libraryTable.performActionFromExpandableMenu(adminModerateLibrary2, joinButton); await expect.soft(snackBar.getByMessageLocator(requestToJoinMessage)).toBeVisible(); @@ -370,6 +383,7 @@ test.describe('Library actions ', () => { const confirmDialog = searchPage.confirmDialogComponent; await searchPage.navigate({ remoteUrl: `#/search-libraries;q=${user1Library3}` }); + await Utils.reloadPageIfRowNotVisible(searchPage, user1Library3); await expect(libraryTable.getCellByColumnNameAndRowItem(user1Library3, 'Collaborator')).toBeVisible(); await libraryTable.performActionFromExpandableMenu(user1Library3, leaveLibraryButton); await confirmDialog.okButton.click(); @@ -380,7 +394,7 @@ test.describe('Library actions ', () => { test('[C306962] Cancel join from Search Results', async ({ searchPage }) => { await user2SitesApi.createSiteMembershipRequestForPerson(username2, adminModerateLibrary4); await searchPage.navigate({ remoteUrl: `#/search-libraries;q=${adminModerateLibrary4}` }); - await searchPage.reload({ waitUntil: loadString }); + await Utils.reloadPageIfRowNotVisible(searchPage, adminModerateLibrary4); await expect(libraryTable.getCellByColumnNameAndRowItem(adminModerateLibrary4, notMemberString)).toBeVisible(); await libraryTable.performActionFromExpandableMenu(adminModerateLibrary4, cancelJoinRequestButton); await expect.soft(snackBar.getByMessageLocator(cancelJoinRequestMessage)).toBeVisible(); @@ -397,6 +411,7 @@ test.describe('Library actions ', () => { await searchPage.searchOverlay.searchLibrariesOption.click(); await searchPage.searchOverlay.searchFor(adminLibrary4); + await Utils.reloadPageIfRowNotVisible(searchPage, adminLibrary4); await expect(libraryTable.getRowByName(adminLibrary4)).toBeVisible(); await libraryTable.getRowByName(adminLibrary4).click(); await myLibrariesHeader.clickMoreActions(); @@ -414,6 +429,7 @@ test.describe('Library actions ', () => { await searchPage.searchOverlay.searchLibrariesOption.click(); await searchPage.searchOverlay.searchFor(user2Library4); + await Utils.reloadPageIfRowNotVisible(searchPage, user2Library4); await expect(libraryTable.getRowByName(user2Library4)).toBeVisible(); await searchPage.reload({ waitUntil: domContentLoadedString }); await libraryTable.getRowByName(user2Library4).click(); @@ -430,7 +446,7 @@ test.describe('Library actions ', () => { const trashTable = trashPage.dataTable; await searchPage.navigate({ remoteUrl: `#/search-libraries;q=${user2Library7Delete}` }); - await searchPage.reload({ waitUntil: loadString }); + await Utils.reloadPageIfRowNotVisible(searchPage, user2Library7Delete); await expect(libraryTable.getRowByName(user2Library7Delete)).toBeVisible(); await libraryTable.getRowByName(user2Library7Delete).click(); await searchHeader.clickMoreActions(); diff --git a/package-lock.json b/package-lock.json index 1e39b8ac5..029faceb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -58,7 +58,7 @@ "@nx/angular": "17.0.2", "@nx/eslint-plugin": "17.0.2", "@nx/workspace": "17.0.2", - "@playwright/test": "^1.37.1", + "@playwright/test": "^1.42.1", "@schematics/angular": "14.1.2", "@types/event-emitter": "^0.3.3", "@types/jasmine": "~3.6.0", @@ -9327,22 +9327,18 @@ } }, "node_modules/@playwright/test": { - "version": "1.37.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.37.1.tgz", - "integrity": "sha512-bq9zTli3vWJo8S3LwB91U0qDNQDpEXnw7knhxLM0nwDvexQAwx9tO8iKDZSqqneVq+URd/WIoz+BALMqUTgdSg==", + "version": "1.42.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.42.1.tgz", + "integrity": "sha512-Gq9rmS54mjBL/7/MvBaNOBwbfnh7beHvS6oS4srqXFcQHpQCV1+c8JXWE8VLPyRDhgS3H8x8A7hztqI9VnwrAQ==", "dev": true, "dependencies": { - "@types/node": "*", - "playwright-core": "1.37.1" + "playwright": "1.42.1" }, "bin": { "playwright": "cli.js" }, "engines": { "node": ">=16" - }, - "optionalDependencies": { - "fsevents": "2.3.2" } }, "node_modules/@rollup/plugin-json": { @@ -25321,10 +25317,28 @@ "node": ">=8" } }, + "node_modules/playwright": { + "version": "1.42.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.42.1.tgz", + "integrity": "sha512-PgwB03s2DZBcNRoW+1w9E+VkLBxweib6KTXM0M3tkiT4jVxKSi6PmVJ591J+0u10LUrgxB7dLRbiJqO5s2QPMg==", + "dev": true, + "dependencies": { + "playwright-core": "1.42.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, "node_modules/playwright-core": { - "version": "1.37.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.37.1.tgz", - "integrity": "sha512-17EuQxlSIYCmEMwzMqusJ2ztDgJePjrbttaefgdsiqeLWidjYz9BxXaTaZWxH1J95SHGk6tjE+dwgWILJoUZfA==", + "version": "1.42.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.42.1.tgz", + "integrity": "sha512-mxz6zclokgrke9p1vtdy/COWBH+eOZgYUVVU34C73M+4j4HLlQJHtfcqiqqxpP0o8HhMkflvfbquLX5dg6wlfA==", "dev": true, "bin": { "playwright-core": "cli.js" diff --git a/package.json b/package.json index 1f0ded385..f2e2d197d 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "@nx/angular": "17.0.2", "@nx/eslint-plugin": "17.0.2", "@nx/workspace": "17.0.2", - "@playwright/test": "^1.37.1", + "@playwright/test": "^1.42.1", "@schematics/angular": "14.1.2", "@types/event-emitter": "^0.3.3", "@types/jasmine": "~3.6.0", diff --git a/projects/aca-playwright-shared/src/api/file-actions.ts b/projects/aca-playwright-shared/src/api/file-actions.ts index 81bd4adca..73e88e4d9 100644 --- a/projects/aca-playwright-shared/src/api/file-actions.ts +++ b/projects/aca-playwright-shared/src/api/file-actions.ts @@ -160,7 +160,9 @@ export class FileActionsApi { try { await waitForApi(apiCall, predicate, 30, 2500); - } catch {} + } catch (error) { + console.error(`Error: ${error}`); + } } async updateNodeContent(nodeId: string, content: string, majorVersion: boolean = true, comment?: string, newName?: string): Promise { diff --git a/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts b/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts index f86006d3d..10503e5a4 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/dataTable/data-table.component.ts @@ -241,7 +241,7 @@ export class DataTableComponent extends BaseComponent { const isSelected = await this.hasCheckMarkIcon(name); if (!isSelected) { let row = this.getRowByName(name); - await row.locator('[title="Size"]').click(); + await row.locator('[title="Size"]').click({ modifiers: ['Meta'] }); await row.locator('.adf-datatable-selected').waitFor({ state: 'attached' }); } } diff --git a/projects/aca-playwright-shared/src/utils/utils.ts b/projects/aca-playwright-shared/src/utils/utils.ts index e8151dc03..6706025d3 100644 --- a/projects/aca-playwright-shared/src/utils/utils.ts +++ b/projects/aca-playwright-shared/src/utils/utils.ts @@ -24,7 +24,7 @@ const crypto = require('crypto'); import * as path from 'path'; -import { LoginPage, PersonalFilesPage } from '../'; +import { LoginPage, MyLibrariesPage, PersonalFilesPage, FavoritesLibrariesPage, SearchPage } from '../'; import { NodesApi, TrashcanApi, SitesApi } from '@alfresco/playwright-shared'; export class Utils { @@ -98,4 +98,18 @@ export class Utils { const fileInput = await personalFilesPage.page.$('#app-upload-file-version'); await fileInput.setInputFiles(path.join(__dirname, `../resources/test-files/${fileFromOS}.docx`)); } + + static async reloadPageIfRowNotVisible( + pageContext: PersonalFilesPage | MyLibrariesPage | FavoritesLibrariesPage | SearchPage, + nodeName: string, + errorMessage = 'Error ' + ): Promise { + try { + if (!await pageContext.dataTable.getRowByName(nodeName).isVisible()) { + await pageContext.page.reload({ waitUntil: 'load' }); + }; + } catch (error) { + console.error(`${errorMessage}: ${error}`); + } + } }