Browse Source

add tests for gives to & from projects

split_build_process
Trent Larson 2 months ago
parent
commit
f7fd568c60
  1. 8
      CHANGELOG.md
  2. 2
      playwright.config-local.ts
  3. 3
      src/views/ClaimView.vue
  4. 6
      src/views/ProjectViewView.vue
  5. 1
      test-playwright/30-record-gift.spec.ts
  6. 1
      test-playwright/33-record-gift-x10.spec.ts
  7. 2
      test-playwright/35-record-gift-from-image-share.spec.ts
  8. 50
      test-playwright/37-record-gift-on-project.spec.ts
  9. 5
      test-playwright/40-add-contact.spec.ts
  10. 3
      test-playwright/50-record-offer.spec.ts
  11. 5
      test-playwright/testUtils.ts

8
CHANGELOG.md

@ -6,6 +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).
## [Unreleased]
### Added
- Record a give from a project on the project page.
- Make unavailable and explain why on confirmation buttons on the project page gives.
## [0.3.36] - 2024.11.24 - c8d23647d165016f8a8f575e13d32583242e53ac
### Changed
- More friendly default reminder message
@ -26,7 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.3.32] - 2024.11.06 - 9a3fa38a3fd28f977e06f0265fc39e635c9c5ccd
### Added
- Highlight new offers to user & to user's projects on the front page.
- Highlight in green new offers to user & to user's projects on the front page.
## [0.3.31] - 2024.10.25 - 07c02ab98a09d293dd90d9289a7872e7d681d296

2
playwright.config-local.ts

