mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-5866] authentication playwright tests (#3391)
* viewer action files e2e migration * viewer action files e2e remove comment * review code fix * [ci:force] * [ACS-5650]viewer test with new user * remove commented code * login and logout playwright test * Update error message login.spec.ts
This commit is contained in:
105
e2e/playwright/authentication/src/tests/login.spec.ts
Normal file
105
e2e/playwright/authentication/src/tests/login.spec.ts
Normal file
@@ -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
e2e/playwright/authentication/src/tests/logout.spec.ts
Normal file
49
e2e/playwright/authentication/src/tests/logout.spec.ts
Normal file
@@ -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');
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user