|
| 1 | +import { test, expect } from '@playwright/test' |
| 2 | + |
| 3 | +test.describe('Skills Marketplace', () => { |
| 4 | + test.beforeEach(async ({ page }) => { |
| 5 | + await page.goto('/skills') |
| 6 | + }) |
| 7 | + |
| 8 | + test('should load the skills marketplace page', async ({ page }) => { |
| 9 | + await expect(page.getByTestId('skills-page')).toBeVisible() |
| 10 | + await expect(page.getByRole('heading', { name: 'Skills Marketplace' })).toBeVisible() |
| 11 | + await expect(page.getByTestId('skill-search-input')).toBeVisible() |
| 12 | + }) |
| 13 | + |
| 14 | + test('should filter skills by search query', async ({ page }) => { |
| 15 | + await page.getByTestId('skill-search-input').fill('react') |
| 16 | + |
| 17 | + const cards = page.locator('[data-testid^="skill-card-"]') |
| 18 | + const count = await cards.count() |
| 19 | + |
| 20 | + if (count > 0) { |
| 21 | + for (let i = 0; i < count; i++) { |
| 22 | + const text = await cards.nth(i).textContent() |
| 23 | + expect(text?.toLowerCase()).toContain('react') |
| 24 | + } |
| 25 | + } |
| 26 | + }) |
| 27 | + |
| 28 | + test('should open skill drawer when clicking a skill card', async ({ page }) => { |
| 29 | + const firstCard = page.locator('[data-testid^="skill-card-"]').first() |
| 30 | + await expect(firstCard).toBeVisible() |
| 31 | + |
| 32 | + const skillName = await firstCard.locator('h3').textContent() |
| 33 | + await firstCard.click() |
| 34 | + |
| 35 | + await expect(page.getByTestId('skill-drawer')).toBeVisible() |
| 36 | + await expect(page.getByRole('heading', { name: 'Edit Skill' })).toBeVisible() |
| 37 | + |
| 38 | + await expect(page.locator('#name')).toHaveValue(skillName || '') |
| 39 | + }) |
| 40 | + |
| 41 | + test('should switch between editor and preview tabs', async ({ page }) => { |
| 42 | + await page.getByTestId('create-custom-skill-button').click() |
| 43 | + await expect(page.getByTestId('skill-drawer')).toBeVisible() |
| 44 | + |
| 45 | + // Default should be editor |
| 46 | + await expect(page.getByTestId('skill-content-input')).toBeVisible() |
| 47 | + |
| 48 | + // Switch to preview |
| 49 | + await page.getByTestId('preview-tab-button').click() |
| 50 | + await expect(page.getByTestId('skill-preview-content')).toBeVisible() |
| 51 | + await expect(page.getByTestId('skill-content-input')).not.toBeVisible() |
| 52 | + |
| 53 | + // Switch back to editor |
| 54 | + await page.getByTestId('editor-tab-button').click() |
| 55 | + await expect(page.getByTestId('skill-content-input')).toBeVisible() |
| 56 | + await expect(page.getByTestId('skill-preview-content')).not.toBeVisible() |
| 57 | + }) |
| 58 | + |
| 59 | + test('should be able to close the drawer', async ({ page }) => { |
| 60 | + await page.getByTestId('create-custom-skill-button').click() |
| 61 | + await expect(page.getByTestId('skill-drawer')).toBeVisible() |
| 62 | + |
| 63 | + await page.getByTestId('close-drawer-button').click() |
| 64 | + await expect(page.getByTestId('skill-drawer')).not.toBeVisible() |
| 65 | + }) |
| 66 | + |
| 67 | + test('should allow creating a custom skill', async ({ page }) => { |
| 68 | + await page.getByTestId('create-custom-skill-button').click() |
| 69 | + await expect(page.getByTestId('skill-drawer')).toBeVisible() |
| 70 | + await expect(page.getByRole('heading', { name: 'Create New Skill' })).toBeVisible() |
| 71 | + |
| 72 | + await page.locator('#name').fill('New Test Skill') |
| 73 | + await page.locator('#description').fill('A description for the test skill') |
| 74 | + await page.getByTestId('skill-content-input').fill('## Test Content') |
| 75 | + |
| 76 | + // Switch to preview to verify |
| 77 | + await page.getByTestId('preview-tab-button').click() |
| 78 | + const previewContent = await page.getByTestId('skill-preview-content').textContent() |
| 79 | + expect(previewContent).toContain('New Test Skill') |
| 80 | + expect(previewContent).toContain('A description for the test skill') |
| 81 | + expect(previewContent).toContain('## Test Content') |
| 82 | + }) |
| 83 | +}) |
0 commit comments