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

Chore: Tests with Playwright (task: ROC-29, 10-user-preferences) #25048

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3e607fe
chore: playwright config and start the first test
Mar 23, 2022
67f8a42
chore: configuration of files to run playwright
Mar 24, 2022
0d9291a
test: ensure all flow of unlloged area is work
Mar 24, 2022
3c1c421
test: wizard page
tmontini Mar 25, 2022
63d2370
test: implements wizard on playwright
tmontini Mar 28, 2022
fd4d726
test: pageObject patter global
Mar 28, 2022
c1bd16a
Merge branch 'ROC-15' of github.com:RocketChat/Rocket.Chat into ROC-15
Mar 28, 2022
b7e7726
chore: remove unused variables
Mar 28, 2022
0ec7d14
Merge branch 'develop' into ROC-15
Mar 28, 2022
4aac14b
fix: add function
Mar 28, 2022
2617fda
fix: remove unexpected test
tmontini Mar 28, 2022
b5f12ed
fix: final step test setup wizard
tmontini Mar 29, 2022
efc78e5
Merge branch 'develop' into ROC-15
Mar 29, 2022
2163fa2
chore: rename files
Mar 29, 2022
795052b
fix: spell check descriptions tests
tmontini Mar 29, 2022
95baaa1
test: ensure channel is working
weslley543 Mar 29, 2022
33a7c51
test: creating chats and send message to a channel
weslley543 Mar 29, 2022
06a3ab6
refactor: add mocks and adjust in test suites
weslley543 Mar 30, 2022
20281c4
chore: remove unused class
weslley543 Mar 30, 2022
429c401
lint
weslley543 Mar 30, 2022
f8af23b
test: create flas-tab, main-content and side-nav
tmontini Mar 30, 2022
2ae4ed1
test: create main-elements tests file
tmontini Mar 30, 2022
d71b5b7
refactor: for playwright
tmontini Mar 30, 2022
b17e15a
refactor: apply new pattern
tmontini Mar 30, 2022
5dbf97c
test: ending 04-main-elements-render
tmontini Mar 31, 2022
93f629a
test: migrate 07-emoji to playwright
tmontini Mar 31, 2022
2a2e757
test: remove docker-compose.yml from commit
tmontini Mar 31, 2022
30a4c14
test: remove app.json from commit
tmontini Mar 31, 2022
f6c1b0b
test: end migrate 07-emoji tests to playwright
tmontini Mar 31, 2022
0722c1d
test: remove docker-compose.yml from commit
tmontini Mar 31, 2022
48bb78c
test: remove app.json from commit
tmontini Mar 31, 2022
2327350
Merge remote-tracking branch 'origin/ROC-15-develop' into ROC-15-develop
tmontini Mar 31, 2022
2f10066
Merge branch 'develop' into ROC-26-emoji-ok
tmontini Mar 31, 2022
3c11e28
chore: include playwright
tmontini Mar 31, 2022
c919adc
refactor: use admin Username
tmontini Mar 31, 2022
3356def
fix: eslint
tmontini Mar 31, 2022
6a4096e
refactor: remove unused functions
tmontini Apr 1, 2022
5af66f9
Merge branch 'ROC-26-emoji-ok' into ROC-15-develop
tmontini Apr 1, 2022
28f1f96
test: begin 10-user-preferences.spec.ts (playwright)
tmontini Apr 1, 2022
7adea34
refactor: end migrate 10-user-preferences.spec.ts tests to playwright
tmontini Apr 4, 2022
4512aea
Merge branch 'develop' into ROC-29-ok
tmontini Apr 4, 2022
b4e75f3
fix a skip test
tmontini Apr 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@ tests/end-to-end/temporary_staged_test
/storybook-static
/tests/cypress/screenshots
/tests/cypress/videos
/tests/e2e/test-failures
coverage
.nyc_output
data
1,031 changes: 1,029 additions & 2 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"scripts": {
"prepare": "husky install",
"start": "meteor",
"dev": "meteor reset && npm start",
"ha": "meteor npm run ha:start",
"ha:start": "ts-node .scripts/run-ha.ts main",
"ha:add": "ts-node .scripts/run-ha.ts instance",
Expand All @@ -36,6 +37,9 @@
"testunit-definition": "mocha --config ./.mocharc.definition.js",
"testunit-watch": "mocha --watch --config ./.mocharc.js",
"test": "npm run testapi && npm run testui",
"test:playwright": "playwright test",
"test:playwright:watch": "PWDEBUG=1 playwright test",
"test:playwright:headed": "playwright test --headed",
"translation-diff": "node .scripts/translationDiff.js",
"translation-check": "node .scripts/check-i18n.js",
"translation-fix-order": "node .scripts/fix-i18n.js",
Expand All @@ -60,6 +64,7 @@
"@babel/preset-env": "^7.14.7",
"@babel/preset-react": "^7.14.5",
"@babel/register": "^7.14.5",
"@playwright/test": "^1.20.0",
"@rocket.chat/eslint-config": "^0.4.0",
"@rocket.chat/livechat": "^1.12.2",
"@settlin/spacebars-loader": "^1.0.9",
Expand Down
18 changes: 18 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
outputDir: 'tests/e2e/test-failures',
reporter: [['list']],
workers: 3,
use: {
baseURL: process.env.BASE_URL || 'http://localhost:3000',
headless: false,
viewport: { width: 1368, height: 768 },
ignoreHTTPSErrors: true,
video: 'retain-on-failure',
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
},
testDir: 'tests/e2e',
};
export default config;
99 changes: 99 additions & 0 deletions tests/e2e/00-wizard.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { test, expect } from '@playwright/test';

