Tests: Auth, Create Session

This commit is contained in:
aodulov
2025-10-29 15:32:50 +02:00
parent fa4b936421
commit fc5a46fa94
7 changed files with 270 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import { test, expect } from '@playwright/test';
test.describe('Session Creation', () => {
test('Attempt to Create Session with Invalid Number of Participants (Less than 2)', async ({ page }) => {
// Ensure the user is logged in and on the session creation page.
await page.goto('https://unisono.aglink.duckdns.org/login');
await page.getByRole('textbox', { name: 'Passphrase' }).fill('HonorableHumansPrivilegeIsToBeAllowedHere');
await page.getByRole('button', { name: 'Enter' }).click();
await expect(page).toHaveURL(/.*\/session\/.*/);
// 2. Enter a valid topic (e.g., "Project Alpha Planning") into the "Topic" textbox.
await page.getByRole('textbox', { name: 'Topic' }).fill('Project Alpha Planning');
// 3. Enter optional details (e.g., "Discuss Q4 goals and allocate resources") into the "Details (Optional)" textbox.
await page.getByRole('textbox', { name: 'Details (Optional)' }).fill('Discuss Q4 goals and allocate resources');
// 4. Enter "1" into the "Number of Expected Responses" spinbutton.
await page.getByRole('spinbutton', { name: 'Number of Expected Responses' }).fill('1');
// 5. Click the "Start Session" button.
await page.getByRole('button', { name: 'Start Session' }).click();
// Expected Results:
// - An error message indicating that the number of participants must be at least 2 is displayed.
await expect(page.getByText('Must be an integer between 2 and 12')).toBeVisible();
// - The session is not created, and the user remains on the session creation page.
await expect(page).toHaveURL(/.*\/session\/.*/);
await expect(page.getByRole('heading', { name: 'Harmonize Desires' })).toBeVisible();
});
});

View File

@@ -0,0 +1,31 @@
import { test, expect } from '@playwright/test';
test.describe('Session Creation', () => {
test('Attempt to Create Session with Invalid Number of Participants (More than 12)', async ({ page }) => {
// Ensure the user is logged in and on the session creation page.
await page.goto('https://unisono.aglink.duckdns.org/login');
await page.getByRole('textbox', { name: 'Passphrase' }).fill('HonorableHumansPrivilegeIsToBeAllowedHere');
await page.getByRole('button', { name: 'Enter' }).click();
await expect(page).toHaveURL(/.*\/session\/.*/);
// 2. Enter a valid topic (e.g., "Project Alpha Planning") into the "Topic" textbox.
await page.getByRole('textbox', { name: 'Topic' }).fill('Project Alpha Planning');
// 3. Enter optional details (e.g., "Discuss Q4 goals and allocate resources") into the "Details (Optional)" textbox.
await page.getByRole('textbox', { name: 'Details (Optional)' }).fill('Discuss Q4 goals and allocate resources');
// 4. Enter "13" into the "Number of Expected Responses" spinbutton.
await page.getByRole('spinbutton', { name: 'Number of Expected Responses' }).fill('13');
// 5. Click the "Start Session" button.
await page.getByRole('button', { name: 'Start Session' }).click();
// Expected Results:
// - An error message indicating that the number of participants cannot exceed 12 is displayed.
await expect(page.getByText('Must be an integer between 2 and 12')).toBeVisible();
// - The session is not created, and the user remains on the session creation page.
await expect(page).toHaveURL(/.*\/session\/.*/);
await expect(page.getByRole('heading', { name: 'Harmonize Desires' })).toBeVisible();
});
});

View File

@@ -0,0 +1,31 @@
import { test, expect } from '@playwright/test';
test.describe('Session Creation', () => {
test('Attempt to Create Session with Missing Topic', async ({ page }) => {
// Ensure the user is logged in and on the session creation page.
await page.goto('https://unisono.aglink.duckdns.org/login');
await page.getByRole('textbox', { name: 'Passphrase' }).fill('HonorableHumansPrivilegeIsToBeAllowedHere');
await page.getByRole('button', { name: 'Enter' }).click();
await expect(page).toHaveURL(/.*\/session\/.*/);
// 2. Leave the "Topic" textbox empty.
// (This step is implicitly handled by not filling the topic field)
// 3. Enter optional details (e.g., "Discuss Q4 goals and allocate resources") into the "Details (Optional)" textbox.
await page.getByRole('textbox', { name: 'Details (Optional)' }).fill('Discuss Q4 goals and allocate resources');
// 4. Enter a valid number of participants (e.g., "3") into the "Number of Expected Responses" spinbutton.
await page.getByRole('spinbutton', { name: 'Number of Expected Responses' }).fill('3');
// 5. Click the "Start Session" button.
await page.getByRole('button', { name: 'Start Session' }).click();
// Expected Results:
// - An error message indicating that the "Topic" field is required is displayed.
await expect(page.getByText('Topic is required')).toBeVisible();
// - The session is not created, and the user remains on the session creation page.
await expect(page).toHaveURL(/.*\/session\/.*/);
await expect(page.getByRole('heading', { name: 'Harmonize Desires' })).toBeVisible();
});
});

