Tests: 4. Submit Desires Functionality. Multiple User approcah needs to be fixed.

This commit is contained in:
aodulov
2025-10-29 17:31:16 +02:00
parent 482d36fc8a
commit 13e150d7d7
7 changed files with 440 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
import { test, expect } from '@playwright/test';
test.describe('Submit Desires Functionality', () => {
test.fixme('Multi-User - All Participants Submit Desires', 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 Desires Test');
await page.getByRole('textbox', { name: 'Details (Optional)' }).fill('Testing multi-user desire submission and result display via websockets.');
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.
await page.getByRole('button', { name: 'Copy Link' }).click();
await expect(page.getByText('Link copied to clipboard!')).toBeVisible();
const sessionLink = await page.evaluate(() => navigator.clipboard.readText());
// 3. User 1:
// a. Enter desires into all categories.
await page.getByRole('textbox', { name: 'Enter items you want' }).fill('User1 Want A
User1 Want B');
await page.getByRole('textbox', { name: 'Enter sensitive ideas privately' }).fill('User1 Secret Item');
await page.getByRole('textbox', { name: 'Enter items you accept' }).fill('User1 Accept Item');
await page.getByRole('textbox', { name: 'Enter items you absolutely do not want' }).fill('User1 Unwanted Item');
// b. 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/page):
// a. Navigate to the copied session link.
const user2Context = await browser.newContext();
const user2Page = await user2Context.newPage();
await user2Page.goto(sessionLink);
// b. Enter desires into all categories.
// User 2 needs to log in first
await user2Page.getByRole('textbox', { name: 'Passphrase' }).fill('HonorableHumansPrivilegeIsToBeAllowedHere');
await user2Page.getByRole('button', { name: 'Enter' }).click();
await user2Page.waitForURL(/.*\/session\/.*/);
await user2Page.getByRole('textbox', { name: 'Enter items you want' }).fill('User2 Want C
User2 Want D');
await user2Page.getByRole('textbox', { name: 'Enter sensitive ideas privately' }).fill('User2 Secret Item');
await user2Page.getByRole('textbox', { name: 'Enter items you accept' }).fill('User2 Accept Item');
await user2Page.getByRole('textbox', { name: 'Enter items you absolutely do not want' }).fill('User2 Unwanted Item');
// c. Click "Submit Desires".
await user2Page.getByRole('button', { name: 'Submit Desires' }).click();
await expect(user2Page.getByText('Your desires have been submitted.')).toBeVisible();
// Expected Results:
// - After User 1 submits, their page shows a "Waiting for other participants" message.
// (Verified above)
// - After User 2 submits, both User 1 and User 2's 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 shows a summary of all submitted desires, categorized and potentially aggregated.
await expect(page.getByText('User1 Want A')).toBeVisible();
await expect(page.getByText('User1 Want B')).toBeVisible();
await expect(page.getByText('User2 Want C')).toBeVisible();
await expect(page.getByText('User2 Want D')).toBeVisible();
await expect(page.getByText('User1 Accept Item')).toBeVisible();
await expect(page.getByText('User2 Accept Item')).toBeVisible();
await expect(page.getByText('User1 Unwanted Item')).toBeVisible();
await expect(page.getByText('User2 Unwanted Item')).toBeVisible();
// - Private desires are not visible to other users.
await expect(page.getByText('User2 Secret Item')).not.toBeVisible();
await expect(user2Page.getByText('User1 Secret Item')).not.toBeVisible();
});
});

View File

@@ -0,0 +1,65 @@
import { test, expect } from '@playwright/test';
test.describe('Submit Desires Functionality', () => {
test.fixme('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.
await page.getByRole('button', { name: 'Copy Link' }).click();
await expect(page.getByText('Link copied to clipboard!')).toBeVisible();
const sessionLink = await page.evaluate(() => navigator.clipboard.readText());
// 3. User 1:
// 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/page):
// a. Navigate to the copied session link.
const user2Context = await browser.newContext();
const user2Page = await user2Context.newPage();
await user2Page.goto(sessionLink);
// b. Enter desires into "What You Want" (e.g., "User2 Want C").
// User 2 needs to log in first
await user2Page.getByRole('textbox', { name: 'Passphrase' }).fill('HonorableHumansPrivilegeIsToBeAllowedHere');
await user2Page.getByRole('button', { name: 'Enter' }).click();
await user2Page.waitForURL(/.*\/session\/.*/);
await user2Page.getByRole('textbox', { name: 'Enter items you want' }).fill('User2 Want C');
// c. Enter items into "What You Accept" (e.g., "User2 Accept D").
await user2Page.getByRole('textbox', { name: 'Enter items you accept' }).fill('User2 Accept D');
// d. Click "Submit Desires".
await user2Page.getByRole('button', { name: 'Submit Desires' }).click();
await expect(user2Page.getByText('Your desires have been submitted.')).toBeVisible();
// 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();
});
});

