Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .env.playwright.example
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,4 @@ react-native-sdk/sounds
tests/.env
test-results

.env.playwright
Copy link

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 :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

8 changes: 6 additions & 2 deletions playwright.config.ts
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/',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe could create template for the playwright .env var as .env.playwright.example with

PLAYWRIGHT_BASE_URL=https://localhost:8080
PLAYWRIGHT_ULTIMATE_EMAIL=your-test-email@example.com
PLAYWRIGHT_ULTIMATE_PASSWORD=your-test-password

And use process.env.PLAYWRIGHT_BASE_URL for baseURL, in this way, each environment could inject the variables for the tests :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created!

ignoreHTTPSErrors: true,
trace: 'on-first-retry',
screenshot: 'only-on-failure',
Expand All @@ -14,4 +18,4 @@ export default defineConfig({
projects: [
{ name: 'chromium', use: { browserName: 'chromium' } },
],
});
});
60 changes: 60 additions & 0 deletions playwright/helpers/auth.ts
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 });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better use data-testid instead of classes

Choose a reason for hiding this comment

The 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? :)

Copy link

Choose a reason for hiding this comment

The 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();
}
75 changes: 75 additions & 0 deletions playwright/readme.md
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.
39 changes: 39 additions & 0 deletions playwright/tests/login-logout.spec.ts
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();
});

});
Loading