Skip to content

Commit 39c2eb5

Browse files
committed
test: update tests for new package-header
1 parent 2edb465 commit 39c2eb5

4 files changed

Lines changed: 8 additions & 66 deletions

File tree

app/components/Package/Header.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ const likeAction = async () => {
221221
ref="header"
222222
class="bg-bg sticky top-14 z-1 border-b border-border flex flex-col md:flex-row-reverse items-baseline justify-between gap-x-2 gap-y-1 flex-wrap min-w-0 pt-2"
223223
:class="[$style.packageHeader]"
224+
data-testid="package-subheader"
224225
>
225226
<div
226227
class="flex items-center max-md:justify-between max-md:w-full max-md:flex-row-reverse gap-2"

test/e2e/create-command.spec.ts

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -61,67 +61,6 @@ test.describe('Create Command', () => {
6161
})
6262
})
6363

64-
test.describe('Copy Functionality', () => {
65-
test('hovering create command shows copy button', async ({ page, goto }) => {
66-
await goto('/package/vite', { waitUntil: 'hydration' })
67-
68-
await expect(page.locator('h1')).toContainText('vite', { timeout: 15000 })
69-
70-
await expect(page.locator('main header').locator('text=/v\\d+\\.\\d+/')).toBeVisible({
71-
timeout: 15000,
72-
})
73-
74-
// Find the create command container (wait longer for API response)
75-
const createCommandContainer = page.locator('.group\\/createcmd').first()
76-
await expect(createCommandContainer).toBeVisible({ timeout: 20000 })
77-
78-
// Copy button should initially be hidden (opacity-0)
79-
const copyButton = createCommandContainer.locator('button')
80-
await expect(copyButton).toHaveCSS('opacity', '0')
81-
82-
// Hover over the container
83-
await createCommandContainer.hover()
84-
85-
// Copy button should become visible
86-
await expect(copyButton).toHaveCSS('opacity', '1')
87-
})
88-
89-
test('clicking copy button copies create command and shows confirmation', async ({
90-
page,
91-
goto,
92-
context,
93-
}) => {
94-
// Grant clipboard permissions
95-
await context.grantPermissions(['clipboard-read', 'clipboard-write'])
96-
97-
await goto('/package/vite', { waitUntil: 'hydration' })
98-
await expect(page.locator('h1')).toContainText('vite', { timeout: 15000 })
99-
100-
await expect(page.locator('main header').locator('text=/v\\d+\\.\\d+/')).toBeVisible({
101-
timeout: 15000,
102-
})
103-
104-
const createCommandContainer = page.locator('.group\\/createcmd').first()
105-
await expect(createCommandContainer).toBeVisible({ timeout: 20000 })
106-
107-
await createCommandContainer.hover()
108-
109-
// Click the copy button
110-
const copyButton = createCommandContainer.locator('button')
111-
await copyButton.click()
112-
113-
// Button text should change to "copied!"
114-
await expect(copyButton).toContainText(/copied/i)
115-
116-
// Verify clipboard content contains the create command
117-
const clipboardContent = await page.evaluate(() => navigator.clipboard.readText())
118-
expect(clipboardContent).toMatch(/create vite/i)
119-
120-
await expect(copyButton).toContainText(/copy/i, { timeout: 5000 })
121-
await expect(copyButton).not.toContainText(/copied/i)
122-
})
123-
})
124-
12564
test.describe('Install Command Copy', () => {
12665
test('hovering install command shows copy button', async ({ page, goto }) => {
12766
await goto('/package/is-odd', { waitUntil: 'hydration' })

test/e2e/package-manager-select.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ test.describe('Package Page', () => {
66

77
await expect(page.locator('h1')).toContainText('vue', { timeout: 15000 })
88

9-
const packageManagerButton = page.locator('button[aria-haspopup="listbox"]').first()
9+
const packageManagerButton = page.locator('article button[aria-haspopup="listbox"]').first()
1010
await expect(packageManagerButton).toBeVisible()
1111

1212
// Open dropdown
1313
await packageManagerButton.click()
14-
const packageManagerDropdown = page.locator('[role="listbox"]')
14+
const packageManagerDropdown = page.locator('article [role="listbox"]')
1515
await expect(packageManagerDropdown).toBeVisible({ timeout: 5000 })
1616

1717
// Arrow keys navigate the listbox

test/e2e/url-compatibility.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ test.describe('npmjs.com URL Compatibility', () => {
88
// Should show package name
99
await expect(page.locator('h1')).toContainText('vue')
1010
// Should have version badge
11-
await expect(page.locator('main header').locator('text=/v\\d+\\.\\d+/')).toBeVisible()
11+
await expect(
12+
page.locator('[data-testid="package-subheader"]').locator('text=/v\\d+\\.\\d+/'),
13+
).toBeVisible()
1214
})
1315

1416
test('/package/@nuxt/kit → scoped package page', async ({ page, goto }) => {
@@ -24,7 +26,7 @@ test.describe('npmjs.com URL Compatibility', () => {
2426
// Should show package name
2527
await expect(page.locator('h1')).toContainText('vue')
2628
// Should show the specific version
27-
await expect(page.locator('text=v3.5.27')).toBeVisible()
29+
await expect(page.locator('text=3.5.27')).toBeVisible()
2830
})
2931

3032
test('/package/@nuxt/kit/v/3.20.0 → scoped package specific version', async ({
@@ -36,7 +38,7 @@ test.describe('npmjs.com URL Compatibility', () => {
3638
// Should show scoped package name
3739
await expect(page.locator('h1')).toContainText('@nuxt/kit')
3840
// Should show the specific version (or "not latest" indicator)
39-
await expect(page.locator('text=v3.20.0').first()).toBeVisible()
41+
await expect(page.locator('text=3.20.0').first()).toBeVisible()
4042
})
4143

4244
test('/package/nonexistent-pkg-12345 → 404 handling', async ({ page, goto }) => {

0 commit comments

Comments
 (0)