Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[ACS-5866] authentication playwright tests #3391

Merged
merged 11 commits into from
Aug 18, 2023
4 changes: 3 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
fail-fast: false
matrix:
e2e-suites:
- name: "authentication,listViews,navigation,application"
- name: "listViews,navigation,application"
id: 1
- name: "search"
id: 2
Expand Down Expand Up @@ -178,6 +178,8 @@ jobs:
id: 2
- name: "viewer"
id: 3
- name: "authentication"
id: 4
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
26 changes: 26 additions & 0 deletions e2e/playwright/authentication/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"extends": "../../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"e2e/playwright/authentication/tsconfig.e2e.json"
],
"createDefaultProgram": true
},
"plugins": [
"rxjs",
"unicorn"
],
"rules": {
"@typescript-eslint/no-floating-promises": "off"
}
}
]
}
3 changes: 3 additions & 0 deletions e2e/playwright/authentication/exclude.tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C213097" : "https://alfresco.atlassian.net/browse/ACS-5479"
}
44 changes: 44 additions & 0 deletions e2e/playwright/authentication/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

import { PlaywrightTestConfig } from '@playwright/test';
import { CustomConfig, getGlobalConfig, getExcludedTestsRegExpArray } from '@alfresco/playwright-shared';
import EXCLUDED_JSON from './exclude.tests.json';

const config: PlaywrightTestConfig<CustomConfig> = {
...getGlobalConfig,

grepInvert: getExcludedTestsRegExpArray(EXCLUDED_JSON, 'Authentication'),
projects: [
{
name: 'Authentication',
testDir: './src/tests',
use: {
users: ['hruser', 'admin']
}
}
]
};

export default config;
34 changes: 34 additions & 0 deletions e2e/playwright/authentication/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"name": "authentication-e2e",
"sourceRoot": "e2e/playwright/authentication/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "nx:run-commands",
"options": {
"commands": [
"npx playwright test --config=e2e/playwright/authentication/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}"]
}
}
}
105 changes: 105 additions & 0 deletions e2e/playwright/authentication/src/tests/login.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*!
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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

test.describe('viewer file', () => {
const apiClientFactory = new ApiClientFactory();

const otherLanguageUser = {
/* cspell:disable-next-line */
username: `пользвате${Utils.random()}`,
password: '密碼中國'
};

const johnDoe = {
username: `user-${Utils.random()}`,
get password() {
return this.username;
},
firstName: 'John',
lastName: 'Doe'
};

const testUser2 = {
username: `user-${Utils.random()}`,
password: 'user2 password'
};
const newPassword = 'new password';

test.beforeAll(async () => {
await apiClientFactory.setUpAcaBackend('admin');

await apiClientFactory.createUser(otherLanguageUser);
await apiClientFactory.createUser(johnDoe);
await apiClientFactory.createUser(testUser2);
});

test.describe('general tests', () => {
test('[C213089] login page layout', async ({ loginPage }) => {
await loginPage.navigate();
expect(await loginPage.username.isEnabled(), 'username input is not enabled').toBe(true);
expect(await loginPage.password.isEnabled(), 'password input is not enabled').toBe(true);
expect(await loginPage.submitButton.isEnabled(), 'SIGN IN button is enabled').toBe(false);
await loginPage.password.fill('text');
expect(await loginPage.isPasswordDisplayed(), 'Password is not hidden by default').toBe(false);
await loginPage.passwordVisibility.click();
expect(await loginPage.isPasswordDisplayed(), 'Password is not visible on show password').toBe(true);
});
});

test.describe('with invalid credentials', () => {
test('[C213106] unauthenticated user is redirected to Login page', async ({ personalFiles }) => {
await personalFiles.navigate();
expect(personalFiles.page.url()).toContain('login');
});
});

test.describe('with valid credentials', () => {
test('[C213097] logs in with user with non-latin characters', async ({ loginPage }) => {
await loginPage.navigate();
await loginPage.loginUser({ username: otherLanguageUser.username, password: otherLanguageUser.password });
expect(await loginPage.page.url()).toContain('personal-files');
});

test('[C213107] redirects to Home Page when navigating to the Login page while already logged in', async ({ loginPage }) => {
const { username } = johnDoe;
await loginPage.navigate();
await loginPage.loginUser({ username: username, password: username });
await loginPage.userProfileButton.waitFor({ state: 'attached' });
await loginPage.navigate();
await loginPage.userProfileButton.waitFor({ state: 'attached' });
expect(loginPage.page.url()).toContain('personal-files');
});

test('[C213104] user is able to login after changing his password', async ({ loginPage }) => {
await apiClientFactory.changePassword(testUser2.username, newPassword);
await loginPage.navigate();
await loginPage.loginUser({ username: testUser2.username, password: newPassword });
await loginPage.userProfileButton.waitFor({ state: 'attached' });
expect(loginPage.page.url()).toContain('personal-files');
});
});
});
49 changes: 49 additions & 0 deletions e2e/playwright/authentication/src/tests/logout.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*!
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Alfresco Example Content Application
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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

