From 1973ca1977e75be125aa56986a7604ee35c6811f Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Wed, 24 Jul 2024 22:09:10 +0800 Subject: [PATCH] New test --- test-playwright/20-create-project.spec.ts | 3 --- .../21-create-project-search.spec.ts | 3 --- test-playwright/30-record-gift.spec.ts | 12 ++++++--- test-playwright/40-add-contact.spec.ts | 27 +++++++++++++++++++ 4 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 test-playwright/40-add-contact.spec.ts diff --git a/test-playwright/20-create-project.spec.ts b/test-playwright/20-create-project.spec.ts index 264f86899..74f3164c9 100644 --- a/test-playwright/20-create-project.spec.ts +++ b/test-playwright/20-create-project.spec.ts @@ -31,9 +31,6 @@ test('Create new project', async ({ page }) => { await page.getByPlaceholder('Name').fill('User Zero'); await page.getByRole('button', { name: 'Save Changes' }).click(); - // Check DID - await expect(page.getByRole('code')).toContainText('did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F'); - // Pause for 5 seconds await page.waitForTimeout(5000); // I have to wait, otherwise the (+) button to add a new project doesn't appear diff --git a/test-playwright/21-create-project-search.spec.ts b/test-playwright/21-create-project-search.spec.ts index 541f841df..b9be42442 100644 --- a/test-playwright/21-create-project-search.spec.ts +++ b/test-playwright/21-create-project-search.spec.ts @@ -31,9 +31,6 @@ test('Create new project, then search for it', async ({ page }) => { await page.getByPlaceholder('Name').fill('User Zero'); await page.getByRole('button', { name: 'Save Changes' }).click(); - // Check DID - await expect(page.getByRole('code')).toContainText('did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F'); - // Pause for 5 seconds await page.waitForTimeout(5000); // I have to wait, otherwise the (+) button to add a new project doesn't appear diff --git a/test-playwright/30-record-gift.spec.ts b/test-playwright/30-record-gift.spec.ts index 3c4ba3967..d49a564e7 100644 --- a/test-playwright/30-record-gift.spec.ts +++ b/test-playwright/30-record-gift.spec.ts @@ -32,9 +32,6 @@ test('Record something given', async ({ page }) => { await page.getByPlaceholder('Name').fill('User Zero'); await page.getByRole('button', { name: 'Save Changes' }).click(); - // Check DID - await expect(page.getByRole('code')).toContainText('did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F'); - // Record something given await page.goto('./'); await page.getByRole('heading', { name: 'Unnamed/Unknown' }).click(); @@ -43,4 +40,13 @@ test('Record something given', async ({ page }) => { await page.getByRole('spinbutton').fill(randomNonZeroNumber.toString()); await page.getByRole('button', { name: 'Sign & Send' }).click(); await expect(page.getByText('That gift was recorded.')).toBeVisible(); + + // Refresh home view and check gift + await page.goto('./'); + await page.locator('li').filter({ hasText: finalTitle }).locator('a').click(); + await expect(page.getByRole('heading', { name: 'Verifiable Claim Details' })).toBeVisible(); + await expect(page.getByText(finalTitle, { exact: true })).toBeVisible(); + const page1Promise = page.waitForEvent('popup'); + await page.getByRole('link', { name: 'View on the Public Server' }).click(); + const page1 = await page1Promise; }); \ No newline at end of file diff --git a/test-playwright/40-add-contact.spec.ts b/test-playwright/40-add-contact.spec.ts new file mode 100644 index 000000000..0fe9771d7 --- /dev/null +++ b/test-playwright/40-add-contact.spec.ts @@ -0,0 +1,27 @@ +import { test, expect } from '@playwright/test'; + +test('Create new ID from seed', async ({ page }) => { + // 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').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').click(); + await page.getByPlaceholder('Name').fill('User Zero'); + await page.getByRole('button', { name: 'Save Changes' }).click(); + + // Add new contact 01 + await page.goto('./contacts'); + await page.getByPlaceholder('URL or DID, Name, Public Key').fill('did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39'); + await page.locator('button > svg.fa-plus').click(); + await expect(page.locator('div[role="alert"]')).toBeVisible(); + + // Why doesn't the alert box come up every time? + // await page.locator('div[role="alert"] button:has-text("Yes")').click(); + + await expect(page.locator('li.border-b')).toContainText('did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39'); +}); \ No newline at end of file