mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
docs(danmuku): [SITE-DANMUKU-01] complete bilingual usage guides
This commit is contained in:
1 parent
520727d762
commit
ea3174daa2
56 files changed
+5321
-3108
No files matched your search
@@ -101,6 +101,16 @@ cleanup and storage restoration. It does not execute all 233 documentation cases
|
||||
or prove remote SDKs/features. DPIP-MEDIA-01's exact WebKit intrinsic/layout size
|
||||
pairs remain explicit observations; this suite does not close that risk.
|
||||
|
||||
`yarn test:browser document-site.spec.js document-danmuku.spec.js --workers=1`
|
||||
checks built bilingual navigation and Run Code URLs, then extracts every runnable
|
||||
Danmuku snippet from both source guides. It loads the local Danmuku distribution
|
||||
(whose SHA-256 is attached), candidate core and real documentation sample in owned
|
||||
frames. This covers readiness and cleanup; it does not click every example control,
|
||||
wait for every delayed callback, prove playback or replace PKG-DANMUKU-08.
|
||||
Regenerate the site and its browser assets before navigation checks. Preserve both
|
||||
`.run-code` and `[classname="run-code"]` selectors: SSR and Vue navigation can
|
||||
produce different attribute forms, both supported by the site's handler.
|
||||
|
||||
`yarn test:browser test/browser/ads.spec.js` tests actual Ads 1.0.6 and candidate code
|
||||
with published 4.5.5/5.4.1 and candidate cores using local image/video media. It covers actual
|
||||
decoded pixels, countdown, skipping, content restoration, 404 and source replacement.
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { createHash } from 'node:crypto'
|
||||
import fs from 'node:fs'
|
||||
import { build } from 'esbuild'
|
||||
import { extractExamples } from '../../scripts/docs-smoke/parser.ts'
|
||||
import { expect, test } from './fixtures.js'
|
||||
|
||||
const compiled = await build({
|
||||
entryPoints: ['scripts/docs-smoke/runtime.ts'],
|
||||
bundle: true,
|
||||
write: false,
|
||||
format: 'iife',
|
||||
globalName: 'DocumentationSmoke',
|
||||
target: 'es2020',
|
||||
logLevel: 'silent',
|
||||
})
|
||||
const pluginFile = 'packages/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js'
|
||||
const plugin = fs.readFileSync(pluginFile)
|
||||
const pluginHash = createHash('sha256').update(plugin).digest('hex')
|
||||
const pluginUrl = '/uncompiled/artplayer-plugin-danmuku/index.js'
|
||||
|
||||
for (const relative of ['plugin/danmuku.md', 'en/plugin/danmuku.md']) {
|
||||
const source = fs.readFileSync(`packages/artplayer-vitepress/docs/${relative}`, 'utf8')
|
||||
for (const example of extractExamples(source, relative)) {
|
||||
test(`documented Danmuku example becomes ready and cleans up: ${example.id}`, async ({ page }, testInfo) => {
|
||||
await page.route(`**${pluginUrl}`, route => route.fulfill({ contentType: 'text/javascript', body: plugin }))
|
||||
await page.goto('/test/player.html')
|
||||
await page.addScriptTag({ content: compiled.outputFiles[0].text })
|
||||
const result = await page.evaluate(
|
||||
({ example, pluginUrl }) => window.DocumentationSmoke.runExample(example, ['/candidate/artplayer.js', pluginUrl]),
|
||||
{ example, pluginUrl },
|
||||
)
|
||||
expect(result.instances).toBe(1)
|
||||
expect(result.ready).toBe(1)
|
||||
expect(result.media[0].duration).toBeGreaterThan(0)
|
||||
expect(result.media[0].width).toBeGreaterThan(0)
|
||||
expect(result.media[0].height).toBeGreaterThan(0)
|
||||
await expect(page.locator('iframe[data-documentation-smoke]')).toHaveCount(0)
|
||||
await testInfo.attach('documented-example', {
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ example, pluginFile, pluginHash, result, scope: 'readiness and frame cleanup; interactive commands and playback remain separate' }),
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ for (const language of ['zh', 'en']) {
|
||||
await expect(page.locator('h1')).toContainText(
|
||||
language === 'en' ? 'Basic Options' : '基础选项',
|
||||
)
|
||||
const button = page.locator('[classname="run-code"]').first()
|
||||
const button = page.locator('.run-code, [classname="run-code"]').first()
|
||||
await expect(button).toBeVisible()
|
||||
const popupPromise = context.waitForEvent('page')
|
||||
await button.click()
|
||||
@@ -49,5 +49,17 @@ for (const language of ['zh', 'en']) {
|
||||
await expect(group.locator('input[type="radio"]').nth(1)).toBeChecked()
|
||||
await expect(group.locator('.blocks > div').nth(1)).toBeVisible()
|
||||
await expect(group.locator('.blocks > div').first()).toBeHidden()
|
||||
const danmukuLink = page.locator(`.VPSidebar a[href="${prefix}/plugin/danmuku.html"]`)
|
||||
await danmukuLink.click()
|
||||
await expect(page.locator('h1')).toContainText(language === 'en' ? 'Danmuku' : '弹幕库')
|
||||
const examplePopup = context.waitForEvent('page')
|
||||
await page.locator('.run-code, [classname="run-code"]').first().click()
|
||||
const example = await examplePopup
|
||||
await example.waitForLoadState('domcontentloaded')
|
||||
const exampleUrl = new URL(example.url())
|
||||
expect(exampleUrl.searchParams.get('libs')).toBe('./uncompiled/artplayer-plugin-danmuku/index.js')
|
||||
expect(exampleUrl.searchParams.get('code')).toContain('artplayerPluginDanmuku({')
|
||||
expect(failedAssets).toEqual([])
|
||||
await example.close()
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user