From ee75576cda780759dfe928af294ce72f904676bc Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Mon, 5 Aug 2024 19:58:40 +0800 Subject: [PATCH] Playwright: implemented importUser --- test-playwright/10-check-usage-limits.spec.ts | 18 ++++++++++++++++ test-playwright/20-create-project.spec.ts | 21 +++++++++---------- test-playwright/30-record-gift.spec.ts | 12 ++--------- test-playwright/40-add-contact.spec.ts | 12 ++--------- 4 files changed, 32 insertions(+), 31 deletions(-) create mode 100644 test-playwright/10-check-usage-limits.spec.ts diff --git a/test-playwright/10-check-usage-limits.spec.ts b/test-playwright/10-check-usage-limits.spec.ts new file mode 100644 index 0000000..0a4a7e5 --- /dev/null +++ b/test-playwright/10-check-usage-limits.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from '@playwright/test'; +import { importUser } from './testUtils'; + +test('Check usage limits', async ({ page }) => { + // Check without ID first + await page.goto('./account'); + await expect(page.locator('div.bg-slate-100.rounded-md').filter({ hasText: 'Usage Limits' })).toBeHidden(); + + // Import user 01 + await importUser(page, '01'); + + // Verify that "Usage Limits" section is visible + await expect(page.locator('#sectionUsageLimits')).toBeVisible(); + await expect(page.getByText('Your claims counter resets')).toBeVisible(); + await expect(page.getByText('Your registration counter resets')).toBeVisible(); + await expect(page.getByText('Your image counter resets')).toBeVisible(); + await expect(page.getByRole('button', { name: 'Recheck Limits' })).toBeVisible(); +}); \ No newline at end of file diff --git a/test-playwright/20-create-project.spec.ts b/test-playwright/20-create-project.spec.ts index 091776b..e32ea66 100644 --- a/test-playwright/20-create-project.spec.ts +++ b/test-playwright/20-create-project.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test'; -test('Create new project', async ({ page }) => { +test('Create new project, then search for it', async ({ page }) => { // Generate a random string of 16 characters let randomString = Math.random().toString(36).substring(2, 18); @@ -18,16 +18,8 @@ test('Create new project', async ({ page }) => { const finalTitle = standardTitle + finalRandomString; const finalDescription = standardDescription + finalRandomString; - // Create new ID using seed phrase "rigid shrug mobile…" - await page.goto('./start'); - await page.getByText('You have a seed').click(); - await page.getByPlaceholder('Seed Phrase').fill('rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage'); - await page.getByRole('button', { name: 'Import' }).click(); - - // Set name - await page.getByRole('link', { name: 'Set Your Name' }).click(); - await page.getByPlaceholder('Name').fill('User Zero'); - await page.getByRole('button', { name: 'Save Changes' }).click(); + // Import user 00 + await importUser(page, '00'); // Pause for 5 seconds await page.waitForTimeout(5000); // I have to wait, otherwise the (+) button to add a new project doesn't appear @@ -46,4 +38,11 @@ test('Create new project', async ({ page }) => { // Check texts await expect(page.locator('h2')).toContainText(finalTitle); await expect(page.locator('#Content')).toContainText(finalDescription); + + // Search for project that was just created + await page.goto('./discover'); + await page.waitForTimeout(5000); // Wait for a bit + await page.getByPlaceholder('Search…').fill(finalRandomString); + await page.locator('#QuickSearch button').click(); + await expect(page.locator('ul#listDiscoverResults li.border-b:nth-child(1)')).toContainText(finalRandomString); }); \ No newline at end of file diff --git a/test-playwright/30-record-gift.spec.ts b/test-playwright/30-record-gift.spec.ts index 293d7a1..ba9cc68 100644 --- a/test-playwright/30-record-gift.spec.ts +++ b/test-playwright/30-record-gift.spec.ts @@ -19,16 +19,8 @@ test('Record something given', async ({ page }) => { // Combine title prefix with the random string const finalTitle = standardTitle + finalRandomString; - // Create new ID using seed phrase "rigid shrug mobile…" - await page.goto('./start'); - await page.getByText('You have a seed').click(); - await page.getByPlaceholder('Seed Phrase').fill('rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage'); - await page.getByRole('button', { name: 'Import' }).click(); - - // Set name - await page.getByRole('link', { name: 'Set Your Name' }).click(); - await page.getByPlaceholder('Name').fill('User Zero'); - await page.getByRole('button', { name: 'Save Changes' }).click(); + // Import user 00 + await importUser(page, '00'); // Record something given await page.goto('./'); diff --git a/test-playwright/40-add-contact.spec.ts b/test-playwright/40-add-contact.spec.ts index b5c4278..2989c62 100644 --- a/test-playwright/40-add-contact.spec.ts +++ b/test-playwright/40-add-contact.spec.ts @@ -1,16 +1,8 @@ import { test, expect } from '@playwright/test'; test('Add contact', async ({ page }) => { - // Create new ID using seed phrase "island fever beef…" - await page.goto('./start'); - await page.getByText('You have a seed').click(); - await page.getByPlaceholder('Seed Phrase').fill('island fever beef wine urban aim vacant quit afford total poem flame service calm better adult neither color gaze forum month sister imitate excite'); - await page.getByRole('button', { name: 'Import' }).click(); - - // Set name - await page.getByRole('link', { name: 'Set Your Name' }).click(); - await page.getByPlaceholder('Name').fill('User One'); - await page.getByRole('button', { name: 'Save Changes' }).click(); + // Import user 01 + await importUser(page, '01'); // Add new contact 00 await page.goto('./contacts');