From 1fe540d5a8915191216f60a851707e0aa7087e3f Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Mon, 12 Aug 2024 09:25:01 -0600 Subject: [PATCH] fix list of offers (and some other lists), and add tests for offers --- CHANGELOG.md | 7 ++++- playwright.config-local.ts | 4 +-- src/components/OfferDialog.vue | 2 ++ src/views/AccountViewView.vue | 17 +++++------- src/views/ClaimView.vue | 5 +++- src/views/ContactAmountsView.vue | 2 +- src/views/DiscoverView.vue | 2 ++ src/views/NewEditProjectView.vue | 2 +- src/views/ProjectViewView.vue | 1 + src/views/ProjectsView.vue | 8 +++--- src/views/SharedPhotoView.vue | 8 +++--- test-playwright/20-create-project.spec.ts | 2 -- test-playwright/30-record-gift.spec.ts | 2 +- test-playwright/40-add-contact.spec.ts | 2 +- test-playwright/50-record-offer.spec.ts | 33 +++++++++++++++++++++++ test-playwright/testUtils.js | 2 ++ 16 files changed, 71 insertions(+), 28 deletions(-) create mode 100644 test-playwright/50-record-offer.spec.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f72edf..1650cf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.3.16] - 2024.07.10 +## [0.3.18] - 2024.07.12 +### Fixed +- List of offers wasn't showing. + + +## [0.3.17] - 2024.07.11 - cefa384ff1a2d922848c370640c096c529920fab ### Added - Photos on more screens ### Fixed diff --git a/playwright.config-local.ts b/playwright.config-local.ts index e7647e3..ff9f647 100644 --- a/playwright.config-local.ts +++ b/playwright.config-local.ts @@ -72,9 +72,9 @@ export default defineConfig({ }, ], - /* Configure global timeout */ + /* Configure global timeout; default is 30000 milliseconds */ // the image upload will often not succeed at 5 seconds - //timeout: 7000, + //timeout: 10000, /* Run your local dev server before starting the tests */ /** diff --git a/src/components/OfferDialog.vue b/src/components/OfferDialog.vue index 1498c06..af48780 100644 --- a/src/components/OfferDialog.vue +++ b/src/components/OfferDialog.vue @@ -4,6 +4,7 @@

Offer Help

