Skip to content

Conversation

@joanaBrit
Copy link
Contributor

Description

Add Playwright tests for the "Become a mentee Section" page

Type

  • Bug Fix
  • New Feature
  • Code Refactor
  • Documentation
  • Other

Related Issue

#143

Screenshots

image

Testing

Playwright test

Pull request checklist

Please check if your PR fulfills the following requirements:

  • I checked and followed the contributor guide
  • I have tested my changes locally.
  • [] I have added a screenshot from the website after I tested it locally

@sonarqubecloud
Copy link

level: 4,
name: /Become a Mentee/i,
});
await sectionTitle.scrollIntoViewIfNeeded();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to scroll to the section to validate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, why is it not necessary? Because we don’t have any interactions, apart from the button to go to a different page? Thank you! I’ll remove it. @nora-weisser

Comment on lines +44 to +46
await expect(findMentorButton).toBeVisible();
await expect(findMentorButton).toBeEnabled();
await findMentorButton.click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visibility and enabled checks (44, 45 lines) are redundant before a click.
Playwright automatically ensures that:

  • the locator resolves to exactly one element
  • the element is visible
  • the element is stable (not animating)
  • the element is enabled

See the docs:
https://playwright.dev/docs/actionability

}

// Validate "Find a mentor" button
const findMentorButton = page.getByRole('button', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you replace locator with the existing one on homePage: findMentorButton?

Comment on lines +36 to +38
for (const item of items) {
await expect(page.getByText(item)).toBeVisible();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since those items are list items in the DOM, I would locate list of items and validate against array you mentioned above.
https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-text

await page.goto('/mentorship');

// Scroll to "Become a Mentee" section
const sectionTitle = page.getByRole('heading', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please move this locator to mentorship.page.ts POM?

await expect(sectionTitle).toBeVisible();

// Validate description text
const description = page.getByRole('heading', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this to the mentorship page definition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants