Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@
"engines": {
"node": ">=20",
"pnpm": ">=9"
}
},
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0"
}
50 changes: 50 additions & 0 deletions playwright-tests/tests/becomeAMentee.page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { expect } from '@playwright/test';
import { test } from '@utils/fixtures';

test('Validate "Become a Mentee" section and Find a Mentor button', async ({
page,
}) => {
// Navigate to Mentorship page
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?

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


// Validate title
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?

level: 5,
name: /You should become a mentee if you:/i,
});
await expect(description).toBeVisible();

// List items
const items = [
'Want to start a career in software engineering',
'Want to find a better job',
'Want to be promoted at work',
'Want to apply for a leadership position',
'Need support in advancing your career',
];

for (const item of items) {
await expect(page.getByText(item)).toBeVisible();
}
Comment on lines +36 to +38
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


// 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?

name: 'Find a mentor',
});
await expect(findMentorButton).toBeVisible();
await expect(findMentorButton).toBeEnabled();
await findMentorButton.click();
Comment on lines +44 to +46
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


// Verify redirection
await expect(page).toHaveURL(/\/mentorship\/mentors/);
});