View File

@@ -0,0 +1,44 @@
import { test, expect } from '@playwright/test';
test.describe('Submit Desires Functionality', () => {
test('Single User - Submit All Desire Categories', async ({ page }) => {
// Ensure a session is created and the user is on the active session 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 page.waitForURL(/.*\/session\/.*/);
await page.getByRole('textbox', { name: 'Topic' }).fill('Single User All Desires');
await page.getByRole('textbox', { name: 'Details (Optional)' }).fill('Testing submission of all desire categories by a single user.');
await page.getByRole('spinbutton', { name: 'Number of Expected Responses' }).fill('2');
await page.getByRole('button', { name: 'Start Session' }).click();
await page.waitForURL(/.*\/session\/.*/);
// 2. Enter items into "What You Want" textbox (e.g., "Item A\nItem B").
await page.getByRole('textbox', { name: 'Enter items you want' }).fill('Item A\nItem B');
// 3. Enter items into "Afraid to Ask (Private)" textbox (e.g., "Secret Item").
await page.getByRole('textbox', { name: 'Enter sensitive ideas privately' }).fill('Secret Item');
// 4. Enter items into "What You Accept" textbox (e.g., "Acceptable Item").
await page.getByRole('textbox', { name: 'Enter items you accept' }).fill('Acceptable Item');
// 5. Enter items into "What You Do Not Want" textbox (e.g., "Unwanted Item").
await page.getByRole('textbox', { name: 'Enter items you absolutely do not want' }).fill('Unwanted Item');
// 6. Click the "Submit Desires" button.
await page.getByRole('button', { name: 'Submit Desires' }).click();
// Expected Results:
// - A success message indicating desires have been submitted is displayed.
await expect(page.getByText('Your desires have been submitted.')).toBeVisible();
// - The input fields are cleared or disabled.
await expect(page.getByRole('textbox', { name: 'Enter items you want' })).not.toBeVisible();
await expect(page.getByRole('textbox', { name: 'Enter sensitive ideas privately' })).not.toBeVisible();
await expect(page.getByRole('textbox', { name: 'Enter items you accept' })).not.toBeVisible();
await expect(page.getByRole('textbox', { name: 'Enter items you absolutely do not want' })).not.toBeVisible();
// - The page transitions to a "Waiting for other participants" or similar state if `Expected Responses` > 1.
await expect(page.getByText('Waiting for 1 more responses...')).toBeVisible();
});
});

View File

@@ -0,0 +1,32 @@
import { test, expect } from '@playwright/test';
test.describe('Submit Desires Functionality', () => {
test('Single User - Submit Only "What You Want"', async ({ page }) => {
// Ensure a session is created and the user is on the active session 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 page.waitForURL(/.*\/session\/.*/);
await page.getByRole('textbox', { name: 'Topic' }).fill('Single User Only Want');
await page.getByRole('textbox', { name: 'Details (Optional)' }).fill('Testing submission of only \'What You Want\' by a single user.');
await page.getByRole('spinbutton', { name: 'Number of Expected Responses' }).fill('2');
await page.getByRole('button', { name: 'Start Session' }).click();
await page.waitForURL(/.*\/session\/.*/);
// 2. Enter items into "What You Want" textbox (e.g., "Only Want This").
await page.getByRole('textbox', { name: 'Enter items you want' }).fill('Only Want This');
// 3. Leave other desire fields empty.
// (Implicitly handled by not filling them)
// 4. Click the "Submit Desires" button.
await page.getByRole('button', { name: 'Submit Desires' }).click();
// Expected Results:
// - Desires are submitted successfully.
await expect(page.getByText('Your desires have been submitted.')).toBeVisible();
// - The page transitions to a "Waiting for other participants" or similar state.
await expect(page.getByText('Waiting for 1 more responses...')).toBeVisible();
});
});

View File