View File

@@ -0,0 +1,36 @@
import { test, expect } from '@playwright/test';
test.describe('Session Creation', () => {
test('Create Session with Valid Data', async ({ page }) => {
// Ensure the user is logged in and on the session creation page.
await page.goto('https://unisono.aglink.duckdns.org/login');
await page.getByRole('textbox', { name: 'Passphrase' }).fill('HonorableHumansPrivilegeIsToBeAllowedHere');
await page.getByRole('button', { name: 'Enter' }).click();
await expect(page).toHaveURL(/.*\/session\/.*/);
// 2. Enter a valid topic (e.g., "Project Alpha Planning") into the "Topic" textbox.
await page.getByRole('textbox', { name: 'Topic' }).fill('Project Alpha Planning');
// 3. Enter optional details (e.g., "Discuss Q4 goals and allocate resources") into the "Details (Optional)" textbox.
await page.getByRole('textbox', { name: 'Details (Optional)' }).fill('Discuss Q4 goals and allocate resources');
// 4. Enter a valid number of participants (e.g., "3") into the "Number of Expected Responses" spinbutton.
await page.getByRole('spinbutton', { name: 'Number of Expected Responses' }).fill('3');
// 5. Click the "Start Session" button.
await page.getByRole('button', { name: 'Start Session' }).click();
// Expected Results:
// - A new session is created.
// - The user is redirected to the active session page.
await expect(page).toHaveURL(/.*\/session\/.*/);
// - The session details (Topic, Details, Number of Expected Responses) are displayed correctly.
await expect(page.getByRole('heading', { name: 'Project Alpha Planning' })).toBeVisible();
await expect(page.getByText('Details: Discuss Q4 goals and allocate resources')).toBeVisible();
await expect(page.getByText('Expected Responses: 3')).toBeVisible();
// - A "Copy Link" button is visible.
await expect(page.getByRole('button', { name: 'Copy Link' })).toBeVisible();
});
});

View File

@@ -0,0 +1,27 @@
import { test, expect } from '@playwright/test';
test.describe('Authentication', () => {
test('Successful Login with Valid Passphrase', async ({ page }) => {
// 1. Navigate to the application URL
await page.goto('https://unisono.aglink.duckdns.org');
// 2. On the login page, enter the valid AUTH_PASSPHRASE into the "Passphrase" textbox.
await page.getByRole('textbox', { name: 'Passphrase' }).fill('HonorableHumansPrivilegeIsToBeAllowedHere');
// 3. Click the "Enter" button.
await page.getByRole('button', { name: 'Enter' }).click();
// Expected Results:
// - The user is redirected to a new session creation page (e.g., /session/<session-id>).
await expect(page).toHaveURL(/.*\/session\/.*/);
// - The "Harmonize Desires" heading is visible.
await expect(page.getByRole('heading', { name: 'Harmonize Desires' })).toBeVisible();
// - The session creation form (Topic, Details, Number of Expected Responses, Start Session button) is displayed.
await expect(page.getByRole('textbox', { name: 'Topic' })).toBeVisible();
await expect(page.getByRole('textbox', { name: 'Details (Optional)' })).toBeVisible();
await expect(page.getByRole('spinbutton', { name: 'Number of Expected Responses' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Start Session' })).toBeVisible();
});
});

View File

@@ -0,0 +1,21 @@
import { test, expect } from '@playwright/test';
test.describe('Authentication', () => {
test('Unsuccessful Login with Invalid Passphrase', async ({ page }) => {
// 1. Navigate to the application URL
await page.goto('https://unisono.aglink.duckdns.org/login');
// 2. On the login page, enter an invalid passphrase (e.g., "incorrect-passphrase") into the "Passphrase" textbox.
await page.getByRole('textbox', { name: 'Passphrase' }).fill('incorrect-passphrase');
// 3. Click the "Enter" button.
await page.getByRole('button', { name: 'Enter' }).click();
// Expected Results:
// - An error message indicating invalid credentials is displayed.
await expect(page.locator('.MuiAlert-standardError', { hasText: 'Invalid passphrase' })).toBeVisible();
// - The user remains on the login page.
await expect(page).toHaveURL(/.*\/login/);
});
});