import SetupWizard from './utils/pageobjects/wizard.page';
import { adminRegister, VALID_EMAIL } from './utils/mocks/userAndPasswordMock';
import { LOCALHOST, setupWizardStepRegex } from './utils/mocks/urlMock';
import { HOME_SELECTOR } from './utils/mocks/waitSelectorsMock';

test.describe('[Wizard]', () => {
let setupWizard: SetupWizard;
test.beforeEach(async ({ page }) => {
setupWizard = new SetupWizard(page);
});
test.describe('[Step 1]', () => {
test.beforeEach(async ({ baseURL }) => {
const baseUrl = baseURL || LOCALHOST;
await setupWizard.goto(baseUrl);
});

test('expect required field alert showed when user dont inform data', async () => {
await setupWizard.stepOneFailedBlankFields();
});

test('expect alert showed when email provided is invalid', async () => {
await setupWizard.stepOneFailedWithInvalidEmail(adminRegister);
});

test('expect go to Step 2 successfully', async () => {
await setupWizard.stepOneSucess(adminRegister);

await expect(setupWizard.getPage()).toHaveURL(setupWizardStepRegex._2);
});
});

test.describe('[Step 2]', async () => {
test.beforeEach(async ({ baseURL }) => {
const baseUrl = baseURL || LOCALHOST;
await setupWizard.goto(baseUrl);
await setupWizard.stepOneSucess(adminRegister);
});

test('expect required field alert showed when user dont inform data', async () => {
await setupWizard.stepTwoFailedWithBlankFields();
});

test('expect go to Step 3 successfully', async () => {
await setupWizard.stepTwoSucess();
await expect(setupWizard.getPage()).toHaveURL(setupWizardStepRegex._3);
});
});

test.describe('[Step 3]', async () => {
test.beforeEach(async () => {
await setupWizard.goto('');
await setupWizard.stepOneSucess(adminRegister);
await setupWizard.stepTwoSucess();
});

test('expect have email field to register the server', async () => {
await expect(setupWizard.registeredServer()).toBeVisible();
});

test('expect start "Register" button disabled', async () => {
await expect(setupWizard.registerButton()).toBeDisabled();
});

test('expect show an error on invalid email', async () => {
await setupWizard.stepThreeFailedWithInvalidField();
});

test('expect enable "Register" button when email is valid and terms checked', async () => {
await setupWizard.registeredServer().type(VALID_EMAIL);
await setupWizard.agreementField().click();
await expect(setupWizard.registerButton()).toBeEnabled();
});

test('expect have option for standalone server', async () => {
await expect(setupWizard.standaloneServer()).toBeVisible();
});
});

test.describe('[Final Step]', async () => {
test.beforeEach(async () => {
await setupWizard.goto('');
await setupWizard.stepOneSucess(adminRegister);
await setupWizard.stepTwoSucess();
await setupWizard.stepThreeSucess();
});

test('expect confirm the standalone option', async () => {
await expect(setupWizard.goToWorkspace()).toBeVisible();
await expect(setupWizard.standaloneConfirmText()).toBeVisible();
});

test('expect confirm standalone', async () => {
await setupWizard.goToWorkspace().click();
await setupWizard.waitForSelector(HOME_SELECTOR);
});
});
});
40 changes: 40 additions & 0 deletions tests/e2e/01-forgot-password.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { test, expect } from '@playwright/test';

