Skip to content

Commit 07af3d2

Browse files
committed
test: update tests and rules
1 parent 1210053 commit 07af3d2

8 files changed

Lines changed: 68 additions & 68 deletions

app/middleware/trailing-slash.global.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineNuxtRouteMiddleware(to => {
1515
if (url.includes('_payload')) return
1616
}
1717

18-
if (to.path.startsWith('/package-code/')) return
18+
if (to.path.startsWith('/package-code/') || to.path.startsWith('/api/')) return
1919

2020
if (to.path !== '' && !to.path.endsWith('/')) {
2121
return navigateTo(

test/e2e/connector.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test.describe.configure({ mode: 'serial' })
1818
* This helper waits for the packages link to appear as proof of successful connection.
1919
*/
2020
async function expectConnected(page: Page, username = 'testuser') {
21-
await expect(page.locator(`a[href="/~${username}"]`, { hasText: 'packages' })).toBeVisible({
21+
await expect(page.locator(`a[href="/~${username}/"]`, { hasText: 'packages' })).toBeVisible({
2222
timeout: 10_000,
2323
})
2424
}
@@ -79,7 +79,7 @@ test.describe('Connector Connection', () => {
7979
await modal.getByRole('button', { name: /close/i }).click()
8080

8181
// The "packages" link should disappear since we're disconnected
82-
await expect(page.locator('a[href="/~testuser"]', { hasText: 'packages' })).not.toBeVisible({
82+
await expect(page.locator('a[href="/~testuser/"]', { hasText: 'packages' })).not.toBeVisible({
8383
timeout: 5000,
8484
})
8585

@@ -106,7 +106,7 @@ test.describe('Organization Management', () => {
106106
})
107107

108108
test('shows org members when connected', async ({ page, gotoConnected }) => {
109-
await gotoConnected('/@testorg')
109+
await gotoConnected('/@testorg/')
110110

111111
// The org management region contains the members panel
112112
const orgManagement = page.getByRole('region', { name: /organization management/i })
@@ -123,7 +123,7 @@ test.describe('Organization Management', () => {
123123
})
124124

125125
test('can filter members by role', async ({ page, gotoConnected }) => {
126-
await gotoConnected('/@testorg')
126+
await gotoConnected('/@testorg/')
127127

128128
const orgManagement = page.getByRole('region', { name: /organization management/i })
129129
await expect(orgManagement).toBeVisible({ timeout: 10_000 })
@@ -144,7 +144,7 @@ test.describe('Organization Management', () => {
144144
})
145145

146146
test('can search members by name', async ({ page, gotoConnected }) => {
147-
await gotoConnected('/@testorg')
147+
await gotoConnected('/@testorg/')
148148

149149
const orgManagement = page.getByRole('region', { name: /organization management/i })
150150
await expect(orgManagement).toBeVisible({ timeout: 10_000 })
@@ -162,7 +162,7 @@ test.describe('Organization Management', () => {
162162
})
163163

164164
test('can add a new member operation', async ({ page, gotoConnected, mockConnector }) => {
165-
await gotoConnected('/@testorg')
165+
await gotoConnected('/@testorg/')
166166

167167
const orgManagement = page.getByRole('region', { name: /organization management/i })
168168
await expect(orgManagement).toBeVisible({ timeout: 10_000 })
@@ -194,7 +194,7 @@ test.describe('Organization Management', () => {
194194
})
195195

196196
test('can remove a member (adds operation)', async ({ page, gotoConnected, mockConnector }) => {
197-
await gotoConnected('/@testorg')
197+
await gotoConnected('/@testorg/')
198198

199199
const orgManagement = page.getByRole('region', { name: /organization management/i })
200200
await expect(orgManagement).toBeVisible({ timeout: 10_000 })
@@ -215,7 +215,7 @@ test.describe('Organization Management', () => {
215215
gotoConnected,
216216
mockConnector,
217217
}) => {
218-
await gotoConnected('/@testorg')
218+
await gotoConnected('/@testorg/')
219219

220220
const orgManagement = page.getByRole('region', { name: /organization management/i })
221221
await expect(orgManagement).toBeVisible({ timeout: 10_000 })
@@ -257,7 +257,7 @@ test.describe('Package Access Controls', () => {
257257
async function goToPackageConnected(page: Page, gotoConnected: (path: string) => Promise<void>) {
258258
await gotoConnected('/')
259259
await expectConnected(page)
260-
await page.goto('/package/@nuxt/kit')
260+
await page.goto('/package/@nuxt/kit/')
261261
await expect(page.locator('h1')).toContainText('kit', { timeout: 30_000 })
262262
}
263263

test/e2e/create-command.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from './test-utils'
33
test.describe('Create Command', () => {
44
test.describe('Visibility', () => {
55
test('/vite - should show create command (same maintainers)', async ({ page, goto }) => {
6-
await goto('/package/vite', { waitUntil: 'domcontentloaded' })
6+
await goto('/package/vite/', { waitUntil: 'domcontentloaded' })
77

88
// Create command section should be visible (SSR)
99
// Use specific container to avoid matching README code blocks
@@ -19,7 +19,7 @@ test.describe('Create Command', () => {
1919
page,
2020
goto,
2121
}) => {
22-
await goto('/package/next', { waitUntil: 'domcontentloaded' })
22+
await goto('/package/next/', { waitUntil: 'domcontentloaded' })
2323

2424
// Create command section should be visible (SSR)
2525
// Use specific container to avoid matching README code blocks
@@ -35,7 +35,7 @@ test.describe('Create Command', () => {
3535
page,
3636
goto,
3737
}) => {
38-
await goto('/package/nuxt', { waitUntil: 'domcontentloaded' })
38+
await goto('/package/nuxt/', { waitUntil: 'domcontentloaded' })
3939

4040
// Create command section should be visible (SSR)
4141
// nuxt has create-nuxt package, so command is "npm create nuxt"
@@ -49,7 +49,7 @@ test.describe('Create Command', () => {
4949
page,
5050
goto,
5151
}) => {
52-
await goto('/package/is-odd', { waitUntil: 'domcontentloaded' })
52+
await goto('/package/is-odd/', { waitUntil: 'domcontentloaded' })
5353

5454
// Wait for package to load
5555
await expect(page.locator('h1').filter({ hasText: 'is-odd' })).toBeVisible()
@@ -63,7 +63,7 @@ test.describe('Create Command', () => {
6363

6464
test.describe('Copy Functionality', () => {
6565
test('hovering create command shows copy button', async ({ page, goto }) => {
66-
await goto('/package/vite', { waitUntil: 'hydration' })
66+
await goto('/package/vite/', { waitUntil: 'hydration' })
6767

6868
await expect(page.locator('h1')).toContainText('vite', { timeout: 15000 })
6969

@@ -94,7 +94,7 @@ test.describe('Create Command', () => {
9494
// Grant clipboard permissions
9595
await context.grantPermissions(['clipboard-read', 'clipboard-write'])
9696

97-
await goto('/package/vite', { waitUntil: 'hydration' })
97+
await goto('/package/vite/', { waitUntil: 'hydration' })
9898
await expect(page.locator('h1')).toContainText('vite', { timeout: 15000 })
9999

100100
await expect(page.locator('main header').locator('text=/v\\d+\\.\\d+/')).toBeVisible({
@@ -124,7 +124,7 @@ test.describe('Create Command', () => {
124124

125125
test.describe('Install Command Copy', () => {
126126
test('hovering install command shows copy button', async ({ page, goto }) => {
127-
await goto('/package/is-odd', { waitUntil: 'hydration' })
127+
await goto('/package/is-odd/', { waitUntil: 'hydration' })
128128

129129
// Find the install command container
130130
const installCommandContainer = page.locator('.group\\/installcmd').first()
@@ -149,7 +149,7 @@ test.describe('Create Command', () => {
149149
// Grant clipboard permissions
150150
await context.grantPermissions(['clipboard-read', 'clipboard-write'])
151151

152-
await goto('/package/is-odd', { waitUntil: 'hydration' })
152+
await goto('/package/is-odd/', { waitUntil: 'hydration' })
153153

154154
// Find and hover over the install command container
155155
const installCommandContainer = page.locator('.group\\/installcmd').first()

test/e2e/docs.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from './test-utils'
33
test.describe('API Documentation Pages', () => {
44
test('docs page loads and shows content for a package', async ({ page, goto }) => {
55
// Use a small, stable package with TypeScript types
6-
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
6+
await goto('/package-docs/ufo/v/1.6.3/', { waitUntil: 'networkidle' })
77

88
// Page title should include package name
99
await expect(page).toHaveTitle(/ufo.*docs/i)
@@ -24,7 +24,7 @@ test.describe('API Documentation Pages', () => {
2424
})
2525

2626
test('docs page shows TOC sidebar on desktop', async ({ page, goto }) => {
27-
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
27+
await goto('/package-docs/ufo/v/1.6.3/', { waitUntil: 'networkidle' })
2828

2929
// TOC sidebar should be visible (on desktop viewport)
3030
const tocSidebar = page.locator('aside')
@@ -38,7 +38,7 @@ test.describe('API Documentation Pages', () => {
3838
})
3939

4040
test('TOC links navigate to sections', async ({ page, goto }) => {
41-
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
41+
await goto('/package-docs/ufo/v/1.6.3/', { waitUntil: 'networkidle' })
4242

4343
// Click on Functions in TOC
4444
const functionsLink = page.locator('aside a[href="#section-function"]')
@@ -53,7 +53,7 @@ test.describe('API Documentation Pages', () => {
5353
})
5454

5555
test('clicking symbol name scrolls to symbol', async ({ page, goto }) => {
56-
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
56+
await goto('/package-docs/ufo/v/1.6.3/', { waitUntil: 'networkidle' })
5757

5858
// Find a symbol link in the TOC
5959
const symbolLink = page.locator('aside a[href^="#function-"]').first()
@@ -67,14 +67,14 @@ test.describe('API Documentation Pages', () => {
6767
})
6868

6969
test('docs page without version redirects to latest', async ({ page, goto }) => {
70-
await goto('/package-docs/ufo', { waitUntil: 'networkidle' })
70+
await goto('/package-docs/ufo/', { waitUntil: 'networkidle' })
7171

7272
// Should redirect to include version
7373
await expect(page).toHaveURL(/\/package-docs\/ufo\/v\//)
7474
})
7575

7676
test('package link in header navigates to package page', async ({ page, goto }) => {
77-
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'networkidle' })
77+
await goto('/package-docs/ufo/v/1.6.3/', { waitUntil: 'networkidle' })
7878

7979
// Click on package name in header
8080
const packageLink = page.locator('header a').filter({ hasText: 'ufo' })
@@ -87,7 +87,7 @@ test.describe('API Documentation Pages', () => {
8787
test('docs page handles package gracefully when types unavailable', async ({ page, goto }) => {
8888
// Use a simple JS package - the page should load without crashing
8989
// regardless of whether it has types or shows an error state
90-
await goto('/package-docs/is-odd/v/3.0.1', { waitUntil: 'networkidle' })
90+
await goto('/package-docs/is-odd/v/3.0.1/', { waitUntil: 'networkidle' })
9191

9292
// Header should always show the package name
9393
await expect(page.locator('header').getByText('is-odd')).toBeVisible()
@@ -105,7 +105,7 @@ test.describe('API Documentation Pages', () => {
105105

106106
test.describe('Version Selector', () => {
107107
test('version selector dropdown shows versions', async ({ page, goto }) => {
108-
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'hydration' })
108+
await goto('/package-docs/ufo/v/1.6.3/', { waitUntil: 'hydration' })
109109

110110
// Find and click the version selector button (wait for it to be visible)
111111
const versionButton = page.locator('header button').filter({ hasText: '1.6.3' })
@@ -123,7 +123,7 @@ test.describe('Version Selector', () => {
123123
})
124124

125125
test('selecting a version navigates to that version', async ({ page, goto }) => {
126-
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'hydration' })
126+
await goto('/package-docs/ufo/v/1.6.3/', { waitUntil: 'hydration' })
127127

128128
// Find and click the version selector button (wait for it to be visible)
129129
const versionButton = page.locator('header button').filter({ hasText: '1.6.3' })
@@ -157,7 +157,7 @@ test.describe('Version Selector', () => {
157157
})
158158

159159
test('escape key closes version dropdown', async ({ page, goto }) => {
160-
await goto('/package-docs/ufo/v/1.6.3', { waitUntil: 'hydration' })
160+
await goto('/package-docs/ufo/v/1.6.3/', { waitUntil: 'hydration' })
161161

162162
// Wait for version button to be visible
163163
const versionButton = page.locator('header button').filter({ hasText: '1.6.3' })

test/e2e/hydration.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { expect, test } from './test-utils'
33

44
const PAGES = [
55
'/',
6-
'/about',
7-
'/settings',
8-
'/privacy',
9-
'/compare',
10-
'/search',
11-
'/package/nuxt',
12-
'/search?q=vue',
6+
'/about/',
7+
'/settings/',
8+
'/privacy/',
9+
'/compare/',
10+
'/search/',
11+
'/package/nuxt/',
12+
'/search/?q=vue',
1313
] as const
1414

1515
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)