2026-05-01 20:39:09 +08:00
|
|
|
import { describe, expect, it } from 'vitest'
|
2026-04-24 09:39:03 +08:00
|
|
|
|
2026-05-01 20:39:09 +08:00
|
|
|
import { isReclaimableHiddenPlaywrightTarget } from './playwright-cdp-targets'
|
2026-04-24 09:39:03 +08:00
|
|
|
|
2026-05-01 20:39:09 +08:00
|
|
|
describe('playwright cdp target pruning', () => {
|
|
|
|
|
it('does not reclaim blank app-owned page targets', () => {
|
|
|
|
|
expect(
|
|
|
|
|
isReclaimableHiddenPlaywrightTarget({
|
|
|
|
|
id: 'main-window-host',
|
|
|
|
|
type: 'page',
|
|
|
|
|
title: '',
|
|
|
|
|
url: '',
|
|
|
|
|
}),
|
|
|
|
|
).toBe(false)
|
|
|
|
|
})
|
2026-04-24 09:39:03 +08:00
|
|
|
|
2026-05-01 20:39:09 +08:00
|
|
|
it('only reclaims targets marked as hidden Playwright pages', () => {
|
|
|
|
|
expect(
|
|
|
|
|
isReclaimableHiddenPlaywrightTarget({
|
|
|
|
|
id: 'hidden-window',
|
|
|
|
|
type: 'page',
|
|
|
|
|
title: '监控任务 · hidden-playwright',
|
|
|
|
|
url: 'data:text/html;charset=utf-8,%3Cmeta%20name%3D%22geo-hidden-playwright-token%22%3E',
|
|
|
|
|
}),
|
|
|
|
|
).toBe(true)
|
|
|
|
|
})
|
2026-04-24 09:39:03 +08:00
|
|
|
|
2026-05-01 20:39:09 +08:00
|
|
|
it('ignores regular user-visible browser targets', () => {
|
|
|
|
|
expect(
|
|
|
|
|
isReclaimableHiddenPlaywrightTarget({
|
|
|
|
|
id: 'renderer',
|
|
|
|
|
type: 'page',
|
|
|
|
|
title: '省心推 - 账号健康监控与内容发布平台',
|
|
|
|
|
url: 'http://localhost:5173/',
|
|
|
|
|
}),
|
|
|
|
|
).toBe(false)
|
|
|
|
|
})
|
|
|
|
|
})
|