Skip to content

Commit 88b1dc8

Browse files
committed
fix: create command tests
1 parent f981dd5 commit 88b1dc8

1 file changed

Lines changed: 29 additions & 18 deletions

File tree

tests/create-command.spec.ts

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ test.describe('Create Command', () => {
66
await goto('/vite', { waitUntil: 'domcontentloaded' })
77

88
// Create command section should be visible (SSR)
9-
const createCommand = page.locator('code', { hasText: /create vite/i })
10-
await expect(createCommand).toBeVisible()
9+
// Use specific container to avoid matching README code blocks
10+
const createCommandSection = page.locator('.group\\/createcmd')
11+
await expect(createCommandSection).toBeVisible()
12+
await expect(createCommandSection.locator('code')).toContainText(/create vite/i)
1113

12-
// Link to create-vite should be present
13-
await expect(page.locator('a[href="/create-vite"]')).toBeVisible()
14+
// Link to create-vite should be present (uses sr-only text, so check attachment not visibility)
15+
await expect(page.locator('a[href="/create-vite"]')).toBeAttached()
1416
})
1517

1618
test('/next - should show create command (shared maintainer, same repo)', async ({
@@ -20,11 +22,13 @@ test.describe('Create Command', () => {
2022
await goto('/next', { waitUntil: 'domcontentloaded' })
2123

2224
// Create command section should be visible (SSR)
23-
const createCommand = page.locator('code', { hasText: /create next-app/i })
24-
await expect(createCommand).toBeVisible()
25+
// Use specific container to avoid matching README code blocks
26+
const createCommandSection = page.locator('.group\\/createcmd')
27+
await expect(createCommandSection).toBeVisible()
28+
await expect(createCommandSection.locator('code')).toContainText(/create next-app/i)
2529

26-
// Link to create-next-app should be present
27-
await expect(page.locator('a[href="/create-next-app"]')).toBeVisible()
30+
// Link to create-next-app should be present (uses sr-only text, so check attachment not visibility)
31+
await expect(page.locator('a[href="/create-next-app"]')).toBeAttached()
2832
})
2933

3034
test('/nuxt - should show create command (same maintainer, same org)', async ({
@@ -34,8 +38,11 @@ test.describe('Create Command', () => {
3438
await goto('/nuxt', { waitUntil: 'domcontentloaded' })
3539

3640
// Create command section should be visible (SSR)
37-
const createCommand = page.locator('code', { hasText: /nuxi init/i })
38-
await expect(createCommand).toBeVisible()
41+
// nuxt has create-nuxt package, so command is "npm create nuxt"
42+
// Use specific container to avoid matching README code blocks
43+
const createCommandSection = page.locator('.group\\/createcmd')
44+
await expect(createCommandSection).toBeVisible()
45+
await expect(createCommandSection.locator('code')).toContainText(/create nuxt/i)
3946
})
4047

4148
test('/color - should NOT show create command (different maintainers)', async ({
@@ -47,9 +54,9 @@ test.describe('Create Command', () => {
4754
// Wait for package to load
4855
await expect(page.locator('h1').filter({ hasText: 'color' })).toBeVisible()
4956

50-
// Create command should NOT be visible
51-
const createCommand = page.locator('code', { hasText: /create color/i })
52-
await expect(createCommand).not.toBeVisible()
57+
// Create command section should NOT be visible (different maintainers)
58+
const createCommandSection = page.locator('.group\\/createcmd')
59+
await expect(createCommandSection).not.toBeVisible()
5360
})
5461

5562
test('/lodash - should NOT show create command (no create-lodash exists)', async ({
@@ -61,19 +68,23 @@ test.describe('Create Command', () => {
6168
// Wait for package to load
6269
await expect(page.locator('h1').filter({ hasText: 'lodash' })).toBeVisible()
6370

64-
// Create command should NOT be visible
65-
const createCommand = page.locator('code', { hasText: /create lodash/i })
66-
await expect(createCommand).not.toBeVisible()
71+
// Create command section should NOT be visible (no create-lodash exists)
72+
const createCommandSection = page.locator('.group\\/createcmd')
73+
await expect(createCommandSection).not.toBeVisible()
6774
})
6875
})
6976

7077
test.describe('Copy Functionality', () => {
7178
test('hovering create command shows copy button', async ({ page, goto }) => {
7279
await goto('/vite', { waitUntil: 'hydration' })
7380

74-
// Find the create command container
81+
// Wait for package analysis API to load (create command requires this)
82+
// First ensure the package page has loaded
83+
await expect(page.locator('h1')).toContainText('vite')
84+
85+
// Find the create command container (wait longer for API response)
7586
const createCommandContainer = page.locator('.group\\/createcmd')
76-
await expect(createCommandContainer).toBeVisible()
87+
await expect(createCommandContainer).toBeVisible({ timeout: 15000 })
7788

7889
// Copy button should initially be hidden (opacity-0)
7990
const copyButton = createCommandContainer.locator('button')

0 commit comments

Comments
 (0)