-
Notifications
You must be signed in to change notification settings - Fork 1
Pb 5571 automate successful login flow #196
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
base: main
Are you sure you want to change the base?
Changes from all commits
b7c27a4
edde4f0
2795ec8
7f1d20d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| PLAYWRIGHT_BASE_URL=https://meet.internxt.com | ||
| PLAYWRIGHT_ULTIMATE_EMAIL=your-test-email@example.com | ||
| PLAYWRIGHT_ULTIMATE_PASSWORD=your-test-password | ||
| PLAYWRIGHT_ULTIMATE_NAME=Name |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,3 +123,4 @@ react-native-sdk/sounds | |
| tests/.env | ||
| test-results | ||
|
|
||
| .env.playwright | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,15 @@ | ||
| import * as dotenv from 'dotenv'; | ||
| dotenv.config({ path: '.env.playwright' }); | ||
|
|
||
| import { defineConfig } from '@playwright/test'; | ||
|
|
||
|
|
||
| export default defineConfig({ | ||
| testDir: './playwright/tests', | ||
| timeout: 60_000, | ||
| expect: { timeout: 10_000 }, | ||
| use: { | ||
| baseURL: 'https://localhost:8080', | ||
| baseURL: 'https://meet.internxt.com/', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe could create template for the playwright .env var as And use process.env.PLAYWRIGHT_BASE_URL for baseURL, in this way, each environment could inject the variables for the tests :)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created! |
||
| ignoreHTTPSErrors: true, | ||
| trace: 'on-first-retry', | ||
| screenshot: 'only-on-failure', | ||
|
|
@@ -14,4 +18,4 @@ export default defineConfig({ | |
| projects: [ | ||
| { name: 'chromium', use: { browserName: 'chromium' } }, | ||
| ], | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { expect, Page } from '@playwright/test'; | ||
| import 'dotenv/config'; | ||
|
|
||
| export async function login(page: Page, email: string, password: string) { | ||
| await page.goto('/'); | ||
|
|
||
| await page.getByRole('button', { name: 'Log in' }).click(); | ||
|
|
||
| const popupPromise = page.waitForEvent('popup'); | ||
| await page.getByRole('button', { name: 'Sign in with Internxt' }).click(); | ||
| const popup = await popupPromise; | ||
|
|
||
| const emailField = popup.locator('[data-cy="emailInput"]'); | ||
| const passField = popup.locator('[data-cy="passwordInput"]'); | ||
| const submitLoginButton = popup.locator('[data-cy="loginButton"]'); | ||
|
|
||
| await expect(emailField).toBeVisible({ timeout: 15_000 }); | ||
| await emailField.fill(email); | ||
|
|
||
| await expect(passField).toBeVisible({ timeout: 15_000 }); | ||
| await passField.fill(password); | ||
|
|
||
| await expect(submitLoginButton).toBeVisible({ timeout: 15_000 }); | ||
| await submitLoginButton.click(); | ||
|
|
||
| await Promise.race([ | ||
| popup.waitForEvent('close').catch(() => {}), | ||
| popup.waitForLoadState('networkidle').catch(() => {}), | ||
| ]); | ||
|
|
||
| if (!popup.isClosed()) { | ||
| await popup.close().catch(() => {}); | ||
| } | ||
|
|
||
| await expect(page.locator('button img.rounded-full').first()).toBeVisible({ timeout: 20_000 }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe better use
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, sure! I am preparing a list of the test IDs needed for the UI. Could you add them? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure :) |
||
| } | ||
|
|
||
| export async function expectLoggedIn(page: Page, email: string) { | ||
| const avatarButton = page.locator('button img.rounded-full').first(); | ||
|
|
||
| await expect(avatarButton).toBeVisible({ timeout: 20_000 }); | ||
| await avatarButton.click(); | ||
|
|
||
| const userMenu = page.locator('div.flex.items-center.p-3'); | ||
| await expect(userMenu).toContainText(email); | ||
|
|
||
| // close menu so next step starts from a clean state | ||
| await avatarButton.click(); | ||
| } | ||
|
|
||
| export async function logout(page: Page) { | ||
| const avatarButton = page.locator('button img.rounded-full').first(); | ||
| const logoutButton = page.getByRole('button', { name: /log out|logout|sign out/i }); | ||
|
|
||
| await expect(avatarButton).toBeVisible({ timeout: 20_000 }); | ||
| await avatarButton.click(); | ||
|
|
||
| await expect(logoutButton).toBeVisible({ timeout: 10_000 }); | ||
| await logoutButton.click(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Playwright Tests – Internxt Meet | ||
|
|
||
| This folder contains end-to-end (E2E) tests for **Internxt Meet** using **Playwright**. | ||
|
|
||
|
|
||
| --- | ||
| # Prerequisites | ||
|
|
||
| Make sure you have installed: | ||
|
|
||
| - Node.js | ||
| - Yarn | ||
| --- | ||
| # Install dependencies | ||
|
|
||
| Install project dependencies: | ||
|
|
||
| `yarn install` | ||
|
|
||
| --- | ||
| # Install Playwright browsers: | ||
|
|
||
| `npx playwright install` | ||
|
|
||
| # Environment configuration | ||
|
|
||
| Tests require environment variables. | ||
|
|
||
| Create a local environment file from the example template: | ||
|
|
||
| `cp .env.playwright.example .env.playwright` | ||
|
|
||
| Then update the values in **.env.playwright** with valid credentials. | ||
|
|
||
|
|
||
| # Running tests | ||
|
|
||
| Run all tests: | ||
|
|
||
| `npx playwright test` | ||
|
|
||
| Run a specific test file: | ||
|
|
||
| `npx playwright test playwright/tests/specific_test.spec.ts` | ||
|
|
||
| Run tests in UI mode: | ||
|
|
||
| `npx playwright test --ui` | ||
|
|
||
| # Debugging tests | ||
|
|
||
| Run tests with Playwright debugger: | ||
|
|
||
| `npx playwright test --debug` | ||
|
|
||
| # Test reports | ||
|
|
||
| After running tests, open the Playwright report: | ||
|
|
||
| `npx playwright show-report` | ||
|
|
||
| # Project structure | ||
| playwright/ | ||
| ├── helpers/ # reusable helper functions | ||
| ├── pages/ # page objects | ||
| ├── tests/ # test specifications | ||
| └── readme.md # documentation for Playwright tests | ||
|
|
||
| # Notes | ||
|
|
||
| Environment variables are loaded from **.env.playwright.** | ||
|
|
||
| **.env.playwright.example** provides a template for required variables. | ||
|
|
||
| **.env.playwright** should not be committed to the repository. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { login, expectLoggedIn, logout } from '../helpers/auth'; | ||
|
|
||
| const email = process.env.PLAYWRIGHT_ULTIMATE_EMAIL!; | ||
| const password = process.env.PLAYWRIGHT_ULTIMATE_PASSWORD!; | ||
|
|
||
| test.beforeAll(() => { | ||
| expect(email).toBeTruthy(); | ||
| expect(password).toBeTruthy(); | ||
| }); | ||
|
|
||
| test('User can log in', async ({ page }) => { | ||
|
|
||
| await test.step('GIVEN user logs in via Internxt', async () => { | ||
| await login(page, email, password); | ||
| }); | ||
|
|
||
| await test.step('THEN user is authenticated', async () => { | ||
| await expectLoggedIn(page, email); | ||
| }); | ||
|
|
||
| }); | ||
|
|
||
|
|
||
| test('User can log out', async ({ page }) => { | ||
|
|
||
| await test.step('GIVEN user is logged in', async () => { | ||
| await login(page, email, password); | ||
| }); | ||
|
|
||
| await test.step('WHEN user logs out', async () => { | ||
| await logout(page); | ||
| }); | ||
|
|
||
| await test.step('THEN user is logged out', async () => { | ||
| await expect(page.getByRole('button', { name: 'Log in' })).toBeVisible(); | ||
| }); | ||
|
|
||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be a good idea to add a readme.md file with instructions on how to run the Playwright tests in
playwright/readme.md:)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added!