Merge remote-tracking branch 'origin/master' into pr/49871

# Conflicts:
#	tests/commands/playlist/format.test.ts
This commit is contained in:
Sanaei
2026-09-04 17:30:25 +02:00
47 changed files with 882 additions and 488 deletions
+1
View File
@@ -19,6 +19,7 @@ describe('playlist:export', () => {
content('tests/__data__/expected/playlist_export/.api/streams.json')
)
})
})
function content(filepath: string) {
+14
View File
@@ -30,6 +30,7 @@ describe('playlist:format', () => {
)
})
})
it('formats playlists in nested directories', () => {
const cmd = `${ENV_VAR} npm run playlist:format`
execSync(cmd, { encoding: 'utf8' })
@@ -39,6 +40,19 @@ describe('playlist:format', () => {
expect(output).toContain(',Zulu (720p)')
expect(output.indexOf(',Alpha (720p)')).toBeLessThan(output.indexOf(',Zulu (720p)'))
})
it('keeps links with malformed percent escapes', () => {
fs.emptyDirSync('tests/__data__/output')
fs.copySync('tests/__data__/input/playlist_normalize', 'tests/__data__/output/streams')
const cmd =
'cross-env STREAMS_DIR=tests/__data__/output/streams DATA_DIR=tests/__data__/input/data npm run playlist:format'
execSync(cmd, { encoding: 'utf8' })
expect(content('tests/__data__/output/streams/bad_encoding.m3u')).toContain(
'http://example.com/a%ZZ'
)
})
})
function content(filepath: string) {
+17 -1
View File
@@ -1,4 +1,5 @@
import child_process from 'node:child_process'
import child_process, { execSync } from 'node:child_process'
import path from 'node:path'
import { pathToFileURL } from 'node:url'
import { promisify } from 'node:util'
import * as fs from 'fs-extra'
@@ -9,6 +10,7 @@ const exec = promisify(child_process.exec)
type ExecError = {
status: number
stdout: string
stderr: string
}
const ENV_VAR = 'cross-env DATA_DIR=tests/__data__/input/data ROOT_DIR=tests/__data__/output'
@@ -55,6 +57,20 @@ describe('playlist:test', () => {
})
}
})
it('fails when the network is unavailable', () => {
const preload = path.resolve('tests/__data__/input/offline_dns.cjs').replaceAll('\\', '/')
const cmd =
`cross-env NODE_OPTIONS="--require=${preload}" npm run playlist:test -- streams/af.m3u`
try {
execSync(cmd, { encoding: 'utf8' })
throw new Error('Expected playlist:test to fail offline')
} catch (error) {
const output = `${(error as ExecError).stdout || ''}${(error as ExecError).stderr || ''}`
expect(output).toContain('Internet connection is required for the script to work')
}
})
})
function content(filepath: string) {
+8
View File
@@ -101,4 +101,12 @@ describe('playlist:validate', () => {
const stdout = execSync(cmd, { encoding: 'utf8' })
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
})
it('accepts a playlist without optional metadata attributes', () => {
const cmd = `${ENV_VAR} npm run playlist:validate -- missing_metadata.m3u`
const stdout = execSync(cmd, { encoding: 'utf8' })
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
expect(stdout).toContain('missing_metadata.m3u')
expect(stdout).toContain('is missing a channel ID')
})
})