Skip to content

Commit

Permalink
contact tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bwhenn committed Jun 8, 2024
1 parent 2431ab9 commit 2d3e7b9
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions __tests__/Contacts.E2E.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,11 @@ describe('Unit test: contact management', () => {
await page.click('.nav-links a:nth-child(1)');
});

afterAll(async () => {
await browser.close();
});

it('should create and delete a contact', async () => {
await page.type('input[name="name"]', 'Jane Doe');
await page.click('form input[type="submit"]');

// Verify the new contact is added
let contact = await page.evaluate(() => {
return document.evaluate("//h3[contains(text(), 'Jane Doe')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
});
expect(contact).not.toBeNull();

// Delete the contact
const deleteButton = await page.evaluateHandle(() => {
return document.evaluate("//button[@class='delete-btn']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
});

await deleteButton.asElement().click();

// Verify the contact is deleted
contact = await page.evaluate(() => {
return document.evaluate("//h3[contains(text(), 'Jane Doe')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
});
expect(contact).toBeNull();
});
});

0 comments on commit 2d3e7b9

Please sign in to comment.