Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Code scanning - action / CodeQL-Build (push) Failing after 2s
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
167 lines
6.4 KiB
TypeScript
167 lines
6.4 KiB
TypeScript
import { faker } from '@faker-js/faker';
|
|
|
|
import { DEFAULT_USER_CREDENTIALS } from './config/constants';
|
|
import { Login, Registration } from './page-objects';
|
|
import { Navbar, RoomSidebar } from './page-objects/fragments';
|
|
import { getSettingValueById, setSettingValueById } from './utils';
|
|
import { test, expect } from './utils/test';
|
|
import type { ITestUser } from './utils/user-helpers';
|
|
import { createTestUser } from './utils/user-helpers';
|
|
|
|
test.describe('User - Password change required', () => {
|
|
let poLogin: Login;
|
|
let poRegistration: Registration;
|
|
let navbar: Navbar;
|
|
let sidebar: RoomSidebar;
|
|
let userRequiringPasswordChange: ITestUser;
|
|
let userNotRequiringPasswordChange: ITestUser;
|
|
let userNotAbleToLogin: ITestUser;
|
|
let settingDefaultValue: unknown;
|
|
|
|
test.beforeAll(async ({ api }) => {
|
|
settingDefaultValue = await getSettingValueById(api, 'Accounts_RequirePasswordConfirmation');
|
|
await setSettingValueById(api, 'Accounts_Password_Policy_Enabled', false);
|
|
await setSettingValueById(api, 'Accounts_RequirePasswordConfirmation', true);
|
|
userRequiringPasswordChange = await createTestUser(api, { data: { requirePasswordChange: true } });
|
|
userNotRequiringPasswordChange = await createTestUser(api, { data: { requirePasswordChange: false } });
|
|
userNotAbleToLogin = await createTestUser(api, { data: { requirePasswordChange: true } });
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
poLogin = new Login(page);
|
|
poRegistration = new Registration(page);
|
|
navbar = new Navbar(page);
|
|
sidebar = new RoomSidebar(page);
|
|
await poLogin.goto();
|
|
});
|
|
|
|
test.afterAll(async ({ api }) => {
|
|
await Promise.all([
|
|
setSettingValueById(api, 'Accounts_RequirePasswordConfirmation', settingDefaultValue),
|
|
userRequiringPasswordChange.delete(),
|
|
userNotRequiringPasswordChange.delete(),
|
|
userNotAbleToLogin.delete(),
|
|
setSettingValueById(api, 'Accounts_Password_Policy_Enabled', true),
|
|
]);
|
|
});
|
|
|
|
test('should redirect to home after successful password change for new user', async ({ page }) => {
|
|
await test.step('login with temporary password', async () => {
|
|
await poLogin.login(userRequiringPasswordChange.data.username, DEFAULT_USER_CREDENTIALS.password);
|
|
});
|
|
|
|
await test.step('should be redirected to password change screen', async () => {
|
|
await expect(poRegistration.inputPassword).toBeVisible();
|
|
await expect(poRegistration.inputPasswordConfirm).toBeVisible();
|
|
});
|
|
|
|
await test.step('enter new password and confirm', async () => {
|
|
const newPassword = faker.internet.password();
|
|
await poRegistration.inputPassword.fill(newPassword);
|
|
await poRegistration.inputPasswordConfirm.fill(newPassword);
|
|
});
|
|
|
|
await test.step('click reset button', async () => {
|
|
await poRegistration.btnReset.click();
|
|
});
|
|
|
|
await test.step('verify password reset form is not visible', async () => {
|
|
await page.waitForURL('/home');
|
|
await expect(poRegistration.inputPassword).not.toBeVisible();
|
|
await expect(poRegistration.inputPasswordConfirm).not.toBeVisible();
|
|
});
|
|
|
|
await test.step('verify user is properly logged in', async () => {
|
|
await expect(navbar.btnUserMenu).toBeVisible();
|
|
await expect(sidebar.channelsList).toBeVisible();
|
|
});
|
|
});
|
|
|
|
test('should show error when password confirmation does not match', async () => {
|
|
await test.step('login with temporary password', async () => {
|
|
await poLogin.login(userNotAbleToLogin.data.username, DEFAULT_USER_CREDENTIALS.password);
|
|
});
|
|
|
|
await test.step('should be redirected to password change screen', async () => {
|
|
await expect(poRegistration.inputPassword).toBeVisible();
|
|
await expect(poRegistration.inputPasswordConfirm).toBeVisible();
|
|
});
|
|
|
|
await test.step('enter different passwords in password and confirm fields', async () => {
|
|
await poRegistration.inputPassword.fill(DEFAULT_USER_CREDENTIALS.password);
|
|
await poRegistration.inputPasswordConfirm.fill(faker.internet.password());
|
|
});
|
|
|
|
await test.step('attempt to submit password change', async () => {
|
|
await poRegistration.btnReset.click();
|
|
});
|
|
|
|
await test.step('verify error message appears for password mismatch', async () => {
|
|
await expect(poRegistration.inputPasswordConfirm).toBeInvalid();
|
|
});
|
|
});
|
|
|
|
test('should show error when user tries to use the same password as current', async () => {
|
|
await test.step('login with temporary password', async () => {
|
|
await poLogin.login(userNotAbleToLogin.data.username, DEFAULT_USER_CREDENTIALS.password);
|
|
});
|
|
|
|
await test.step('should be redirected to password change screen', async () => {
|
|
await expect(poRegistration.inputPassword).toBeVisible();
|
|
await expect(poRegistration.inputPasswordConfirm).toBeVisible();
|
|
});
|
|
|
|
await test.step('enter the same password as current password', async () => {
|
|
await poRegistration.inputPassword.fill(DEFAULT_USER_CREDENTIALS.password);
|
|
await poRegistration.inputPasswordConfirm.fill(DEFAULT_USER_CREDENTIALS.password);
|
|
});
|
|
|
|
await test.step('attempt to submit password change', async () => {
|
|
await poRegistration.btnReset.click();
|
|
});
|
|
|
|
await test.step('verify error message appears for same password', async () => {
|
|
await expect(poRegistration.inputPassword).toBeInvalid();
|
|
});
|
|
});
|
|
});
|
|
|
|
test.describe('User - Password change not required', () => {
|
|
let poLogin: Login;
|
|
let navbar: Navbar;
|
|
let sidebar: RoomSidebar;
|
|
let userNotRequiringPasswordChange: ITestUser;
|
|
let settingDefaultValue: unknown;
|
|
|
|
test.beforeAll(async ({ api }) => {
|
|
settingDefaultValue = await getSettingValueById(api, 'Accounts_RequirePasswordConfirmation');
|
|
userNotRequiringPasswordChange = await createTestUser(api, { data: { requirePasswordChange: false } });
|
|
});
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
poLogin = new Login(page);
|
|
navbar = new Navbar(page);
|
|
sidebar = new RoomSidebar(page);
|
|
await poLogin.goto();
|
|
});
|
|
|
|
test.afterAll(async ({ api }) => {
|
|
await Promise.all([
|
|
setSettingValueById(api, 'Accounts_RequirePasswordConfirmation', settingDefaultValue),
|
|
userNotRequiringPasswordChange.delete(),
|
|
]);
|
|
});
|
|
|
|
test('should not require password change if the requirePasswordChange is disabled', async ({ page }) => {
|
|
await test.step('login with user not requiring password change', async () => {
|
|
await poLogin.login(userNotRequiringPasswordChange.data.username, DEFAULT_USER_CREDENTIALS.password);
|
|
});
|
|
|
|
await test.step('verify user is properly logged in', async () => {
|
|
await page.waitForURL('/home');
|
|
await expect(navbar.btnUserMenu).toBeVisible();
|
|
await expect(sidebar.channelsList).toBeVisible();
|
|
});
|
|
});
|
|
});
|