import LoginPage from './utils/pageobjects/login.page';
import { LOCALHOST } from './utils/mocks/urlMock';
import { VALID_EMAIL, INVALID_EMAIL, INVALID_EMAIL_WITHOUT_MAIL_PROVIDER } from './utils/mocks/userAndPasswordMock';

test.describe('[Forgot Password]', () => {
let loginPage: LoginPage;

test.beforeEach(async ({ page, baseURL }) => {
loginPage = new LoginPage(page);
const baseUrl = baseURL || LOCALHOST;
await loginPage.goto(baseUrl);
await loginPage.gotToForgotPassword();
});

test('expect be required', async () => {
loginPage.submit();

await expect(loginPage.emailInvalidText()).toBeVisible();
});

test('expect invalid for email without domain', async () => {
await loginPage.emailField().type(INVALID_EMAIL_WITHOUT_MAIL_PROVIDER);
await loginPage.submit();
await expect(loginPage.emailInvalidText()).toBeVisible();
});

test('expect be invalid for email with invalid domain', async () => {
await loginPage.emailField().type(INVALID_EMAIL);
await loginPage.submit();
await expect(loginPage.emailInvalidText()).toBeVisible();
});

test('expect user type a valid email', async () => {
await loginPage.emailField().type(VALID_EMAIL);
await loginPage.submit();
await expect(loginPage.getToastMessageSuccess()).toBeVisible();
});
});
28 changes: 28 additions & 0 deletions tests/e2e/02-register.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { test } from '@playwright/test';

import { registerUser, WRONG_PASSWORD } from './utils/mocks/userAndPasswordMock';
import LoginPage from './utils/pageobjects/login.page';
import { LOCALHOST } from './utils/mocks/urlMock';

test.describe('[Register]', () => {
let loginPage: LoginPage;

test.beforeEach(async ({ page, baseURL }) => {
const URL = baseURL || LOCALHOST;
loginPage = new LoginPage(page);
await loginPage.goto(URL);
});

test('expect user click in register button without data', async () => {
await loginPage.registerFail();
});

test('expect user click in register button with different password', async () => {
await loginPage.registerFailWithDifentPassword(registerUser, WRONG_PASSWORD);
});

test('expect new user is created', async () => {
await loginPage.gotToRegister();
await loginPage.registerNewUser(registerUser);
});
});
30 changes: 30 additions & 0 deletions tests/e2e/03-login.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { test, expect } from '@playwright/test';

import { validUser } from './utils/mocks/userAndPasswordMock';
import LoginPage from './utils/pageobjects/login.page';
import { LOCALHOST } from './utils/mocks/urlMock';
import { HOME_SELECTOR } from './utils/mocks/waitSelectorsMock';

test.describe('[Login]', () => {
let loginPage: LoginPage;

test.beforeEach(async ({ page, baseURL }) => {
const baseUrl = baseURL || LOCALHOST;
loginPage = new LoginPage(page);
await loginPage.goto(baseUrl);
});

test('expect user make login', async () => {
await loginPage.login(validUser);
await loginPage.waitForSelector(HOME_SELECTOR);
});

test('expect user write a password incorrectly', async () => {
const invalidUserPassword = {
email: validUser.email,
password: 'any_password1',
};
await loginPage.login(invalidUserPassword);
await expect(loginPage.getToastError()).toBeVisible();
});
});
Loading