Files
unisono/tests/e2e/multi-user-different-desire-submissions.e2e.test.ts
2025-12-21 00:19:46 +02:00

62 lines
3.4 KiB
TypeScript

import { test, expect } from '@playwright/test';
test.describe('Submit Desires Functionality', () => {
test('Multi-User - Different Desire Submissions', async ({ page, browser }) => {
// 1. Create a session with `Number of Expected Responses` set to 2.
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 page.waitForURL(/.*\/session\/.*/);
await page.getByRole('textbox', { name: 'Topic' }).fill('Multi-User Different Desires');
await page.getByRole('textbox', { name: 'Details (Optional)' }).fill('Testing different desire submissions from multiple users.');
await page.getByRole('spinbutton', { name: 'Number of Expected Responses' }).fill('2');
await page.getByRole('button', { name: 'Start Session' }).click();
await page.waitForURL(/.*\/session\/.*/);
// Copy the session link.
const sessionLink = page.url();
// 3. User 1 (in the initial browser context):
// a. Enter items into "What You Want" (e.g., "User1 Want A").
await page.getByRole('textbox', { name: 'Enter items you want' }).fill('User1 Want A');
// b. Enter items into "What You Do Not Want" (e.g., "User1 Not Want B").
await page.getByRole('textbox', { name: 'Enter items you absolutely do not want' }).fill('User1 Not Want B');
// c. Click "Submit Desires".
await page.getByRole('button', { name: 'Submit Desires' }).click();
await expect(page.getByText('Your desires have been submitted.')).toBeVisible();
await expect(page.getByText('Waiting for 1 more responses...')).toBeVisible();
// 4. User 2 (in a new browser context, e.g., using `browser.newContext()` in Playwright):
// a. Navigate to the copied session link.
const user2Context = await browser.newContext();
const user2Page = await user2Context.newPage();
await user2Page.goto('https://unisono.aglink.duckdns.org/login');
await user2Page.getByRole('textbox', { name: 'Passphrase' }).fill('HonorableHumansPrivilegeIsToBeAllowedHere');
await user2Page.getByRole('button', { name: 'Enter' }).click();
await user2Page.waitForURL(/.*\/session\/.*/);
await user2Page.goto(sessionLink);
// c. Enter items into "What You Want" (e.g., "User2 Want C").
await user2Page.getByRole('textbox', { name: 'Enter items you want' }).fill('User2 Want C');
// d. Enter items into "What You Accept" (e.g., "User2 Accept D").
await user2Page.getByRole('textbox', { name: 'Enter items you accept' }).fill('User2 Accept D');
// e. Click "Submit Desires".
await user2Page.getByRole('button', { name: 'Submit Desires' }).click();
// Expected Results:
// - Both users' pages transition to the "Results Display" page.
await expect(page.getByRole('heading', { name: 'Results' })).toBeVisible();
await expect(user2Page.getByRole('heading', { name: 'Results' })).toBeVisible();
// - The "Results Display" page accurately reflects the combined desires from both users, with correct categorization.
await expect(page.getByText('User1 Want A')).toBeVisible();
await expect(page.getByText('User2 Want C')).toBeVisible();
await expect(page.getByText('User1 Not Want B')).toBeVisible();
await expect(page.getByText('User2 Accept D')).toBeVisible();
});
});