Skip to content

test(home): add events card verification test (HP-003) #199

Open
ptrcja wants to merge 1 commit intoWomen-Coding-Community:mainfrom
ptrcja:HP-003-Latest-Events-Section
Open

test(home): add events card verification test (HP-003) #199
ptrcja wants to merge 1 commit intoWomen-Coding-Community:mainfrom
ptrcja:HP-003-Latest-Events-Section

Conversation

@ptrcja
Copy link
Contributor

@ptrcja ptrcja commented Jan 10, 2026

Description

  • Add data-testid attributes to EventCard and EventContainer
  • Create EventCard component class in home.page.ts
  • Add events section methods to HomePage
  • Update LinkButton to forward data-testid prop

Type

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

Related Issue

#134

Screenshots

Screenshot 2026-01-10 at 19 09 10

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

@ptrcja ptrcja requested review from a team and womencodingcommunity as code owners January 10, 2026 18:18
@ptrcja ptrcja force-pushed the HP-003-Latest-Events-Section branch from 6512f51 to 2fd24d7 Compare January 12, 2026 12:46
@ptrcja ptrcja changed the title test(home): add HP-003 Events Card verification test test(home): add events card verification test (HP-003) Jan 15, 2026
@ptrcja ptrcja force-pushed the HP-003-Latest-Events-Section branch 2 times, most recently from 821ba5a to f689761 Compare January 25, 2026 15:59

import { BasePage } from '@pages/base.page';

export class EventCard extends BasePage {
Copy link
Contributor

Choose a reason for hiding this comment

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

EventCard deserves a file for itself ;)

readonly leetCodeLink: Locator;
readonly joinSlackButton: Locator;

readonly eventsSection: Locator;
Copy link
Contributor

@gpaOliveira gpaOliveira Feb 1, 2026

Choose a reason for hiding this comment

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

In order to not abuse this class, I'd prefer to see EventsSection as another page object, that the HomePage uses

All new methods go then to that new class and we make sure HomePage doesn't grow much.

The tests can then do:

// test file
await homePage.eventsSection.getEventCard(...)

Or:

// test file
const eventsSection = await homePage.getEventsSection();
await eventsSection.getEventCard(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good points! I'll extract both EventCard and EventsSection classes into their own file

await expect(eventTitle).not.toBeEmpty();

const eventSpeaker = this.card.getByTestId('event-card-speaker');
await expect(eventSpeaker).toHaveText(/^Speaker:\s{1,5}.{1,100}$/);
Copy link
Contributor

@gpaOliveira gpaOliveira Feb 1, 2026

Choose a reason for hiding this comment

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

Why we need such a regex? I mean, what is the tradeoff here (what we miss, what we gain) if we just check for .toHaveText(/^Speaker/) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the requirement format closely, but you're right that /^Speaker:/ is simpler and sufficient


const eventDate = this.card.getByTestId('event-card-date');
await expect(eventDate).toHaveText(
/[A-Za-z]{3}.{0,20}\d{4}.{0,10}\d{1,2}:\d{2}/,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not that good at regex to understand what this stands for - can you provide an example as a comment before this?


await test.step('Verify CTA button opens external link', async () => {
const eventCard = homePage.getEventCard(0);
const ctaButton = eventCard.card.getByTestId('event-card-cta');
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole logic deserves to be in eventCard as a method


await test.step('Verify "View all events" link navigates to events page', async () => {
await homePage.clickViewAllEventsLink();
await basePage.verifyURL('/events');
Copy link
Contributor

@gpaOliveira gpaOliveira Feb 1, 2026

Choose a reason for hiding this comment

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

Can't we also do homePage.verifyURL('/events'); ? Even better if the verify is part of the clickViewAllEventsLink method, no?

return (
<Grid
container
data-testid="event-card"
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome job putting the IDs there 👌

@vercel
Copy link

vercel bot commented Feb 10, 2026

@ptrcja is attempting to deploy a commit to the Women Coding Community's projects Team on Vercel.

A member of the Team first needs to authorize it.

@ptrcja ptrcja force-pushed the HP-003-Latest-Events-Section branch from 66b5b38 to ee007b1 Compare February 21, 2026 17:35
@sonarqubecloud
Copy link

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