@ -74,7 +74,7 @@ export default defineConfig({
/* Configure global timeout; default is 30000 milliseconds */
// the image upload will often not succeed at 5 seconds
// timeout: 10000,
timeout: 25000, // various tests fail at various times with 20000
/* Run your local dev server before starting the tests */
/**

3
src/views/ClaimView.vue

@ -27,7 +27,8 @@
['GiveAction', 'Offer', 'PlanAction'].includes(
veriClaim.claimType as string,
) && veriClaim.issuer === activeDid
// a PlanAction agent also could edit one of those, but rather than add more Plan-specific logic to detect the agent
// a PlanAction agent also could edit one of those,
// but rather than add more Plan-specific logic to detect the agent
// we'll let them click the Project link and edit from there
"
@click="onClickEditClaim"

6
src/views/ProjectViewView.vue

@ -300,7 +300,7 @@
<!-- Now, gives TO this project in the middle -->
<!-- (similar to "FROM" gift display below) -->
<div class="bg-slate-100 px-4 py-3 rounded-md">
<div class="bg-slate-100 px-4 py-3 rounded-md" data-testId="gives-to">
<div v-if="activeDid && isRegistered">
<div class="text-center">
<button
@ -387,7 +387,7 @@
<!-- Finally, gives FROM this project on the right -->
<!-- (similar to "TO" gift display above) -->
<div class="bg-slate-100 px-4 py-3 rounded-md">
<div class="bg-slate-100 px-4 py-3 rounded-md" data-testId="gives-from">
<div v-if="activeDid && isRegistered">
<div class="text-center">
<button
@ -540,7 +540,7 @@ export default class ProjectViewView extends Vue {
offersToThis: Array<OfferSummaryRecord> = [];
offersHitLimit = false;
projectId = ""; // handle ID
recentlyCheckedAndUnconfirmableJwts = [];
recentlyCheckedAndUnconfirmableJwts: string[] = [];
showDidCopy = false;
startTime = "";
truncatedDesc = "";

1
test-playwright/30-record-gift.spec.ts

@ -25,6 +25,7 @@ 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();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
// Refresh home view and check gift
await page.goto('./');

1
test-playwright/33-record-gift-x10.spec.ts

@ -38,6 +38,7 @@ test('Record 9 new gifts', async ({ page }) => {
await page.getByRole('spinbutton').fill(finalNumbers[i].toString());
await page.getByRole('button', { name: 'Sign & Send' }).click();
await expect(page.getByText('That gift was recorded.')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
// Refresh home view and check gift
await page.goto('./');

2
test-playwright/35-record-gift-from-image-share.spec.ts

@ -28,7 +28,7 @@ test('Record item given from image-share', async ({ page }) => {
await page.getByRole('spinbutton').fill('2');
await page.getByRole('button', { name: 'Sign & Send' }).click();
await expect(page.getByText('That gift was recorded.')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
// Refresh home view and check gift
await page.goto('./');

50
test-playwright/37-record-gift-on-project.spec.ts

@ -0,0 +1,50 @@
import { test, expect, Page } from '@playwright/test';
import { importUser } from './testUtils';
async function testProjectGive(page: Page, selector: string) {
// Generate a random string of a few characters
const randomString = Math.random().toString(36).substring(2, 6);
// Generate a random non-zero single-digit number
const randomNonZeroNumber = Math.floor(Math.random() * 99) + 1;
// Standard title prefix
const standardTitle = 'Gift ';
// Combine title prefix with the random string
const finalTitle = standardTitle + randomString;
// find a project and enter a give to it and see that it shows
await importUser(page, '00');
await page.goto('./discover');
await page.getByTestId('closeOnboardingAndFinish').click();
await page.locator('ul#listDiscoverResults li:first-child a').click()
// wait for the project page to load
await page.waitForLoadState('networkidle');
// click the give button, inside the first div
await page.getByTestId(selector).locator('div:first-child div button').click();
await page.getByPlaceholder('What was given').fill(finalTitle);
await page.getByRole('spinbutton').fill(randomNonZeroNumber.toString());
await page.getByRole('button', { name: 'Sign & Send' }).click();
await expect(page.getByText('That gift was recorded.')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
// refresh the page
await page.reload();
// check that the give is in the list
await page
.getByTestId(selector)
.locator('div ul li:first-child')
.filter({ hasText: finalTitle })
.isVisible();
}
test('Record a give to a project', async ({ page }) => {
await testProjectGive(page, 'gives-to');
});
test('Record a give from a project', async ({ page }) => {
await testProjectGive(page, 'gives-from');
});

5
test-playwright/40-add-contact.spec.ts

@ -87,6 +87,7 @@ test('Add contact, record gift, confirm gift', async ({ page }) => {
await page.getByRole('button', { name: 'Confirm' }).click();
await page.getByRole('button', { name: 'Yes' }).click();
await expect(page.getByText('Confirmation submitted.')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
// Refresh claim page, Confirm button should throw an alert because they already confirmed
await page.reload();
@ -112,7 +113,7 @@ test('Without being registered, add contacts without registration', async ({ pag
});
test('Add contact, copy details, delete, and import various ways', async ({ page, context }) => {
test('Add contact, copy details, delete, and import from paste & from file', async ({ page, context }) => {
await importUser(page, '00');
// Add new contact
@ -179,7 +180,7 @@ test('Add contact, copy details, delete, and import various ways', async ({ page
// check that there are more contacts
await expect(page.getByTestId('contactListItem')).toHaveCount(2);
// Import via the file backup-import
// Import via the file backup-import, with both new and existing contacts
await page.goto('./account');
await page.getByRole('heading', { name: 'Advanced' }).click();
const fileSelect = await page.locator('input[type="file"]')

3
test-playwright/50-record-offer.spec.ts

@ -25,6 +25,7 @@ test('Record an offer', async ({ page }) => {
expect(page.getByRole('button', { name: 'Sign & Send' }));
await page.getByRole('button', { name: 'Sign & Send' }).click();
await expect(page.getByText('That offer was recorded.')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
// go to the offer and check the values
await page.goto('./projects');
@ -57,6 +58,7 @@ test('Record an offer', async ({ page }) => {
await amount.fill(String(randomNonZeroNumber + 1));
await page.getByRole('button', { name: 'Sign & Send' }).click();
await expect(page.getByText('That offer was recorded.')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
// go to the offer claim again and check the updated values
await page.goto('./projects');
@ -107,4 +109,5 @@ test('Affirm delivery of an offer', async ({ page }) => {
await page.getByRole('spinbutton').fill('2');
await page.getByRole('button', { name: 'Sign & Send' }).click();
await expect(page.getByText('That gift was recorded.')).toBeVisible();
await page.locator('div[role="alert"] button > svg.fa-xmark').click(); // dismiss info alert
});

5
test-playwright/testUtils.ts

@ -1,8 +1,9 @@
import { expect, Page } from '@playwright/test';
// Import the seed and switch to the user based on the ID.
// '01' -> 111
// otherwise -> 000
// '01' -> user 111
// otherwise -> user 000
// (... which is a weird convention but I haven't taken the time to change it)
export async function importUser(page: Page, id?: string): Promise<string> {
let seedPhrase, userName, did;

Loading…
Cancel
Save