|
@ -5,7 +5,8 @@ test('Record an offer', async ({ page }) => { |
|
|
// Generate a random string of 3 characters, skipping the "0." at the beginning
|
|
|
// Generate a random string of 3 characters, skipping the "0." at the beginning
|
|
|
const randomString = Math.random().toString(36).substring(2, 5); |
|
|
const randomString = Math.random().toString(36).substring(2, 5); |
|
|
// Standard title prefix
|
|
|
// Standard title prefix
|
|
|
const finalTitle = `Offering of ${randomString}`; |
|
|
const description = `Offering of ${randomString}`; |
|
|
|
|
|
const updatedDescription = `Updated ${description}`; |
|
|
const randomNonZeroNumber = Math.floor(Math.random() * 998) + 1; |
|
|
const randomNonZeroNumber = Math.floor(Math.random() * 998) + 1; |
|
|
|
|
|
|
|
|
// Create new ID for default user
|
|
|
// Create new ID for default user
|
|
@ -17,46 +18,46 @@ test('Record an offer', async ({ page }) => { |
|
|
|
|
|
|
|
|
// Record an offer
|
|
|
// Record an offer
|
|
|
await page.getByTestId('offerButton').click(); |
|
|
await page.getByTestId('offerButton').click(); |
|
|
await page.getByTestId('inputDescription').fill(finalTitle); |
|
|
await page.getByTestId('inputDescription').fill(description); |
|
|
await page.getByTestId('inputOfferAmount').fill(randomNonZeroNumber.toString()); |
|
|
await page.getByTestId('inputOfferAmount').fill(randomNonZeroNumber.toString()); |
|
|
await page.getByRole('button', { name: 'Sign & Send' }).click(); |
|
|
await page.getByRole('button', { name: 'Sign & Send' }).click(); |
|
|
await expect(page.getByText('That offer was recorded.')).toBeVisible(); |
|
|
await expect(page.getByText('That offer was recorded.')).toBeVisible(); |
|
|
|
|
|
|
|
|
// go to the offer and check the values
|
|
|
// go to the offer and check the values
|
|
|
await page.goto('./projects'); |
|
|
await page.goto('./projects'); |
|
|
await page.locator('li').filter({ hasText: finalTitle }).locator('a').first().click(); |
|
|
await page.locator('li').filter({ hasText: description }).locator('a').first().click(); |
|
|
await expect(page.getByRole('heading', { name: 'Verifiable Claim Details' })).toBeVisible(); |
|
|
await expect(page.getByRole('heading', { name: 'Verifiable Claim Details' })).toBeVisible(); |
|
|
await expect(page.getByText(finalTitle, { exact: true })).toBeVisible(); |
|
|
await expect(page.getByText(description, { exact: true })).toBeVisible(); |
|
|
const serverPagePromise = page.waitForEvent('popup'); |
|
|
const serverPagePromise = page.waitForEvent('popup'); |
|
|
await page.getByRole('link', { name: 'View on the Public Server' }).click(); |
|
|
await page.getByRole('link', { name: 'View on the Public Server' }).click(); |
|
|
const serverPage = await serverPagePromise; |
|
|
const serverPage = await serverPagePromise; |
|
|
await serverPage.getByText(finalTitle); |
|
|
await serverPage.getByText(description); |
|
|
await serverPage.getByText('did:none:HIDDEN'); |
|
|
await serverPage.getByText('did:none:HIDDEN'); |
|
|
|
|
|
|
|
|
// Now update that offer
|
|
|
// Now update that offer
|
|
|
|
|
|
|
|
|
// find the edit page and check the old values again
|
|
|
// find the edit page and check the old values again
|
|
|
await page.goto('./projects'); |
|
|
await page.goto('./projects'); |
|
|
await page.locator('li').filter({ hasText: finalTitle }).locator('a').first().click(); |
|
|
await page.locator('li').filter({ hasText: description }).locator('a').first().click(); |
|
|
await page.getByTestId('editClaimButton').click(); |
|
|
await page.getByTestId('editClaimButton').click(); |
|
|
await page.locator('heading', { hasText: 'What was offered' }).isVisible(); |
|
|
await page.locator('heading', { hasText: 'What is offered' }).isVisible(); |
|
|
const itemDesc = await page.getByTestId('itemDescription'); |
|
|
const itemDesc = await page.getByTestId('itemDescription'); |
|
|
await expect(itemDesc).toHaveValue(finalTitle); |
|
|
await expect(itemDesc).toHaveValue(description); |
|
|
const amount = await page.getByTestId('inputOfferAmount'); |
|
|
const amount = await page.getByTestId('inputOfferAmount'); |
|
|
await expect(amount).toHaveValue(randomNonZeroNumber.toString()); |
|
|
await expect(amount).toHaveValue(randomNonZeroNumber.toString()); |
|
|
// update the values
|
|
|
// update the values
|
|
|
await itemDesc.fill('Updated ' + finalTitle); |
|
|
await itemDesc.fill(updatedDescription); |
|
|
await amount.fill(String(randomNonZeroNumber + 1)); |
|
|
await amount.fill(String(randomNonZeroNumber + 1)); |
|
|
await page.getByRole('button', { name: 'Sign & Send' }).click(); |
|
|
await page.getByRole('button', { name: 'Sign & Send' }).click(); |
|
|
|
|
|
|
|
|
// go to the offer claim again and check the updated values
|
|
|
// go to the offer claim again and check the updated values
|
|
|
await page.goto('./projects'); |
|
|
await page.goto('./projects'); |
|
|
await page.locator('li').filter({ hasText: finalTitle }).locator('a').first().click(); |
|
|
await page.locator('li').filter({ hasText: description }).locator('a').first().click(); |
|
|
const newItemDesc = await page.getByTestId('description'); |
|
|
const newItemDesc = await page.getByTestId('description'); |
|
|
await expect(newItemDesc).toHaveText(finalTitle); |
|
|
await expect(newItemDesc).toHaveText(updatedDescription); |
|
|
|
|
|
|
|
|
// go to edit page
|
|
|
// go to edit page
|
|
|
await page.getByTestId('editClaimButton').click(); |
|
|
await page.getByTestId('editClaimButton').click(); |
|
|
const newAmount = await page.getByTestId('inputOfferAmount'); |
|
|
const newAmount = await page.getByTestId('inputOfferAmount'); |
|
|
await expect(newAmount).toHaveValue(randomNonZeroNumber.toString()); |
|
|
await expect(newAmount).toHaveValue((randomNonZeroNumber + 1).toString()); |
|
|
}); |
|
|
}); |
|
|