diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9ed5968679..ffe12acc82 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -176,6 +176,8 @@ jobs: id: 1 - name: "folder-rules" id: 2 + - name: "viewer" + id: 3 steps: - name: Checkout uses: actions/checkout@v3 diff --git a/e2e/playwright/viewer/.eslintrc.json b/e2e/playwright/viewer/.eslintrc.json new file mode 100644 index 0000000000..20cbee6e3e --- /dev/null +++ b/e2e/playwright/viewer/.eslintrc.json @@ -0,0 +1,26 @@ +{ + "extends": "../../../.eslintrc.json", + "ignorePatterns": [ + "!**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "parserOptions": { + "project": [ + "e2e/playwright/viewer/tsconfig.e2e.json" + ], + "createDefaultProgram": true + }, + "plugins": [ + "rxjs", + "unicorn" + ], + "rules": { + "@typescript-eslint/no-floating-promises": "off" + } + } + ] +} diff --git a/e2e/playwright/viewer/exclude.tests.json b/e2e/playwright/viewer/exclude.tests.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/e2e/playwright/viewer/exclude.tests.json @@ -0,0 +1 @@ +{} diff --git a/e2e/playwright/viewer/playwright.config.ts b/e2e/playwright/viewer/playwright.config.ts new file mode 100644 index 0000000000..a5748b1c46 --- /dev/null +++ b/e2e/playwright/viewer/playwright.config.ts @@ -0,0 +1,44 @@ +/*! + * 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 . + */ + +import { PlaywrightTestConfig } from '@playwright/test'; +import { CustomConfig, getGlobalConfig, getExcludedTestsRegExpArray } from '@alfresco/playwright-shared'; +import EXCLUDED_JSON from './exclude.tests.json'; + +const config: PlaywrightTestConfig = { + ...getGlobalConfig, + + grepInvert: getExcludedTestsRegExpArray(EXCLUDED_JSON, 'Viewer'), + projects: [ + { + name: 'Viewer', + testDir: './src/tests', + use: { + users: ['hruser', 'admin'] + } + } + ] +}; + +export default config; diff --git a/e2e/playwright/viewer/project.json b/e2e/playwright/viewer/project.json new file mode 100644 index 0000000000..bb31d77f5e --- /dev/null +++ b/e2e/playwright/viewer/project.json @@ -0,0 +1,34 @@ +{ + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "name": "viewer-e2e", + "sourceRoot": "e2e/playwright/viewer/src", + "projectType": "application", + "targets": { + "e2e": { + "executor": "nx:run-commands", + "options": { + "commands": [ + "npx playwright test --config=e2e/playwright/viewer/playwright.config.ts" + ] + }, + "configurations": { + "production": { + "devServerTarget": "content-ce:serve:production" + } + } + }, + "lint": { + "executor": "@angular-eslint/builder:lint", + "options": { + "lintFilePatterns": [ + "e2e/**/*.ts", + "e2e/**/*.html" + ], + "cache": true, + "cacheLocation": ".eslintcache", + "ignorePath": ".eslintignore" + }, + "outputs": ["{options.outputFile}"] + } + } +} diff --git a/e2e/playwright/viewer/src/tests/viewer.spec.ts b/e2e/playwright/viewer/src/tests/viewer.spec.ts new file mode 100644 index 0000000000..709b554a4e --- /dev/null +++ b/e2e/playwright/viewer/src/tests/viewer.spec.ts @@ -0,0 +1,135 @@ +/*! + * 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 . + */ + +import { expect } from '@playwright/test'; +import { ApiClientFactory, getUserState, test, TEST_FILES } from '@alfresco/playwright-shared'; + +test.use({ storageState: getUserState('admin') }); +test.describe('viewer file', () => { + const apiClientFactory = new ApiClientFactory(); + const randomFolderName = `playwright-folder-${(Math.random() + 1).toString(36).substring(6)}`; + const randomDocxName = TEST_FILES.DOCX.name + (Math.random() + 1).toString(36).substring(6); + let folderId: string; + let fileDocxId: string; + + test.beforeAll(async ({ fileAction, shareAction, favoritesPageAction: favoritesPageAction }) => { + await apiClientFactory.setUpAcaBackend('admin'); + const node = await apiClientFactory.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder', relativePath: '/' }); + folderId = await node.entry.id; + const fileDoc = await fileAction.uploadFile(TEST_FILES.DOCX.path, randomDocxName, folderId); + fileDocxId = await fileDoc.entry.id; + await shareAction.shareFileById(fileDocxId); + await favoritesPageAction.addFavoriteById('file', fileDocxId); + }); + + test.beforeEach(async ({ personalFiles }) => { + await personalFiles.navigate({ waitUntil: 'domcontentloaded' }); + await personalFiles.dataTable.performClickFolderOrFileToOpen(randomFolderName); + }); + + test.afterAll(async () => { + await apiClientFactory.nodes.deleteNode(folderId); + }); + + 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.selectItem(randomDocxName); + 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); + await personalFiles.viewer.closeButtonLocator.click(); + expect(await personalFiles.viewer.isViewerOpened(), 'Viewer did not close').toBe(false); + }); + + test('[C284632] Close button tooltip', async ({ personalFiles }) => { + await personalFiles.dataTable.performClickFolderOrFileToOpen(randomDocxName); + expect(await personalFiles.viewer.getCloseButtonTooltip()).toEqual('Close'); + }); + + 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('[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('[C284635] Viewer opens for a file from Shared Files', async ({ sharedPage }) => { + await sharedPage.navigate(); + await sharedPage.reload(); + 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.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('[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.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); + }); +}); diff --git a/e2e/playwright/viewer/tsconfig.e2e.adf.json b/e2e/playwright/viewer/tsconfig.e2e.adf.json new file mode 100644 index 0000000000..87cbcf775a --- /dev/null +++ b/e2e/playwright/viewer/tsconfig.e2e.adf.json @@ -0,0 +1,15 @@ +{ + "extends": "../../../tsconfig.adf.json", + "compilerOptions": { + "outDir": "../../out-tsc/e2e", + "baseUrl": "./", + "module": "commonjs", + "target": "es2017", + "types": ["jasmine", "jasminewd2", "node"], + "skipLibCheck": true, + "paths": { + "@alfresco/playwright-shared": ["../../../projects/aca-playwright-shared/src/index.ts"] + } + }, + "exclude": ["node_modules"] +} diff --git a/e2e/playwright/viewer/tsconfig.e2e.json b/e2e/playwright/viewer/tsconfig.e2e.json new file mode 100755 index 0000000000..d1d140fba4 --- /dev/null +++ b/e2e/playwright/viewer/tsconfig.e2e.json @@ -0,0 +1,12 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "../../out-tsc/e2e", + "baseUrl": "./", + "module": "commonjs", + "target": "es2017", + "types": ["jasmine", "jasminewd2", "node", "@playwright/test"], + "skipLibCheck": true, + }, + "exclude": ["node_modules"] +} diff --git a/e2e/protractor/suites/viewer/viewer-general.test.ts b/e2e/protractor/suites/viewer/viewer-general.test.ts index cf05f3597c..37f12450d1 100755 --- a/e2e/protractor/suites/viewer/viewer-general.test.ts +++ b/e2e/protractor/suites/viewer/viewer-general.test.ts @@ -23,7 +23,6 @@ */ import { AdminActions, UserActions, LoginPage, BrowsingPage, FILES, SITE_VISIBILITY, RepoClient, Utils, Viewer } from '@alfresco/aca-testing-shared'; -import { BrowserActions } from '@alfresco/adf-testing'; describe('Viewer general', () => { const username = `user-${Utils.random()}`; @@ -49,9 +48,8 @@ describe('Viewer general', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); - const { dataTable, toolbar } = page; + const { dataTable } = page; const viewer = new Viewer(); - const { searchInput } = page.pageLayoutHeader; const adminApiActions = new AdminActions(); const userActions = new UserActions(); @@ -98,45 +96,6 @@ describe('Viewer general', () => { await apis.user.sites.deleteSite(siteUser); }); - it('[C279269] Viewer opens on double clicking on a file from Personal Files', async () => { - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - }); - - it('[C279270] Viewer opens when clicking the View action for a file', async () => { - await dataTable.selectItem(xlsxFile); - await BrowserActions.click(page.toolbar.viewButton); - - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - }); - - it('[C279283] The viewer general elements are displayed', async () => { - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); - - it('[C279271] Close the viewer', async () => { - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - await BrowserActions.click(viewer.closeButton); - expect(await viewer.isViewerOpened()).toBe(false, 'Viewer did not close'); - }); - - it('[C284632] Close button tooltip', async () => { - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.getCloseButtonTooltip()).toEqual('Close'); - }); - - it('[C279285] Viewer opens when accessing the preview URL for a file', async () => { - const previewURL = `personal-files/${parentId}/(viewer:view/${xlsxFileId})`; - await page.load(previewURL); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.getFileTitle()).toEqual(xlsxFile); - }); - it('[C279287] Viewer does not open when accessing the preview URL for a file without permissions', async () => { const previewURL = `libraries/${docLibId}/(viewer:view/${fileAdminId})`; await page.load(previewURL); @@ -153,45 +112,4 @@ describe('Viewer general', () => { expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); }); - - it('[C284636] Viewer opens for a file from Recent Files', async () => { - await page.clickRecentFilesAndWait(); - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); - - it('[C284635] Viewer opens for a file from Shared Files', async () => { - await page.clickSharedFilesAndWait(); - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); - - it('[C284634] Viewer opens for a file from Favorites', async () => { - await page.clickFavoritesAndWait(); - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); - - it('[C279175] Viewer opens for a file from Search Results', async () => { - await toolbar.clickSearchIconButton(); - await searchInput.clickSearchButton(); - await searchInput.checkFilesAndFolders(); - await searchInput.searchFor(xlsxFile); - await dataTable.waitForBody(); - - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); }); diff --git a/projects/aca-playwright-shared/src/api/api-client-factory.ts b/projects/aca-playwright-shared/src/api/api-client-factory.ts index 6147a78759..53453aaa95 100644 --- a/projects/aca-playwright-shared/src/api/api-client-factory.ts +++ b/projects/aca-playwright-shared/src/api/api-client-factory.ts @@ -35,7 +35,9 @@ import { SecurityGroupsApi, SecurityMarksApi, SitesApi, - UploadApi + UploadApi, + SharedlinksApi, + FavoritesApi } from '@alfresco/js-api'; import { logger } from '@alfresco/adf-cli/scripts/logger'; import { ActionTypes, Rule } from './rules-api'; @@ -45,6 +47,8 @@ export interface AcaBackend { sites: SitesApi; upload: UploadApi; nodes: NodesApi; + share: SharedlinksApi; + favorites: FavoritesApi; tearDown(): Promise; } @@ -73,6 +77,8 @@ export class ApiClientFactory { public securityGroupsApi: SecurityGroupsApi; public securityMarksApi: SecurityMarksApi; public contentClient: ContentClient; + public share: SharedlinksApi; + public favorites: FavoritesApi; constructor() { this.alfrescoApi = new AlfrescoApi(config); @@ -92,6 +98,8 @@ export class ApiClientFactory { this.search = new SearchApi(this.alfrescoApi); this.securityGroupsApi = new SecurityGroupsApi(this.alfrescoApi); this.securityMarksApi = new SecurityMarksApi(this.alfrescoApi); + this.share = new SharedlinksApi(this.alfrescoApi); + this.favorites = new FavoritesApi(this.alfrescoApi); return this; } diff --git a/projects/aca-playwright-shared/src/api/favorites-api.ts b/projects/aca-playwright-shared/src/api/favorites-api.ts new file mode 100755 index 0000000000..83904cff83 --- /dev/null +++ b/projects/aca-playwright-shared/src/api/favorites-api.ts @@ -0,0 +1,52 @@ +/*! + * 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 + * along with Alfresco. If not, see . + */ + +import { ApiClientFactory } from './api-client-factory'; +import { FavoriteEntry } from '@alfresco/js-api'; +import { users } from '../base-config/global-variables'; + +export class FavoritesPageApi extends ApiClientFactory { + private apiService: ApiClientFactory; + + constructor() { + super(); + this.apiService = new ApiClientFactory(); + } + static async initialize(userProfile: keyof typeof users): Promise { + const classObj = new FavoritesPageApi(); + await classObj.apiService.setUpAcaBackend(userProfile); + return classObj; + } + async addFavoriteById(nodeType: 'file' | 'folder' | 'site', id: string): Promise { + let guid = nodeType === 'site' ? (await this.sites.getSite(id)).entry.guid : id; + const data = { + target: { + [nodeType]: { + guid: guid + } + } + }; + return await this.apiService.favorites.createFavorite('-me-', data); + } +} diff --git a/projects/aca-playwright-shared/src/api/file-actions.ts b/projects/aca-playwright-shared/src/api/file-actions.ts new file mode 100644 index 0000000000..9c7b4a528d --- /dev/null +++ b/projects/aca-playwright-shared/src/api/file-actions.ts @@ -0,0 +1,59 @@ +/*! + * 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 + * along with Alfresco. If not, see . + */ + +import * as fs from 'fs'; +import { ApiClientFactory } from './api-client-factory'; +import { users } from '../base-config/global-variables'; + +export class FileActionsApi extends ApiClientFactory { + private apiService: ApiClientFactory; + + constructor() { + super(); + this.apiService = new ApiClientFactory(); + } + + static async initialize( + userProfile: keyof typeof users + ): Promise { + const classObj = new FileActionsApi(); + await classObj.apiService.setUpAcaBackend(userProfile); + return classObj; + } + + async uploadFile(fileLocation: string, fileName: string, parentFolderId: string): Promise { + const file = fs.createReadStream(fileLocation); + return this.apiService.upload.uploadFile( + file, + '', + parentFolderId, + null, + { + name: fileName, + nodeType: 'cm:content', + renditions: 'doclib' + } + ); + } +} diff --git a/projects/aca-playwright-shared/src/api/index.ts b/projects/aca-playwright-shared/src/api/index.ts index 03f510735c..b7a8762b4a 100644 --- a/projects/aca-playwright-shared/src/api/index.ts +++ b/projects/aca-playwright-shared/src/api/index.ts @@ -24,3 +24,6 @@ export * from './rules-api'; export * from './api-client-factory'; +export * from './file-actions'; +export * from './shared-links-api'; +export * from './favorites-api'; diff --git a/projects/aca-playwright-shared/src/api/shared-links-api.ts b/projects/aca-playwright-shared/src/api/shared-links-api.ts new file mode 100755 index 0000000000..0c24e75598 --- /dev/null +++ b/projects/aca-playwright-shared/src/api/shared-links-api.ts @@ -0,0 +1,55 @@ +/*! + * 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 + * along with Alfresco. If not, see . + */ + +import { ApiClientFactory } from './api-client-factory'; +import { SharedLinkEntry } from '@alfresco/js-api'; +import { users } from '../base-config/global-variables'; + +export class SharedLinksApi extends ApiClientFactory { + private apiService: ApiClientFactory; + + constructor() { + super(); + this.apiService = new ApiClientFactory(); + } + static async initialize( + userProfile: keyof typeof users + ): Promise { + const classObj = new SharedLinksApi(); + await classObj.apiService.setUpAcaBackend(userProfile); + return classObj; + } + + async shareFileById(id: string, expireDate?: Date): Promise { + try { + const data = { + nodeId: id, + expiresAt: expireDate + }; + return await this.apiService.share.createSharedLink(data); + } catch (error) { + return null; + } + } +} diff --git a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts index 3a35b75ca8..a30b775a1c 100644 --- a/projects/aca-playwright-shared/src/fixtures/page-initialization.ts +++ b/projects/aca-playwright-shared/src/fixtures/page-initialization.ts @@ -22,20 +22,63 @@ * from Hyland Software. If not, see . */ - import { test as base } from '@playwright/test'; -import { NodesPage, PersonalFilesPage } from '../'; +import { + FileActionsApi, + NodesPage, + PersonalFilesPage, + RecentFilesPage, + SharedLinksApi, + SharedPage, + SearchPage, + FavoritesPage, + FavoritesPageApi +} from '../'; interface Pages { personalFiles: PersonalFilesPage; nodesPage: NodesPage; + recentFilesPage: RecentFilesPage; + sharedPage: SharedPage; + searchPage: SearchPage; + favoritePage: FavoritesPage; +} + +interface Api { + fileAction: FileActionsApi; + shareAction: SharedLinksApi; + favoritesPageAction: FavoritesPageApi; } -export const test = base.extend({ +export const test = base.extend({ personalFiles: async ({ page }, use) => { await use(new PersonalFilesPage(page)); }, nodesPage: async ({ page }, use) => { await use(new NodesPage(page)); + }, + recentFilesPage: async ({ page }, use) => { + await use(new RecentFilesPage(page)); + }, + sharedPage: async ({ page }, use) => { + await use(new SharedPage(page)); + }, + searchPage: async ({ page }, use) => { + await use(new SearchPage(page)); + }, + favoritePage: async ({ page }, use) => { + await use(new FavoritesPage(page)); + }, + // eslint-disable-next-line no-empty-pattern + fileAction: async ({}, use) => { + await use(await FileActionsApi.initialize('admin')); + }, + // eslint-disable-next-line no-empty-pattern + shareAction: async ({}, use) => { + await use(await SharedLinksApi.initialize('admin')); + }, + // eslint-disable-next-line no-empty-pattern + favoritesPageAction: async ({}, use) => { + await use(await FavoritesPageApi.initialize('admin')); } }); diff --git a/projects/aca-playwright-shared/src/index.ts b/projects/aca-playwright-shared/src/index.ts index 24b44026ef..356316797e 100644 --- a/projects/aca-playwright-shared/src/index.ts +++ b/projects/aca-playwright-shared/src/index.ts @@ -28,3 +28,4 @@ export * from './models'; export * from './page-objects'; export * from './fixtures/page-initialization'; export * from './utils'; +export * from './resources/test-files'; diff --git a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts index dc8c10ee4e..063aed6e8f 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/aca-header.component.ts @@ -22,14 +22,16 @@ * from Hyland Software. If not, see . */ - import { BaseComponent } from './base.component'; - import { Page } from '@playwright/test'; +import { BaseComponent } from './base.component'; +import { Page } from '@playwright/test'; - export class AcaHeader extends BaseComponent { - private static rootElement = 'adf-toolbar'; - public createButton = this.getChild('[id="app.toolbar.create"]'); +export class AcaHeader extends BaseComponent { + private static rootElement = 'adf-toolbar'; + public createButton = this.getChild('[id="app.toolbar.create"]'); + public viewButton = this.getChild('button[title="View"]'); + public searchButton = this.getChild('button[title="Search"]'); - constructor(page: Page) { - super(page, AcaHeader.rootElement); - } - } + constructor(page: Page) { + super(page, AcaHeader.rootElement); + } +} diff --git a/projects/aca-playwright-shared/src/page-objects/components/actions-dropdown.component.ts b/projects/aca-playwright-shared/src/page-objects/components/actions-dropdown.component.ts index 4671f5355e..2bc2b12093 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/actions-dropdown.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/actions-dropdown.component.ts @@ -77,7 +77,7 @@ export class ActionsDropdownComponent extends BaseComponent { await this.actionDropdownLocator.nth(index).click(); await this.spinnerWaitForReload(); const option = this.getOptionLocator(action); - await option.click(); + await option.nth(0).click(); } async dropdownSelection(selectValue: string, locator: string, index: number): Promise { diff --git a/projects/aca-playwright-shared/src/page-objects/components/base.component.ts b/projects/aca-playwright-shared/src/page-objects/components/base.component.ts index 62919a0fdb..11910754b1 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/base.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/base.component.ts @@ -50,13 +50,13 @@ export abstract class BaseComponent extends PlaywrightBase { async closeAdditionalOverlayElementIfVisible(): Promise { if (await this.overlayElement.isVisible()) { await this.page.keyboard.press('Escape'); - await this.overlayElement.waitFor({ state: 'detached', timeout: 5000 }); + await this.overlayElement.waitFor({ state: 'detached', timeout: timeouts.medium }); } } async spinnerWaitForReload(): Promise { try { - await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.short }); + await this.page.locator('mat-progress-spinner').waitFor({ state: 'attached', timeout: timeouts.normal }); await this.page.locator('mat-progress-spinner').waitFor({ state: 'detached', timeout: timeouts.normal }); } catch (e) { this.logger.info('Spinner was not present'); 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 0c9a9eb9dd..8ae4a2b822 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 @@ -155,6 +155,17 @@ export class DataTableComponent extends BaseComponent { } } + /** + * This method is used when we want to perform double click on the dataTable row to open a file or folder + * + * @param name of the data table element with which we want to double click + */ + async performClickFolderOrFileToOpen(name: string): Promise { + await this.goThroughPagesLookingForRowWithName(name); + await this.getCellLinkByName(name).click(); + await this.spinnerWaitForReload(); + } + async getActionLocatorFromExpandableMenu(name: string | number, action: string): Promise { await this.getRowByName(name).click({ button: 'right' }); return this.contextMenuActions.getButtonByText(action); @@ -180,4 +191,17 @@ export class DataTableComponent extends BaseComponent { await this.spinnerWaitForReload(); } } + + async selectItem(name: string): Promise { + const isSelected = await this.hasCheckMarkIcon(name); + if (!isSelected) { + const row = await this.getRowByName(name); + await row.locator('.mat-checkbox[id*="mat-checkbox"]').check(); + } + } + + async hasCheckMarkIcon(itemName: string): Promise { + const row = this.getRowByName(itemName); + return await row.locator('.mat-checkbox[class*="checked"]').isVisible(); + } } diff --git a/projects/aca-playwright-shared/src/page-objects/components/index.ts b/projects/aca-playwright-shared/src/page-objects/components/index.ts index 2286fc7061..a3f04f1fb6 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/index.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/index.ts @@ -31,4 +31,6 @@ export * from './spinner.component'; export * from './actions-dropdown.component'; export * from './conditions.component'; export * from './pagination.component'; - +export * from './viewer.component'; +export * from './search/search-input.component'; +export * from './search/search-overlay.components'; diff --git a/projects/aca-playwright-shared/src/page-objects/components/search/search-input.component.ts b/projects/aca-playwright-shared/src/page-objects/components/search/search-input.component.ts new file mode 100644 index 0000000000..1f0d182ca5 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/search/search-input.component.ts @@ -0,0 +1,51 @@ +/*! + * 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 . + */ + +import { Locator, Page } from '@playwright/test'; +import { BaseComponent } from '.././base.component'; +import { timeouts } from '../../../utils'; + +export class SearchInputComponent extends BaseComponent { + private static rootElement = 'aca-page-layout'; + public searchButton = this.getChild('aca-search-input .app-search-button'); + + /** + * Method used in cases where user have possibility to navigate "inside" the element (it's clickable and has link attribute). + * Perform action .click() to navigate inside it + * + * @returns reference to cell element which contains link. + */ + getCellLinkByName = (name: string): Locator => this.getChild('.adf-datatable-row[role="row"]', { hasText: name }); + + constructor(page: Page, rootElement = SearchInputComponent.rootElement) { + super(page, rootElement); + } + + async performDoubleClickFolderOrFileToOpen(name: string): Promise { + await this.getCellLinkByName(name).waitFor({ state:'visible', timeout: timeouts.normal }); + await this.getCellLinkByName(name).dblclick(); + await this.spinnerWaitForReload(); + } + +} diff --git a/projects/aca-playwright-shared/src/page-objects/components/search/search-overlay.components.ts b/projects/aca-playwright-shared/src/page-objects/components/search/search-overlay.components.ts new file mode 100644 index 0000000000..ed32e68c25 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/search/search-overlay.components.ts @@ -0,0 +1,50 @@ +/*! + * 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 . + */ + +import { Page } from '@playwright/test'; +import { BaseComponent } from '.././base.component'; + +export class SearchOverlayComponent extends BaseComponent { + private static rootElement = '.cdk-overlay-pane'; + + public searchFilesOption = this.getChild('label[for="content-input"]'); + public searchFoldersOption = this.getChild('label[for="folder-input"]'); + public searchLibrariesOption = this.getChild('label[for="libraries-input"]'); + public searchInput = this.getChild('input[id="app-control-input"]'); + public searchButton = this.getChild('.app-search-button'); + + constructor(page: Page, rootElement = SearchOverlayComponent.rootElement) { + super(page, rootElement); + } + + async checkFilesAndFolders(): Promise { + await this.searchFilesOption.click(); + await this.searchFoldersOption.click(); + } + + async searchFor(input: string): Promise { + await this.searchInput.fill(input); + await this.searchButton.click(); + } +} diff --git a/projects/aca-playwright-shared/src/page-objects/components/viewer.component.ts b/projects/aca-playwright-shared/src/page-objects/components/viewer.component.ts new file mode 100644 index 0000000000..0aaa290014 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/components/viewer.component.ts @@ -0,0 +1,61 @@ +/*! + * 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 . + */ + +import { Page } from '@playwright/test'; +import { BaseComponent } from './base.component'; +import { AcaHeader } from './aca-header.component'; +import { timeouts } from '../../utils'; + +export class ViewerComponent extends BaseComponent { + private static rootElement = 'adf-viewer'; + + private viewerLocator = this.getChild('.adf-viewer-render-layout-content'); + public closeButtonLocator = this.getChild('.adf-viewer-close-button'); + public fileTitleButtonLocator = this.getChild('.adf-viewer__file-title'); + + toolbar = new AcaHeader(this.page); + + constructor(page: Page) { + super(page, ViewerComponent.rootElement); + } + + async isViewerOpened(): Promise { + return await this.viewerLocator.isVisible(); + } + + async isCloseButtonDisplayed(): Promise { + await this.closeButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal }); + return await this.closeButtonLocator.isEnabled({ timeout: timeouts.normal }); + } + + async isFileTitleDisplayed(): Promise { + await this.fileTitleButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal }); + return await this.fileTitleButtonLocator.isVisible(); + } + + async getCloseButtonTooltip(): Promise { + await this.closeButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal }); + return await this.closeButtonLocator.getAttribute('title'); + } +} diff --git a/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts new file mode 100644 index 0000000000..2d0a13cde7 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/pages/favorites.page.ts @@ -0,0 +1,43 @@ +/*! + * 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 . + */ + +import { Page } from '@playwright/test'; +import { BasePage } from './base.page'; +import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components'; +import { AcaHeader } from '../components/aca-header.component'; +import { AdfFolderDialogComponent } from '../components/dialogs'; + +export class FavoritesPage extends BasePage { + private static pageUrl = 'favorites'; + + constructor(page: Page) { + super(page, FavoritesPage.pageUrl); + } + + public acaHeader = new AcaHeader(this.page); + public matMenu = new MatMenuComponent(this.page); + public folderDialog = new AdfFolderDialogComponent(this.page); + public dataTable = new DataTableComponent(this.page); + public viewer = new ViewerComponent(this.page); +} diff --git a/projects/aca-playwright-shared/src/page-objects/pages/index.ts b/projects/aca-playwright-shared/src/page-objects/pages/index.ts index c1d1ae1c15..72def0ece5 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/index.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/index.ts @@ -26,3 +26,7 @@ export * from './base.page'; export * from './login.page'; export * from './nodes.page'; export * from './personal-files.page'; +export * from './recent-files.page'; +export * from './shared.page'; +export * from './search.page'; +export * from './favorites.page'; diff --git a/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts index 7845ee51bc..94251cc440 100644 --- a/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts +++ b/projects/aca-playwright-shared/src/page-objects/pages/personal-files.page.ts @@ -25,7 +25,7 @@ import { Page } from '@playwright/test'; import { BasePage } from './base.page'; -import { DataTableComponent, MatMenuComponent } from '../components'; +import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components'; import { AcaHeader } from '../components/aca-header.component'; import { AdfFolderDialogComponent } from '../components/dialogs'; @@ -40,4 +40,5 @@ export class PersonalFilesPage extends BasePage { public matMenu = new MatMenuComponent(this.page); public folderDialog = new AdfFolderDialogComponent(this.page); public dataTable = new DataTableComponent(this.page); + public viewer = new ViewerComponent(this.page); } diff --git a/projects/aca-playwright-shared/src/page-objects/pages/recent-files.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/recent-files.page.ts new file mode 100644 index 0000000000..e971c89213 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/pages/recent-files.page.ts @@ -0,0 +1,44 @@ +/*! + * 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 . + */ + + +import { Page } from '@playwright/test'; +import { BasePage } from './base.page'; +import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components'; +import { AcaHeader } from '../components/aca-header.component'; +import { AdfFolderDialogComponent } from '../components/dialogs'; + +export class RecentFilesPage extends BasePage { + private static pageUrl = 'recent-files'; + + constructor(page: Page) { + super(page, RecentFilesPage.pageUrl); + } + + public acaHeader = new AcaHeader(this.page); + public matMenu = new MatMenuComponent(this.page); + public folderDialog = new AdfFolderDialogComponent(this.page); + public dataTable = new DataTableComponent(this.page); + public viewer = new ViewerComponent(this.page); +} diff --git a/projects/aca-playwright-shared/src/page-objects/pages/search.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/search.page.ts new file mode 100644 index 0000000000..b195a5b77c --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/pages/search.page.ts @@ -0,0 +1,45 @@ +/*! + * 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 . + */ + +import { Page } from '@playwright/test'; +import { BasePage } from './base.page'; +import { DataTableComponent, MatMenuComponent, ViewerComponent, SearchInputComponent, SearchOverlayComponent } from '../components'; +import { AcaHeader } from '../components/aca-header.component'; +import { AdfFolderDialogComponent } from '../components/dialogs'; + +export class SearchPage extends BasePage { + private static pageUrl = 'search'; + + constructor(page: Page) { + super(page, SearchPage.pageUrl); + } + + public acaHeader = new AcaHeader(this.page); + public matMenu = new MatMenuComponent(this.page); + public folderDialog = new AdfFolderDialogComponent(this.page); + public dataTable = new DataTableComponent(this.page); + public viewer = new ViewerComponent(this.page); + public searchInput = new SearchInputComponent(this.page); + public searchOverlay = new SearchOverlayComponent(this.page); +} diff --git a/projects/aca-playwright-shared/src/page-objects/pages/shared.page.ts b/projects/aca-playwright-shared/src/page-objects/pages/shared.page.ts new file mode 100644 index 0000000000..c70bbe57d8 --- /dev/null +++ b/projects/aca-playwright-shared/src/page-objects/pages/shared.page.ts @@ -0,0 +1,43 @@ +/*! + * 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 . + */ + +import { Page } from '@playwright/test'; +import { BasePage } from './base.page'; +import { DataTableComponent, MatMenuComponent, ViewerComponent } from '../components'; +import { AcaHeader } from '../components/aca-header.component'; +import { AdfFolderDialogComponent } from '../components/dialogs'; + +export class SharedPage extends BasePage { + private static pageUrl = 'shared'; + + constructor(page: Page) { + super(page, SharedPage.pageUrl); + } + + public acaHeader = new AcaHeader(this.page); + public matMenu = new MatMenuComponent(this.page); + public folderDialog = new AdfFolderDialogComponent(this.page); + public dataTable = new DataTableComponent(this.page); + public viewer = new ViewerComponent(this.page); +} diff --git a/projects/aca-playwright-shared/src/resources/test-files/file-docx.docx b/projects/aca-playwright-shared/src/resources/test-files/file-docx.docx new file mode 100644 index 0000000000..7d4e30425e Binary files /dev/null and b/projects/aca-playwright-shared/src/resources/test-files/file-docx.docx differ diff --git a/projects/aca-playwright-shared/src/resources/test-files/index.ts b/projects/aca-playwright-shared/src/resources/test-files/index.ts new file mode 100644 index 0000000000..a516a5d5c3 --- /dev/null +++ b/projects/aca-playwright-shared/src/resources/test-files/index.ts @@ -0,0 +1,22 @@ +/* + * Copyright © 2005 - 2021 Alfresco Software, Ltd. All rights reserved. + * + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +import { resolve } from 'path'; + +export const TEST_FILES = { + DOCX: { + path: resolve(__dirname, 'file-docx.docx'), + name: 'file-docx', + data: 'Lorem ipsum dolor sit amet' + }, + PDF: { + path: resolve(__dirname, 'file-pdf.pdf'), + name: 'file-pdf', + data: 'Lorem ipsum dolor sit amet' + }, +};