-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
018ee0c
commit 051e163
Showing
3 changed files
with
67 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// WalletPage.ts | ||
import { type Page, type Locator, expect } from '@playwright/test'; | ||
|
||
export class WalletPage { | ||
private readonly page: Page; | ||
private readonly walletHeading: Locator; | ||
private readonly credentialsHeading: Locator; | ||
private readonly credentialsDescription: Locator; | ||
private readonly emptyStateHeading: Locator; | ||
private readonly emptyStateDescription: Locator; | ||
private readonly getCredentialsButton: Locator; | ||
private readonly credentialCard: Locator; | ||
private readonly credentialLink: Locator; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.walletHeading = page.getByText('WALLET').first(); | ||
this.credentialsHeading = page.getByText('My credentials').first(); | ||
this.credentialsDescription = page.locator('d-text p'); | ||
this.emptyStateHeading = page.locator( | ||
'd-heading:has-text("There is no Credential in your wallet")' | ||
); | ||
this.emptyStateDescription = page.locator('d-text:has-text("Get your first credential")'); | ||
this.getCredentialsButton = page.locator('d-button:has-text("GET CREDENTIALS")'); | ||
this.credentialCard = page.locator('d-credential-card'); | ||
this.credentialLink = page.locator('button[class*="relative"]').first(); | ||
} | ||
|
||
async verifyWalletPage() { | ||
await expect(this.page).toHaveURL('/en/wallet'); | ||
await expect(this.walletHeading).toBeVisible(); | ||
} | ||
|
||
async verifyCredentialsHeadingAndDescription() { | ||
await expect(this.credentialsHeading).toBeVisible(); | ||
await expect(this.credentialsDescription).toContainText('Explore and manage your credentials'); | ||
} | ||
|
||
async verifyEmptyState() { | ||
await expect(this.emptyStateHeading).toBeVisible(); | ||
await expect(this.emptyStateDescription).toBeVisible(); | ||
await expect(this.getCredentialsButton).toBeVisible(); | ||
} | ||
|
||
async verifyCredentialsVisible() { | ||
await expect(this.credentialCard.first()).toBeVisible(); | ||
} | ||
|
||
async clickFirstCredential() { | ||
await this.credentialLink.click(); | ||
await expect(this.page).toHaveURL(/\/credential-detail$/); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,41 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { test } from '@playwright/test'; | ||
import { addCredentialsToLocalStorage, login, tabBarClick } from './utils'; | ||
import { WalletPage } from './fixtures/WalletPage'; | ||
|
||
test.describe('Wallet Page', () => { | ||
test('should load wallet page after login', async ({ page }) => { | ||
await login(page); | ||
await expect(page).toHaveURL('/en/wallet'); | ||
await expect(page.getByText('WALLET').first()).toBeVisible(); | ||
const walletPage = new WalletPage(page); | ||
await walletPage.verifyWalletPage(); | ||
}); | ||
|
||
test('should display heading and description', async ({ page }) => { | ||
await login(page); | ||
await expect(page.getByText('My credentials').first()).toBeVisible(); | ||
await expect(page.locator('d-text p')).toContainText('Explore and manage your credentials'); | ||
const walletPage = new WalletPage(page); | ||
await walletPage.verifyCredentialsHeadingAndDescription(); | ||
}); | ||
|
||
test('should show empty state when no credentials', async ({ page }) => { | ||
await login(page); | ||
await expect( | ||
page.locator('d-heading:has-text("There is no Credential in your wallet")') | ||
).toBeVisible(); | ||
await expect(page.locator('d-text:has-text("Get your first credential")')).toBeVisible(); | ||
await expect(page.locator('d-button:has-text("GET CREDENTIALS")')).toBeVisible(); | ||
const walletPage = new WalletPage(page); | ||
await walletPage.verifyEmptyState(); | ||
}); | ||
|
||
test('should list credentials if available', async ({ page }) => { | ||
await login(page); | ||
await addCredentialsToLocalStorage(page); | ||
await tabBarClick('Home', page); | ||
await tabBarClick('Wallet', page); | ||
const credentialLocator = page.locator('d-credential-card'); | ||
await expect(credentialLocator.first()).toBeVisible(); | ||
const walletPage = new WalletPage(page); | ||
await walletPage.verifyCredentialsVisible(); | ||
}); | ||
|
||
test('should navigate to credential detail on click', async ({ page }) => { | ||
await login(page); | ||
await addCredentialsToLocalStorage(page); | ||
await tabBarClick('Home', page); | ||
await tabBarClick('Wallet', page); | ||
const credentialLink = page.locator('button[class*="relative"]').first(); | ||
await credentialLink.click(); | ||
await expect(page).toHaveURL(/\/credential-detail$/); | ||
const walletPage = new WalletPage(page); | ||
await walletPage.clickFirstCredential(); | ||
}); | ||
}); |