-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Major refactors in pageobjects (#26015)
## Proposed changes (including videos or screenshots) - Simplify pageobjects - Remove unused code
- Loading branch information
souzaramon
authored
Jun 27, 2022
1 parent
e85a63b
commit 89546dd
Showing
45 changed files
with
309 additions
and
519 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
import { PlaywrightTestConfig } from '@playwright/test'; | ||
|
||
import { verifyTestBaseUrl } from './tests/e2e/utils/configs/verifyTestBaseUrl'; | ||
import * as constants from './tests/e2e/utils/constants'; | ||
|
||
const { isLocal, baseURL } = verifyTestBaseUrl(); | ||
|
||
const localInserts = isLocal | ||
const setupIsLocalhost = constants.IS_LOCALHOST | ||
? { | ||
globalSetup: require.resolve('./tests/e2e/utils/configs/setup.ts'), | ||
globalTeardown: require.resolve('./tests/e2e/utils/configs/teardown.ts'), | ||
globalSetup: require.resolve('./tests/e2e/configs/setup.ts'), | ||
globalTeardown: require.resolve('./tests/e2e/configs/teardown.ts'), | ||
} | ||
: { testIgnore: '00-wizard.spec.ts' }; | ||
|
||
const config: PlaywrightTestConfig = { | ||
...localInserts, | ||
export default { | ||
...setupIsLocalhost, | ||
use: { | ||
headless: true, | ||
viewport: { width: 1368, height: 768 }, | ||
ignoreHTTPSErrors: true, | ||
video: 'retain-on-failure', | ||
screenshot: 'only-on-failure', | ||
trace: 'retain-on-failure', | ||
baseURL, | ||
baseURL: constants.BASE_URL, | ||
}, | ||
outputDir: 'tests/e2e/test-failures', | ||
reporter: process.env.CI ? 'github' : 'list', | ||
testDir: 'tests/e2e', | ||
retries: 3, | ||
workers: 1, | ||
timeout: 42 * 1000, | ||
}; | ||
|
||
export default config; | ||
} as PlaywrightTestConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,40 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
import { Global, LoginPage } from './pageobjects'; | ||
import { VALID_EMAIL, INVALID_EMAIL, INVALID_EMAIL_WITHOUT_MAIL_PROVIDER } from './utils/mocks/userAndPasswordMock'; | ||
|
||
test.describe('[Forgot Password]', () => { | ||
let loginPage: LoginPage; | ||
let global: Global; | ||
|
||
test.beforeEach(async ({ page, baseURL }) => { | ||
test.beforeEach(async ({ page }) => { | ||
loginPage = new LoginPage(page); | ||
global = new Global(page); | ||
const baseUrl = baseURL as string; | ||
await loginPage.goto(baseUrl); | ||
await loginPage.gotToForgotPassword(); | ||
|
||
await page.goto('/'); | ||
await loginPage.btnForgotPassword.click(); | ||
}); | ||
|
||
test('expect be required', async () => { | ||
loginPage.submit(); | ||
loginPage.btnSubmit.click(); | ||
|
||
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 loginPage.emailField.type('mail'); | ||
await loginPage.btnSubmit.click(); | ||
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 loginPage.emailField.type('mail@mail'); | ||
await loginPage.btnSubmit.click(); | ||
await expect(loginPage.emailInvalidText).toBeVisible(); | ||
}); | ||
|
||
test('expect user type a valid email', async () => { | ||
await loginPage.emailField.type(VALID_EMAIL); | ||
await loginPage.submit(); | ||
await loginPage.emailField.type('mail@mail.com'); | ||
await loginPage.btnSubmit.click(); | ||
await expect(global.getToastBarSuccess).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
import { test } from '@playwright/test'; | ||
import { test, expect } from '@playwright/test'; | ||
|
||
import { registerUser, WRONG_PASSWORD } from './utils/mocks/userAndPasswordMock'; | ||
import { registerUser } from './utils/mocks/userAndPasswordMock'; | ||
import { LoginPage } from './pageobjects'; | ||
|
||
test.describe('[Register]', () => { | ||
let loginPage: LoginPage; | ||
|
||
test.beforeEach(async ({ page, baseURL }) => { | ||
const URL = baseURL as string; | ||
test.beforeEach(async ({ page }) => { | ||
loginPage = new LoginPage(page); | ||
await loginPage.goto(URL); | ||
await page.goto('/'); | ||
}); | ||
|
||
test('expect user click in register button without data', async () => { | ||
await loginPage.registerFail(); | ||
await loginPage.btnRegister.click(); | ||
await loginPage.btnSubmit.click(); | ||
|
||
await expect(loginPage.nameInvalidText).toBeVisible(); | ||
await expect(loginPage.emailInvalidText).toBeVisible(); | ||
await expect(loginPage.passwordInvalidText).toBeVisible(); | ||
}); | ||
|
||
test('expect user click in register button with different password', async () => { | ||
await loginPage.registerFailWithDifferentPassword(registerUser, WRONG_PASSWORD); | ||
await loginPage.btnRegister.click(); | ||
await loginPage.passwordField.type(registerUser.password); | ||
await loginPage.emailField.type(registerUser.email); | ||
await loginPage.nameField.type(registerUser.name); | ||
await loginPage.confirmPasswordField.type('wrong_password'); | ||
|
||
await loginPage.btnSubmit.click(); | ||
await expect(loginPage.confirmPasswordInvalidText).toBeVisible(); | ||
await expect(loginPage.confirmPasswordInvalidText).toHaveText('The password confirmation does not match password'); | ||
}); | ||
|
||
test('expect new user is created', async () => { | ||
await loginPage.gotToRegister(); | ||
await loginPage.btnRegister.click(); | ||
await loginPage.registerNewUser(registerUser); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import { test } from '@playwright/test'; | ||
import { faker } from '@faker-js/faker'; | ||
|
||
import { LoginPage, ChannelCreation } from './pageobjects'; | ||
import { LoginPage, SideNav } from './pageobjects'; | ||
import { adminLogin } from './utils/mocks/userAndPasswordMock'; | ||
|
||
test.describe('[Channel]', async () => { | ||
let channelCreation: ChannelCreation; | ||
let sideNav: SideNav; | ||
let loginPage: LoginPage; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
const page = await browser.newPage(); | ||
loginPage = new LoginPage(page); | ||
channelCreation = new ChannelCreation(page); | ||
sideNav = new SideNav(page); | ||
|
||
await loginPage.goto('/'); | ||
await page.goto('/'); | ||
await loginPage.doLogin(adminLogin); | ||
}); | ||
|
||
test('expect create private channel', async () => { | ||
await channelCreation.doCreateChannel(faker.animal.type() + Date.now(), true); | ||
await sideNav.doCreateChannel(faker.animal.type() + Date.now(), true); | ||
}); | ||
|
||
test('expect create public channel', async () => { | ||
await channelCreation.doCreateChannel(faker.animal.type() + Date.now()); | ||
await sideNav.doCreateChannel(faker.animal.type() + Date.now()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.