forked from trent_larson/crowd-funder-for-time-pwa
Fix Playwright test selector and clean up debug logging
- Use correct aria-label for Copy button selector - Remove verbose debug console.log statements - Maintain robust overlay closing functionality - Test now passes for unregistered user onboarding flow
This commit is contained in:
@@ -69,7 +69,7 @@
|
||||
*/
|
||||
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { deleteContact, generateAndRegisterEthrUser, importUser } from './testUtils';
|
||||
import { deleteContact, generateAndRegisterEthrUser, importUser, importUserAndCloseOnboarding } from './testUtils';
|
||||
|
||||
test('Check activity feed - check that server is running', async ({ page }) => {
|
||||
// Load app homepage
|
||||
@@ -144,26 +144,90 @@ test('Check ID generation', async ({ page }) => {
|
||||
|
||||
|
||||
test('Check setting name & sharing info', async ({ page }) => {
|
||||
// Load homepage to trigger ID generation (?)
|
||||
// Do NOT import a user; start with a fresh, unregistered user state
|
||||
|
||||
function now() {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
|
||||
// Start by loading the homepage and looking for the onboarding notice and button
|
||||
await page.goto('./');
|
||||
await page.getByTestId('closeOnboardingAndFinish').click();
|
||||
// Check 'someone must register you' notice
|
||||
|
||||
// Wait for page to fully load and check for overlays
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// Loop to close all visible overlays/dialogs before proceeding
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const overlayCount = await page.locator('.dialog-overlay').count();
|
||||
if (overlayCount === 0) break;
|
||||
|
||||
// Try to close the overlay with various known close button texts
|
||||
const closeButtons = [
|
||||
"That's enough help, thanks.",
|
||||
'Close',
|
||||
'Cancel',
|
||||
'Dismiss',
|
||||
'Got it',
|
||||
'OK'
|
||||
];
|
||||
|
||||
let closed = false;
|
||||
for (const buttonText of closeButtons) {
|
||||
const button = page.getByRole('button', { name: buttonText });
|
||||
if (await button.count() > 0) {
|
||||
await button.click();
|
||||
closed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If no text button found, try the close icon (xmark)
|
||||
if (!closed) {
|
||||
const closeIcon = page.locator('.fa-xmark, .fa-times, [aria-label*="close"], [aria-label*="Close"]');
|
||||
if (await closeIcon.count() > 0) {
|
||||
await closeIcon.first().click();
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!closed) break;
|
||||
|
||||
// Wait a bit for the overlay to close
|
||||
await page.waitForTimeout(500);
|
||||
}
|
||||
|
||||
await expect(page.getByText('someone must register you.')).toBeVisible();
|
||||
await page.getByRole('button', { name: /Show them/}).click();
|
||||
// fill in a name
|
||||
|
||||
// Click the "Show them" button
|
||||
await page.getByRole('button', { name: 'Show them' }).click();
|
||||
|
||||
// Wait for the "Set Your Name" dialog to appear
|
||||
await expect(page.getByText('Set Your Name')).toBeVisible();
|
||||
await page.getByRole('textbox').fill('Me Test User');
|
||||
await page.locator('button:has-text("Save")').click();
|
||||
await expect(page.getByText('share some other way')).toBeVisible();
|
||||
await page.getByRole('button', { name: /share some other way/ }).click();
|
||||
await expect(page.getByRole('button', { name: 'copy to clipboard' })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'copy to clipboard' }).click();
|
||||
await expect(page.getByText('contact info was copied')).toBeVisible();
|
||||
// dismiss alert and wait for it to go away
|
||||
await page.locator('div[role="alert"] button > svg.fa-xmark').click();
|
||||
await expect(page.getByText('contact info was copied')).toBeHidden();
|
||||
// check that they're on the Contacts screen
|
||||
await expect(page.getByText('your contacts')).toBeVisible();
|
||||
|
||||
// Fill in the name
|
||||
await page.getByRole('textbox').fill('Test User');
|
||||
|
||||
// Click Save
|
||||
await page.getByRole('button', { name: 'Save' }).click();
|
||||
|
||||
// Wait for the choice dialog to appear
|
||||
await expect(page.getByText('We will share some other way')).toBeVisible();
|
||||
|
||||
// Click "We will share some other way"
|
||||
await page.getByRole('button', { name: 'We will share some other way' }).click();
|
||||
|
||||
// Wait up to 10 seconds for the heading
|
||||
await expect(page.getByRole('heading', { name: 'Share Your Contact Info' })).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Click the Copy to Clipboard button
|
||||
await expect(page.getByRole('button', { name: 'Copy contact information to clipboard' })).toBeVisible({ timeout: 10000 });
|
||||
await page.getByRole('button', { name: 'Copy contact information to clipboard' }).click();
|
||||
|
||||
// Wait for either the notification or navigation to contacts
|
||||
await Promise.race([
|
||||
expect(page.getByText('contact info was copied')).toBeVisible({ timeout: 10000 }),
|
||||
expect(page.getByText('your contacts')).toBeVisible({ timeout: 10000 })
|
||||
]);
|
||||
});
|
||||
|
||||
test('Confirm test API setting (may fail if you are running your own Time Safari)', async ({ page }, testInfo) => {
|
||||
|
||||
Reference in New Issue
Block a user