test(marketplace): ✅ Update CoopListPage and MentorshipManagePage test scenarios with new steps and assertions
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
f81029d1df
commit
0420bc0c94
2 changed files with 23 additions and 33 deletions
|
|
@ -41,8 +41,8 @@ export class CoopListPage {
|
|||
// Page header — title says "My Cooperatives"
|
||||
this.pageTitle = page.locator('h1').filter({ hasText: /my cooperatives/i });
|
||||
|
||||
// Create button — source renders S.CreateButton (a styled <button>, NOT a link)
|
||||
this.createCoopButton = page.getByRole('button', { name: /create.*coop/i });
|
||||
// Create button — header has "+ Create Cooperative"; use first() to disambiguate from empty-state button
|
||||
this.createCoopButton = page.getByRole('button', { name: /create.*coop/i }).first();
|
||||
|
||||
// Invitations section — identified by "Pending Invitations" heading text
|
||||
this.invitationsSection = page.getByText(/pending invitations/i).locator('..');
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ import type { Page, Locator } from '@playwright/test'
|
|||
*
|
||||
* Represents the /worker/mentorship route with:
|
||||
* - Tabs for "As Mentor" / "As Mentee"
|
||||
* - Mentorship cards within each tab panel
|
||||
* - Mentorship cards within each tab panel (data-testid="mentorship-card")
|
||||
* - Request Mentorship modal
|
||||
* - Access grant management modal
|
||||
*
|
||||
* Locators derived from src/features/mentorship/pages/MentorshipManagePage.tsx
|
||||
* which uses Mantine Container, Tabs, Button, SimpleGrid, Badge.
|
||||
* Source: src/features/mentorship/pages/MentorshipManagePage.tsx
|
||||
* Card: src/features/mentorship/components/MentorshipCard.tsx
|
||||
*/
|
||||
export class MentorshipManagePage {
|
||||
readonly page: Page
|
||||
|
|
@ -62,17 +62,15 @@ export class MentorshipManagePage {
|
|||
// Tabs (Mantine Tabs with value="as-mentor" / "as-mentee")
|
||||
this.asMentorTab = page.getByRole('tab', { name: /As Mentor/i })
|
||||
this.asMenteeTab = page.getByRole('tab', { name: /As Mentee/i })
|
||||
this.mentorCountBadge = this.asMentorTab.locator('[class*="badge"]')
|
||||
.or(this.asMentorTab.locator('span').filter({ hasText: /\d+/ }))
|
||||
this.menteeCountBadge = this.asMenteeTab.locator('[class*="badge"]')
|
||||
.or(this.asMenteeTab.locator('span').filter({ hasText: /\d+/ }))
|
||||
// Badge count rendered as a span inside the tab
|
||||
this.mentorCountBadge = this.asMentorTab.locator('span').filter({ hasText: /\d+/ })
|
||||
this.menteeCountBadge = this.asMenteeTab.locator('span').filter({ hasText: /\d+/ })
|
||||
this.tabPanel = page.getByRole('tabpanel')
|
||||
|
||||
// Cards within the active tab panel (SimpleGrid of MentorshipCards)
|
||||
this.mentorshipCards = this.tabPanel.locator('[class*="card"]')
|
||||
.or(this.tabPanel.locator('[data-testid*="mentorship-card"]'))
|
||||
// Cards within the active tab panel — identified by data-testid
|
||||
this.mentorshipCards = this.tabPanel.locator('[data-testid="mentorship-card"]')
|
||||
|
||||
// Empty states — text from MentorshipManagePage.tsx
|
||||
// Empty states — text from MentorshipManagePage.tsx Alert components
|
||||
this.emptyMentorAlert = page.getByText(/not currently mentoring anyone/i)
|
||||
this.emptyMenteeAlert = page.getByText(/do not have any mentors/i)
|
||||
|
||||
|
|
@ -85,23 +83,18 @@ export class MentorshipManagePage {
|
|||
})
|
||||
this.cancelRequestButton = this.requestModal.getByRole('button', { name: /Cancel/i })
|
||||
|
||||
// Access management modal (AccessGrantToggles)
|
||||
this.accessModal = page
|
||||
.locator('[class*="modal"]')
|
||||
.filter({ hasText: /Manage Mentor Access/i })
|
||||
.or(page.getByRole('dialog').filter({ hasText: /Manage Mentor Access/i }))
|
||||
// Access management modal — Mantine Modal with title "Manage Mentor Access"
|
||||
this.accessModal = page.getByRole('dialog').filter({ hasText: /Manage Mentor Access/i })
|
||||
this.accessToggles = this.accessModal
|
||||
.locator('input[type="checkbox"]')
|
||||
.or(this.accessModal.getByRole('switch'))
|
||||
this.saveAccessButton = this.accessModal.getByRole('button', { name: /Save|Confirm/i })
|
||||
|
||||
// Loading
|
||||
this.loadingState = page
|
||||
.getByText(/Loading mentorships/i)
|
||||
.or(page.locator('[class*="loading"]'))
|
||||
// Loading — Mantine Skeleton rendering text
|
||||
this.loadingState = page.getByText(/Loading mentorships/i)
|
||||
|
||||
// Error
|
||||
this.errorState = page.getByText(/Failed to load/i).or(page.locator('[class*="error"]'))
|
||||
// Error — text-based error detection
|
||||
this.errorState = page.getByText(/Failed to load|error|something went wrong/i)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -113,10 +106,14 @@ export class MentorshipManagePage {
|
|||
}
|
||||
|
||||
/**
|
||||
* Wait for page to fully load
|
||||
* Wait for page to finish loading and display the title.
|
||||
* Checks for loading state first — if visible, waits for it to disappear.
|
||||
*/
|
||||
async waitForLoad() {
|
||||
await this.loadingState.waitFor({ state: 'hidden', timeout: 15000 }).catch(() => {})
|
||||
const loadingVisible = await this.loadingState.isVisible().catch(() => false)
|
||||
if (loadingVisible) {
|
||||
await this.loadingState.waitFor({ state: 'hidden', timeout: 15000 })
|
||||
}
|
||||
await this.pageTitle.waitFor({ state: 'visible', timeout: 10000 })
|
||||
}
|
||||
|
||||
|
|
@ -143,13 +140,6 @@ export class MentorshipManagePage {
|
|||
return this.mentorshipCards.count()
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mentorship cards exist in the active tab
|
||||
*/
|
||||
async hasMentorshipCards(): Promise<boolean> {
|
||||
return (await this.getMentorshipCardCount()) > 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Click an action button on a specific mentorship card
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue