adjust test lines to await/expect appropriately

This commit is contained in:
2024-11-07 19:07:45 -07:00
parent a73f0239c9
commit a3b10d9a78
5 changed files with 15 additions and 13 deletions

View File

@@ -7,7 +7,7 @@ test('Check activity feed - check that server is running', async ({ page }) => {
await page.getByTestId('closeOnboardingAndFinish').click(); await page.getByTestId('closeOnboardingAndFinish').click();
// Check that initial 10 activities have been loaded // Check that initial 10 activities have been loaded
await page.locator('ul#listLatestActivity li:nth-child(10)'); await expect(page.locator('ul#listLatestActivity li:nth-child(10)')).toBeVisible();
// Scroll down a bit to trigger loading additional activities // Scroll down a bit to trigger loading additional activities
await page.locator('ul#listLatestActivity li:nth-child(50)').scrollIntoViewIfNeeded(); await page.locator('ul#listLatestActivity li:nth-child(50)').scrollIntoViewIfNeeded();
@@ -18,7 +18,7 @@ test('Check discover results', async ({ page }) => {
await page.goto('./discover'); await page.goto('./discover');
// Check that initial 10 projects have been loaded // Check that initial 10 projects have been loaded
await page.locator('ul#listDiscoverResults li.border-b:nth-child(10)'); await expect(page.locator('ul#listDiscoverResults li.border-b:nth-child(10)')).toBeVisible();
// Scroll down a bit to trigger loading additional projects // Scroll down a bit to trigger loading additional projects
await page.locator('ul#listDiscoverResults li.border-b:nth-child(20)').scrollIntoViewIfNeeded(); await page.locator('ul#listDiscoverResults li.border-b:nth-child(20)').scrollIntoViewIfNeeded();
@@ -43,7 +43,7 @@ test('Check ability to share contact', async ({ page }) => {
await page.goto('./discover'); await page.goto('./discover');
// Check that initial 10 projects have been loaded // Check that initial 10 projects have been loaded
await page.locator('ul#listDiscoverResults li.border-b:nth-child(10)'); await expect(page.locator('ul#listDiscoverResults li.border-b:nth-child(10)')).toBeVisible();
// Scroll down a bit to trigger loading additional projects // Scroll down a bit to trigger loading additional projects
await page.locator('ul#listDiscoverResults li.border-b:nth-child(20)').scrollIntoViewIfNeeded(); await page.locator('ul#listDiscoverResults li.border-b:nth-child(20)').scrollIntoViewIfNeeded();

View File

@@ -16,11 +16,11 @@ test('Check User 0 can invite someone', async ({ page }) => {
await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden(); await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden();
// check that the invite is in the list // check that the invite is in the list
const newInviteLine = await page.locator(`td:has-text("Neighbor ${neighborNum}")`); const newInviteLine = page.locator(`td:has-text("Neighbor ${neighborNum}")`);
await expect(newInviteLine).toBeVisible(); await expect(newInviteLine).toBeVisible();
// retrieve the link from the title // retrieve the link from the title
const inviteLink = await newInviteLine.getAttribute('data-testId'); const inviteLink = await newInviteLine.getAttribute('data-testId');
await expect(inviteLink).not.toBeNull(); expect(inviteLink).not.toBeNull();
// become the new user and accept the invite // become the new user and accept the invite
await switchToUser(page, newDid); await switchToUser(page, newDid);

View File

@@ -22,6 +22,7 @@ test('Record an offer', async ({ page }) => {
await page.getByTestId('offerButton').click(); await page.getByTestId('offerButton').click();
await page.getByTestId('inputDescription').fill(description); await page.getByTestId('inputDescription').fill(description);
await page.getByTestId('inputOfferAmount').fill(randomNonZeroNumber.toString()); await page.getByTestId('inputOfferAmount').fill(randomNonZeroNumber.toString());
expect(page.getByRole('button', { name: 'Sign & Send' }));
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();
@@ -36,8 +37,8 @@ test('Record an offer', async ({ page }) => {
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(description); await expect(serverPage.getByText(description)).toBeVisible();
await serverPage.getByText('did:none:HIDDEN'); await expect(serverPage.getByText('did:none:HIDDEN')).toBeVisible();
// Now update that offer // Now update that offer
@@ -61,12 +62,12 @@ test('Record an offer', async ({ page }) => {
await page.goto('./projects'); await page.goto('./projects');
await page.getByRole('link', { name: 'Offers', exact: true }).click(); await page.getByRole('link', { name: 'Offers', exact: true }).click();
await page.locator('li').filter({ hasText: description }).locator('a').first().click(); await page.locator('li').filter({ hasText: description }).locator('a').first().click();
const newItemDesc = await page.getByTestId('description'); const newItemDesc = page.getByTestId('description');
await expect(newItemDesc).toHaveText(updatedDescription); 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 = page.getByTestId('inputOfferAmount');
await expect(newAmount).toHaveValue((randomNonZeroNumber + 1).toString()); await expect(newAmount).toHaveValue((randomNonZeroNumber + 1).toString());
// go to the home page and check that the offer is shown as new // go to the home page and check that the offer is shown as new
@@ -102,8 +103,8 @@ test('Affirm delivery of an offer', async ({ page }) => {
// click on the 'Affirm Delivery' button // click on the 'Affirm Delivery' button
await page.getByRole('button', { name: 'Affirm Delivery' }).click(); await page.getByRole('button', { name: 'Affirm Delivery' }).click();
// fill our offer info and submit // fill our offer info and submit
await page.getByPlaceholder('What was given').fill("Whatever the offer says"); await page.getByPlaceholder('What was given').fill('Whatever the offer says');
await page.getByRole('spinbutton').fill("2"); await page.getByRole('spinbutton').fill('2');
await page.getByRole('button', { name: 'Sign & Send' }).click(); await page.getByRole('button', { name: 'Sign & Send' }).click();
await expect(page.getByText('That gift was recorded.')).toBeVisible(); await expect(page.getByText('That gift was recorded.')).toBeVisible();
}); });

View File

@@ -4,11 +4,12 @@ import { importUser, generateNewEthrUser, switchToUser } from './testUtils';
test('New offers for another user', async ({ page }) => { test('New offers for another user', async ({ page }) => {
const user01Did = await generateNewEthrUser(page); const user01Did = await generateNewEthrUser(page);
await page.goto('./'); await page.goto('./');
expect(page.getByTestId('newDirectOffersActivityNumber')).toBeHidden(); await expect(page.getByTestId('newDirectOffersActivityNumber')).toBeHidden();
await importUser(page, '00'); await importUser(page, '00');
await page.goto('./contacts'); await page.goto('./contacts');
await page.getByPlaceholder('URL or DID, Name, Public Key').fill(user01Did + ', A Friend'); await page.getByPlaceholder('URL or DID, Name, Public Key').fill(user01Did + ', A Friend');
await expect(page.locator('button > svg.fa-plus')).toBeVisible();
await page.locator('button > svg.fa-plus').click(); await page.locator('button > svg.fa-plus').click();
await expect(page.locator('div[role="alert"] span:has-text("Contact Added")')).toBeVisible(); await expect(page.locator('div[role="alert"] span:has-text("Contact Added")')).toBeVisible();
await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register await page.locator('div[role="alert"] button:has-text("No")').click(); // don't register

View File

@@ -85,11 +85,11 @@ export async function generateAndRegisterEthrUser(page: Page): Promise<string> {
const contactName = createContactName(newDid); const contactName = createContactName(newDid);
await page.getByPlaceholder('URL or DID, Name, Public Key').fill(`${newDid}, ${contactName}`); await page.getByPlaceholder('URL or DID, Name, Public Key').fill(`${newDid}, ${contactName}`);
await page.locator('button > svg.fa-plus').click(); await page.locator('button > svg.fa-plus').click();
await page.locator('li', { hasText: contactName }).click();
// register them // register them
await page.locator('div[role="alert"] button:has-text("Yes")').click(); await page.locator('div[role="alert"] button:has-text("Yes")').click();
// wait for it to disappear because the next steps may depend on alerts being gone // wait for it to disappear because the next steps may depend on alerts being gone
await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden(); await expect(page.locator('div[role="alert"] button:has-text("Yes")')).toBeHidden();
await expect(page.locator('li', { hasText: contactName })).toBeVisible();
return newDid; return newDid;
} }