admin/e2e/shared/public-pages.spec.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

76 lines
3.2 KiB
TypeScript

import { expect, test } from '@playwright/test'
const contentPages = [
['/about', 'درباره قبیله'],
['/faq', 'سؤالات متداول'],
['/terms', 'شرایط استفاده'],
['/privacy', 'حریم خصوصی'],
['/refund-policy', 'بازگشت وجه'],
['/become-a-host', 'برگزارکننده شو'],
['/host-guide', 'میزبان'],
] as const
for (const [path, expectedText] of contentPages) {
test(`${path} renders its public content`, async ({ page }) => {
const response = await page.goto(path)
expect(response?.ok()).toBe(true)
await expect(page.getByRole('main')).toContainText(expectedText)
})
}
test('about uses a search title separate from the marketing heading', async ({ page }) => {
await page.goto('/about')
await expect(page).toHaveTitle(/درباره قبیله/)
await expect(page.getByRole('heading', { level: 1 })).toContainText('ما هنوز هم دور چیزهایی که دوست داریم جمع می‌شیم')
await expect(page.getByRole('heading', { level: 2, name: /هزاران ساله/ })).toBeVisible()
await expect(page.getByRole('heading', { level: 2, name: /همین کارو می‌کنیم/ })).toBeVisible()
})
test('faq exposes questions as headings and FAQ structured data', async ({ page }) => {
await page.goto('/faq')
await expect(page).toHaveTitle(/سؤالات متداول/)
await expect(page.getByRole('heading', { level: 2, name: 'چطور در یک رویداد ثبت‌نام کنم؟' })).toBeVisible()
const jsonLd = await page.locator('script[type="application/ld+json"]').allTextContents()
expect(jsonLd.some((block) => block.includes('"FAQPage"'))).toBe(true)
})
test('blog listing opens an article', async ({ page }) => {
await page.goto('/blog')
await expect(page.getByRole('heading', { name: /راهنمای تجربه‌های بهتر/ })).toBeVisible()
const firstArticleLink = page.locator('main article').first().getByRole('link')
const articleTitle = await firstArticleLink.locator('h2').innerText()
await expect(firstArticleLink).toBeVisible()
await firstArticleLink.click()
await expect(page).toHaveURL(/\/blog\/[^/]+$/, { timeout: 15_000 })
await expect(page.getByRole('heading', { level: 1 })).toContainText(articleTitle.trim())
})
test('contact form renders the public inbox fields', async ({ page }) => {
await page.goto('/contact')
await expect(page.getByLabel('نام و نام خانوادگی')).toBeVisible()
await expect(page.getByLabel('شماره تماس')).toBeVisible()
await expect(page.getByLabel('موضوع')).toBeVisible()
await expect(page.getByLabel('پیام شما')).toBeVisible()
await expect(page.getByRole('button', { name: 'ارسال پیام' })).toBeVisible()
})
test('unknown routes bounce guests to home with auth modal, not admin /auth', async ({ page }) => {
await page.route('**/api/v1/**', (route) =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ success: true, data: { items: [], meta: {} } }),
})
)
await page.goto('/not-a-real-content-page')
await expect(page).toHaveURL(/\/(\?|$)/)
await expect(page).not.toHaveURL(/\/auth/)
await expect(page.getByLabel('شماره موبایل')).toBeVisible()
})