- {{ veriClaim.claim?.description }} + {{ + veriClaim.claim?.description || + veriClaim.claim?.itemOffered?.description + }}
diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index 98c955b..0b3a0a9 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -271,7 +271,7 @@ export default class ContactAmountssView extends Vue { // Make the xhr request payload const payload = JSON.stringify({ jwtEncoded: vcJwt }); const url = this.apiServer + "/api/v2/claim"; - const headers = getHeaders(this.activeDid) as AxiosRequestHeaders; + const headers = (await getHeaders(this.activeDid)) as AxiosRequestHeaders; try { const resp = await this.axios.post(url, payload, { headers }); diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index 4f73a83..61b0669 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -265,6 +265,8 @@ export default class DiscoverView extends Vue { // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (e: any) { console.error("Error with feed load:", e); + // this sometimes gives different information + console.error("Error with feed load (error added): " + e); this.$notify( { group: "alert", diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index 6d5f4d0..5c469f0 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -309,7 +309,7 @@ export default class NewEditProjectView extends Vue { return; } try { - const headers = getHeaders(this.activeDid) as AxiosRequestHeaders; + const headers = (await getHeaders(this.activeDid)) as AxiosRequestHeaders; const response = await this.axios.delete( DEFAULT_IMAGE_API_SERVER + "/image/" + diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index 242960a..0f4d185 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -162,6 +162,7 @@
diff --git a/test-playwright/20-create-project.spec.ts b/test-playwright/20-create-project.spec.ts index af22ff0..d7742bc 100644 --- a/test-playwright/20-create-project.spec.ts +++ b/test-playwright/20-create-project.spec.ts @@ -43,12 +43,10 @@ test('Create new project, then search for it', async ({ page }) => { // Search for newly-created project in /projects await page.goto('./projects'); await page.getByRole('link', { name: 'Projects', exact: true }).click(); - await page.waitForTimeout(3000); // Wait for a bit await expect(page.locator('ul#listProjects li.border-b:nth-child(1)')).toContainText(finalRandomString); // Assumes newest project always appears first in the Projects tab list // Search for newly-created project in /discover await page.goto('./discover'); - await page.waitForTimeout(3000); // 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); diff --git a/test-playwright/30-record-gift.spec.ts b/test-playwright/30-record-gift.spec.ts index 387be37..77dc3ff 100644 --- a/test-playwright/30-record-gift.spec.ts +++ b/test-playwright/30-record-gift.spec.ts @@ -27,7 +27,7 @@ test('Record something given', async ({ page }) => { await page.goto('./'); await page.getByRole('heading', { name: 'Unnamed/Unknown' }).click(); await page.getByPlaceholder('What was given').fill(finalTitle); - await page.getByRole('spinbutton', { id: 'inputGivenAmount' }).fill(randomNonZeroNumber.toString()); + await page.getByRole('spinbutton').fill(randomNonZeroNumber.toString()); await page.getByRole('button', { name: 'Sign & Send' }).click(); await expect(page.getByText('That gift was recorded.')).toBeVisible(); diff --git a/test-playwright/40-add-contact.spec.ts b/test-playwright/40-add-contact.spec.ts index f625474..4bb7656 100644 --- a/test-playwright/40-add-contact.spec.ts +++ b/test-playwright/40-add-contact.spec.ts @@ -51,7 +51,7 @@ test('Add contact, record gift, confirm gift', async ({ page }) => { // Record something given by new contact await page.getByRole('heading', { name: contactName }).click(); await page.getByPlaceholder('What was given').fill(finalTitle); - await page.getByRole('spinbutton').fill(randomNonZeroNumber.toString()); + await page.getByRole('spinbutton', { id: 'inputGivenAmount' }).fill(randomNonZeroNumber.toString()); await page.getByRole('button', { name: 'Sign & Send' }).click(); await expect(page.getByText('That gift was recorded.')).toBeVisible(); diff --git a/test-playwright/50-record-offer.spec.ts b/test-playwright/50-record-offer.spec.ts new file mode 100644 index 0000000..031c99f --- /dev/null +++ b/test-playwright/50-record-offer.spec.ts @@ -0,0 +1,33 @@ +import { test, expect } from '@playwright/test'; +import { importUser } from './testUtils'; + +test('Record an offer', async ({ page }) => { + // Generate a random string of 6 characters, skipping the "0." at the beginning + const randomString = Math.random().toString(36).substring(2, 8); + // Standard title prefix + const finalTitle = `Offer ${randomString}`; + const randomNonZeroNumber = Math.floor(Math.random() * 999) + 1; + + // Create new ID for default user + await importUser(page); + + // Select a project + await page.goto('./discover'); + await page.locator('ul#listDiscoverResults li:nth-child(1)').click(); + + // Record an offer + await page.getByTestId('offerButton').click(); + await page.getByTestId('inputDescription').fill(finalTitle); + await page.getByTestId('inputOfferAmount').fill(randomNonZeroNumber.toString()); + await page.getByRole('button', { name: 'Sign & Send' }).click(); + await expect(page.getByText('That offer was recorded.')).toBeVisible(); + + // Refresh home view and check gift + await page.goto('./projects'); + await page.locator('li').filter({ hasText: `All ${randomNonZeroNumber} remaining` }).locator('a').first().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/testUtils.js b/test-playwright/testUtils.js index 44706ed..3cd2e5c 100644 --- a/test-playwright/testUtils.js +++ b/test-playwright/testUtils.js @@ -21,6 +21,8 @@ export async function importUser(page, id) { await page.getByText('You have a seed').click(); await page.getByPlaceholder('Seed Phrase').fill(seedPhrase); await page.getByRole('button', { name: 'Import' }).click(); + await expect(page.locator('#sectionUsageLimits')).toContainText('You have done'); + await expect(page.locator('#sectionUsageLimits')).toContainText('You have uploaded'); // Set name await page.getByRole('link', { name: 'Set Your Name' }).click();