@@ -0,0 +1,58 @@
import { test, expect } from '@playwright/test';
test.describe('Results Display Functionality', () => {
test.fixme('Verify Private Desires are Not Shared', async ({ page, browser }) => {
// 1. Follow steps for "4.2 Multi-User - All Participants Submit Desires", ensuring User 1 submits a "Afraid to Ask (Private)" item.
// 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('Private Desires Test');
await page.getByRole('textbox', { name: 'Details (Optional)' }).fill('Verifying private desires are not shared between 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.
await page.getByRole('button', { name: 'Copy Link' }).click();
await expect(page.getByText('Link copied to clipboard!')).toBeVisible();
const sessionLink = await page.evaluate(() => navigator.clipboard.readText());
// User 1:
// a. Enter desires into "What You Want" and "Afraid to Ask (Private)".
await page.getByRole('textbox', { name: 'Enter items you want' }).fill('User1 Public Want');
await page.getByRole('textbox', { name: 'Enter sensitive ideas privately' }).fill('User1 Secret Desire');
// b. 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();
// User 2 (in a new browser context/page):
// a. Navigate to the copied session link.
const user2Context = await browser.newContext();
const user2Page = await user2Context.newPage();
await user2Page.goto(sessionLink);
// b. Enter desires into "What You Want".
// User 2 needs to log in first
await user2Page.getByRole('textbox', { name: 'Passphrase' }).fill('HonorableHumansPrivilegeIsToBeAllowedHere');
await user2Page.getByRole('button', { name: 'Enter' }).click();
await user2Page.waitForURL(/.*\/session\/.*/);
await user2Page.getByRole('textbox', { name: 'Enter items you want' }).fill('User2 Public Want');
// c. Click "Submit Desires".
await user2Page.getByRole('button', { name: 'Submit Desires' }).click();
await expect(user2Page.getByText('Your desires have been submitted.')).toBeVisible();
// Expected Results:
// - User 1's private desire is only visible to User 1 (if applicable, or not displayed at all on the results page).
await expect(page.getByText('User1 Secret Desire')).toBeVisible(); // User 1 can see their own private desire
await expect(user2Page.getByText('User1 Secret Desire')).not.toBeVisible(); // User 2 cannot see User 1's private desire
// - User 2's results page does not show User 1's private desire.
await expect(user2Page.getByText('User2 Public Want')).toBeVisible();
});
});

View File

@@ -0,0 +1,79 @@
import { test, expect } from '@playwright/test';
test.describe('Results Display Functionality', () => {
test.fixme('Verify Results Display After All Submissions', async ({ page, browser }) => {
// 1. Follow steps for "4.2 Multi-User - All Participants Submit Desires" to reach the results page.
// 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('Results Display Test');
await page.getByRole('textbox', { name: 'Details (Optional)' }).fill('Verifying the results display after all submissions.');
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.
await page.getByRole('button', { name: 'Copy Link' }).click();
await expect(page.getByText('Link copied to clipboard!')).toBeVisible();
const sessionLink = await page.evaluate(() => navigator.clipboard.readText());
// User 1:
// a. Enter desires into all categories.
await page.getByRole('textbox', { name: 'Enter items you want' }).fill('User1 Want A
User1 Want B');
await page.getByRole('textbox', { name: 'Enter sensitive ideas privately' }).fill('User1 Secret Item');
await page.getByRole('textbox', { name: 'Enter items you accept' }).fill('User1 Accept Item');
await page.getByRole('textbox', { name: 'Enter items you absolutely do not want' }).fill('User1 Unwanted Item');
// b. 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();
// User 2 (in a new browser context/page):
// a. Navigate to the copied session link.
const user2Context = await browser.newContext();
const user2Page = await user2Context.newPage();
await user2Page.goto(sessionLink);
// b. Enter desires into all categories.
// User 2 needs to log in first
await user2Page.getByRole('textbox', { name: 'Passphrase' }).fill('HonorableHumansPrivilegeIsToBeAllowedHere');
await user2Page.getByRole('button', { name: 'Enter' }).click();
await user2Page.waitForURL(/.*\/session\/.*/);
await user2Page.getByRole('textbox', { name: 'Enter items you want' }).fill('User2 Want C
User2 Want D');
await user2Page.getByRole('textbox', { name: 'Enter sensitive ideas privately' }).fill('User2 Secret Item');
await user2Page.getByRole('textbox', { name: 'Enter items you accept' }).fill('User2 Accept Item');
await user2Page.getByRole('textbox', { name: 'Enter items you absolutely do not want' }).fill('User2 Unwanted Item');
// c. Click "Submit Desires".
await user2Page.getByRole('button', { name: 'Submit Desires' }).click();
await expect(user2Page.getByText('Your desires have been submitted.')).toBeVisible();
// Expected Results:
// - The "Results Display" page is visible.
await expect(page.getByRole('heading', { name: 'Results' })).toBeVisible();
await expect(user2Page.getByRole('heading', { name: 'Results' })).toBeVisible();
// - All submitted desires (excluding private ones) are displayed in their respective categories (Want, Accept, Do Not Want).
await expect(page.getByText('User1 Want A')).toBeVisible();
await expect(page.getByText('User1 Want B')).toBeVisible();
await expect(page.getByText('User2 Want C')).toBeVisible();
await expect(page.getByText('User2 Want D')).toBeVisible();
await expect(page.getByText('User1 Accept Item')).toBeVisible();
await expect(page.getByText('User2 Accept Item')).toBeVisible();
await expect(page.getByText('User1 Unwanted Item')).toBeVisible();
await expect(page.getByText('User2 Unwanted Item')).toBeVisible();
// - The count of participants who submitted desires matches the `Number of Expected Responses`.
// This would require more complex assertions based on the actual display of participant count.
// - The session topic and details are still visible.
await expect(page.getByRole('heading', { name: 'Results Display Test' })).toBeVisible();
await expect(page.getByText('Details: Verifying the results display after all submissions.')).toBeVisible();
});
});