Skip to content

Commit

Permalink
test: add settings admin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramon Souza committed May 10, 2022
1 parent 7e99158 commit 604dccf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/client/views/admin/users/UserInfoActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export const UserInfoActions = ({ username, _id, isActive, isAdmin, onChange, on
}, [actionsDefinition, menu]);

return (
<ButtonGroup flexGrow={0} justifyContent='center'>
<ButtonGroup flexGrow={0} justifyContent='center' data-qa-id='UserInfoActions'>
{actions}
</ButtonGroup>
);
Expand Down
40 changes: 27 additions & 13 deletions apps/meteor/tests/e2e/12-settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { test, expect, Page } from '@playwright/test';
import { v4 as uuid } from 'uuid';

import { BASE_API_URL } from './utils/mocks/urlMock';
import { adminLogin, validUserInserted } from './utils/mocks/userAndPasswordMock';
import { adminLogin, validUserInserted, registerUser } from './utils/mocks/userAndPasswordMock';
import LoginPage from './utils/pageobjects/LoginPage';
import MainContent from './utils/pageobjects/MainContent';
import SideNav from './utils/pageobjects/SideNav';
import Administration from './utils/pageobjects/Administration';
import PreferencesMainContent from './utils/pageobjects/PreferencesMainContent';

const apiSessionHeaders = { 'X-Auth-Token': '', 'X-User-Id': '' };

Expand All @@ -15,6 +16,7 @@ test.describe('[Settings]', async () => {
let loginPage: LoginPage;
let mainContent: MainContent;
let sideNav: SideNav;
let userPreferences: PreferencesMainContent;

test.beforeAll(async ({ browser }) => {
const context = await browser.newContext();
Expand All @@ -23,6 +25,7 @@ test.describe('[Settings]', async () => {
loginPage = new LoginPage(page);
mainContent = new MainContent(page);
sideNav = new SideNav(page);
userPreferences = new PreferencesMainContent(page);

await loginPage.goto('/');
await loginPage.login(validUserInserted);
Expand Down Expand Up @@ -337,8 +340,14 @@ test.describe('[Settings]', async () => {
expect(data).toHaveProperty('success', true);
});

test.skip('(UI) expect option(update profile) not be visible', async () => {
//
test.skip('(UI) expect options(update profile) be disabled', async () => {
await sideNav.sidebarUserMenu().click();
await sideNav.account().click();

expect(userPreferences.avatarFileInput().isDisabled()).toBeTruthy();
expect(userPreferences.emailTextInput().isDisabled()).toBeTruthy();
expect(userPreferences.realNameTextInput().isDisabled()).toBeTruthy();
expect(userPreferences.userNameTextInput().isDisabled()).toBeTruthy();
});

test('(API) expect enable profile change', async ({ request }) => {
Expand All @@ -353,7 +362,7 @@ test.describe('[Settings]', async () => {
});
});

test.describe('Avatar change', () => {
test.describe.only('Avatar change', () => {
test('(API) expect disable avatar change', async ({ request }) => {
const response = await request.post(`${BASE_API_URL}/settings/Accounts_AllowUserAvatarChange`, {
headers: apiSessionHeaders,
Expand All @@ -365,8 +374,11 @@ test.describe('[Settings]', async () => {
expect(data).toHaveProperty('success', true);
});

test.skip('(UI) expect option(update avatar) not be visible', async () => {
//
test.skip('(UI) expect option(update avatar) be disabled', async () => {
await sideNav.sidebarUserMenu().click();
await sideNav.account().click();

expect(userPreferences.avatarFileInput().isDisabled()).toBeTruthy();
});

test('(API) expect enable avatar change', async ({ request }) => {
Expand Down Expand Up @@ -451,7 +463,7 @@ test.describe('[Settings (admin)]', async () => {
});
});

test.describe('Manual new users approve', () => {
test.describe.serial('Manual new users approve', () => {
test('(API) expect enable manually approve new users', async ({ request }) => {
const response = await request.post(`${BASE_API_URL}/settings/Accounts_ManuallyApproveNewUsers`, {
headers: apiSessionHeaders,
Expand All @@ -463,23 +475,25 @@ test.describe('[Settings (admin)]', async () => {
expect(data).toHaveProperty('success', true);
});

test.describe.only('(UI) expect activate/deactivate flow as admin', () => {
test.describe('(UI) expect activate/deactivate flow as admin', () => {
test('expect open /users as admin', async () => {
await admin.goto('/admin');
await admin.usersLink().click();
});

test('expect find registered user', async () => {
await admin.usersFilter().type(validUserInserted.email, { delay: 200 });
await admin.userInTable(validUserInserted.email).click();
await admin.usersFilter().type(registerUser.email, { delay: 200 });
await admin.userInTable(registerUser.email).click();
});

test('expect activate registered user', async () => {
//
await admin.userInfoActions().locator('button:nth-child(3)').click();
await admin.getPage().locator('[value="changeActiveStatus"]').click();
});

test.skip('expect deactivate registered user', async () => {
//
test('expect deactivate registered user', async () => {
await admin.userInfoActions().locator('button:nth-child(3)').click();
await admin.getPage().locator('[value="changeActiveStatus"]').click();
});
});

Expand Down
1 change: 1 addition & 0 deletions apps/meteor/tests/e2e/utils/mocks/userAndPasswordMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const validUserInserted: ILogin = {
email: 'user.name.test@email.com',
password: 'any_password',
};

const validEmail = faker.internet.email();

export const registerUser: IRegister = {
Expand Down
4 changes: 4 additions & 0 deletions apps/meteor/tests/e2e/utils/pageobjects/Administration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,4 +674,8 @@ export default class Administration extends BasePage {
public async adminSaveChanges(): Promise<void> {
await this.buttonSave().click();
}

public userInfoActions(): Locator {
return this.getPage().locator('[data-qa-id="UserInfoActions"]');
}
}

0 comments on commit 604dccf

Please sign in to comment.