test.describe('viewer file', () => {
const apiClientFactory = new ApiClientFactory();
const testUser = {
username: `user-${Utils.random()}`,
password: 'user password'
};
test.beforeAll(async () => {
await apiClientFactory.setUpAcaBackend('admin');
await apiClientFactory.createUser(testUser);
});

test('[C213145] redirects to Login page when pressing browser Back after logout', async ({ loginPage }) => {
await loginPage.navigate();
await loginPage.loginUser({ username: testUser.username, password: testUser.password });
await loginPage.logoutUser();
await loginPage.username.waitFor({ state: 'attached' });
expect(loginPage.page.url()).toContain('login');
await loginPage.page.goBack();
await loginPage.username.waitFor({ state: 'attached' });
expect(loginPage.page.url()).toContain('login');
});
});
15 changes: 15 additions & 0 deletions e2e/playwright/authentication/tsconfig.e2e.adf.json
Original file line number Diff line number Diff line change
@@ -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"]
}
12 changes: 12 additions & 0 deletions e2e/playwright/authentication/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -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"]
}
7 changes: 2 additions & 5 deletions e2e/playwright/viewer/src/tests/viewer-action.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ test.describe('viewer action file', () => {
});

test.afterAll(async () => {
await apiClientFactory.nodes.deleteNode(folderId);
await apiClientFactory.trashCan.deleteDeletedNode(folderId);
await apiClientFactory.nodes.deleteNode(folderId, { permanent: true });
});

test('[C268129] Download action', async ({ personalFiles }) => {
Expand All @@ -82,7 +81,6 @@ test.describe('viewer action file', () => {
await personalFiles.dataTable.getCellLinkByName(randomDocxName).waitFor({ state: 'attached' });
expect(await personalFiles.dataTable.getCellLinkByName(randomDocxDelete).isVisible(), 'file should not visible').toBe(false);
await trashPage.navigate({ waitUntil: 'domcontentloaded' });
await trashPage.dataTable.goThroughPagesLookingForRowWithName(randomDocxDelete);
expect(await trashPage.dataTable.isItemPresent(randomDocxDelete), 'Item should be present in Trash').toBe(true);
});

Expand Down Expand Up @@ -130,7 +128,7 @@ test.describe('viewer action file', () => {
expect(await personalFiles.viewer.isViewerOpened(), 'Viewer should be opened').toBe(true);
});

test('[C286379] Favorite action from Shared Files', async ({ sharedPage, favoritePage, shareAction }) => {
test('[C286379] Favorite action from Shared Files', async ({ sharedPage, favoritePage }) => {
await sharedPage.navigate({ waitUntil: 'domcontentloaded' });
await sharedPage.dataTable.performClickFolderOrFileToOpen(randomDocxNameShare);
expect(await sharedPage.viewer.isViewerOpened(), 'Viewer should be opened').toBe(true);
Expand All @@ -146,7 +144,6 @@ test.describe('viewer action file', () => {
await sharedPage.page.keyboard.press('Escape');
await favoritePage.navigate({ waitUntil: 'domcontentloaded' });
expect(await favoritePage.dataTable.isItemPresent(randomDocxNameShare), 'Item is not present in Favorites list').toBe(true);
expect(await shareAction.isFavorite(randomDocxNameShare, 'hruser'), 'Item is not favorite').toBe(true);
});

test('[C286395] Share action from Favorites', async ({ favoritePage }) => {
Expand Down
8 changes: 4 additions & 4 deletions e2e/playwright/viewer/src/tests/viewer-protected.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ test.use({ storageState: getUserState('hruser') });
test.describe('viewer file', () => {
const apiClientFactory = new ApiClientFactory();
const randomFolderName = `playwright-folder-${Utils.random()}`;
const randomDocxName = `${TEST_FILES.DOCX_PROTECTED.name}-${Utils.random()}`;
const randomDocxName = `${TEST_FILES.PDF_PROTECTED.name}-${Utils.random()}`;
let folderId: string;
let fileDocxId: string;

test.beforeAll(async ({ fileAction, shareAction, favoritesPageAction: favoritesPageAction }) => {
await apiClientFactory.setUpAcaBackend('hruser');
const node = await apiClientFactory.nodes.createNode('-my-', { name: randomFolderName, nodeType: 'cm:folder', relativePath: '/' });
folderId = node.entry.id;
const fileDoc = await fileAction.uploadFile(TEST_FILES.DOCX_PROTECTED.path, randomDocxName, folderId);
const fileDoc = await fileAction.uploadFile(TEST_FILES.PDF_PROTECTED.path, randomDocxName, folderId);
akashrathod28 marked this conversation as resolved.
Show resolved Hide resolved
fileDocxId = fileDoc.entry.id;
await shareAction.shareFileById(fileDocxId);
await favoritesPageAction.addFavoriteById('file', fileDocxId);
Expand All @@ -61,7 +61,7 @@ test.describe('viewer file', () => {
});

test('[C268959] File content is displayed when entering the correct password', async ({ personalFiles }) => {
await personalFiles.passwordDialog.enterPassword(TEST_FILES.DOCX_PROTECTED.password);
await personalFiles.passwordDialog.enterPassword(TEST_FILES.PDF_PROTECTED.password);
expect(await personalFiles.passwordDialog.submitButton.isVisible(), 'Submit button not enabled').toBe(true);

await personalFiles.passwordDialog.submitButton.click();
Expand All @@ -80,7 +80,7 @@ test.describe('viewer file', () => {
});

test('[C268961] Refresh the page while Password dialog is open', async ({ personalFiles }) => {
await personalFiles.passwordDialog.enterPassword(TEST_FILES.DOCX_PROTECTED.password);
await personalFiles.passwordDialog.enterPassword(TEST_FILES.PDF_PROTECTED.password);
await personalFiles.reload({ waitUntil: 'domcontentloaded' });
await personalFiles.viewer.waitForViewerToOpen();

Expand Down
Loading