From 9902121ac0c02772d1c004582aeba0ce710f7d84 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 18 Sep 2026 11:30:45 +0300 Subject: [PATCH] Update tests --- tests/commands/issue/validate.test.ts | 15 +++++++++++++ tests/commands/playlist/edit.test.ts | 1 + tests/commands/playlist/export.test.ts | 2 +- tests/commands/playlist/format.test.ts | 1 + tests/commands/playlist/generate.test.ts | 1 + tests/commands/playlist/test.test.ts | 4 ++-- tests/commands/playlist/update.test.ts | 6 ++---- tests/commands/playlist/validate.test.ts | 27 +++++++++++++++++++++--- tests/commands/readme/update.test.ts | 1 + tests/commands/report/create.test.ts | 1 + 10 files changed, 49 insertions(+), 10 deletions(-) diff --git a/tests/commands/issue/validate.test.ts b/tests/commands/issue/validate.test.ts index ba2eefe6ce..d283ba4d5b 100644 --- a/tests/commands/issue/validate.test.ts +++ b/tests/commands/issue/validate.test.ts @@ -1,3 +1,4 @@ +import { describe, beforeEach, it, expect } from 'vitest' import issues from '../../__data__/input/issues' import { pathToFileURL } from 'node:url' import { execFileSync } from 'child_process' @@ -57,6 +58,20 @@ describe('issue:validate', () => { ) } }) + + it('can handle streams:edit request without changes', () => { + const body = issues.find(issue => issue.number === 39098)?.body + + try { + const stdout = runIssueValidate(body, 'approved,streams:edit') + if (process.env.DEBUG === 'true') console.log(stdout) + throw new Error('Failed') + } catch { + expect(content('tests/__data__/output/logs/errors.txt')).toBe( + content('tests/__data__/expected/issue_validate/logs/streams_edit_no_changes.txt') + ) + } + }) }) function runIssueValidate(body: string | undefined, labels: string) { diff --git a/tests/commands/playlist/edit.test.ts b/tests/commands/playlist/edit.test.ts index aee61364b4..15f385dae3 100644 --- a/tests/commands/playlist/edit.test.ts +++ b/tests/commands/playlist/edit.test.ts @@ -1,3 +1,4 @@ +import { describe, beforeEach, it, expect } from 'vitest' import { execSync } from 'child_process' import fs from 'fs-extra' diff --git a/tests/commands/playlist/export.test.ts b/tests/commands/playlist/export.test.ts index 7026c0a55c..e14658052a 100644 --- a/tests/commands/playlist/export.test.ts +++ b/tests/commands/playlist/export.test.ts @@ -1,3 +1,4 @@ +import { describe, beforeEach, it, expect } from 'vitest' import { pathToFileURL } from 'node:url' import { execSync } from 'child_process' import fs from 'fs-extra' @@ -19,7 +20,6 @@ describe('playlist:export', () => { content('tests/__data__/expected/playlist_export/.api/streams.json') ) }) - }) function content(filepath: string) { diff --git a/tests/commands/playlist/format.test.ts b/tests/commands/playlist/format.test.ts index 2a01d0a887..feeed80fd6 100644 --- a/tests/commands/playlist/format.test.ts +++ b/tests/commands/playlist/format.test.ts @@ -1,3 +1,4 @@ +import { describe, beforeEach, it, expect } from 'vitest' import { pathToFileURL } from 'node:url' import { execSync } from 'child_process' import * as fs from 'fs-extra' diff --git a/tests/commands/playlist/generate.test.ts b/tests/commands/playlist/generate.test.ts index 37efbf67f1..03e42106dc 100644 --- a/tests/commands/playlist/generate.test.ts +++ b/tests/commands/playlist/generate.test.ts @@ -1,3 +1,4 @@ +import { describe, beforeEach, it, expect } from 'vitest' import { pathToFileURL } from 'node:url' import { execSync } from 'child_process' import { EOL } from 'node:os' diff --git a/tests/commands/playlist/test.test.ts b/tests/commands/playlist/test.test.ts index d53e50a9c8..eae0c60deb 100644 --- a/tests/commands/playlist/test.test.ts +++ b/tests/commands/playlist/test.test.ts @@ -1,3 +1,4 @@ +import { describe, beforeEach, it, expect } from 'vitest' import child_process, { execSync } from 'node:child_process' import path from 'node:path' import { pathToFileURL } from 'node:url' @@ -60,8 +61,7 @@ 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` + const cmd = `cross-env NODE_OPTIONS="--require=${preload}" npm run playlist:test -- streams/af.m3u` try { execSync(cmd, { encoding: 'utf8' }) diff --git a/tests/commands/playlist/update.test.ts b/tests/commands/playlist/update.test.ts index afd03cc574..02b29471eb 100644 --- a/tests/commands/playlist/update.test.ts +++ b/tests/commands/playlist/update.test.ts @@ -1,3 +1,4 @@ +import { describe, beforeEach, it, expect } from 'vitest' import { pathToFileURL } from 'node:url' import { execSync } from 'child_process' import * as fs from 'fs-extra' @@ -12,7 +13,7 @@ beforeEach(() => { }) describe('playlist:update', () => { - it('can update playlists', done => { + it('can update playlists', async () => { let cmd = `${ENV_VAR} npm run playlist:update` if (!process.env.DEBUG) cmd += ' --silent' try { @@ -39,11 +40,8 @@ describe('playlist:update', () => { expect(content('tests/__data__/output/logs/playlist_update.log')).toBe( content('tests/__data__/expected/playlist_update/playlist_update.log') ) - - done() } catch (err) { if (process.env.DEBUG === 'true') console.log(cmd, err.stdout) - done(err) } }) }) diff --git a/tests/commands/playlist/validate.test.ts b/tests/commands/playlist/validate.test.ts index 44288eeaf9..29595ad853 100644 --- a/tests/commands/playlist/validate.test.ts +++ b/tests/commands/playlist/validate.test.ts @@ -1,3 +1,4 @@ +import { describe, it, expect } from 'vitest' import { execSync } from 'child_process' type ExecError = { @@ -38,6 +39,7 @@ describe('playlist:validate', () => { ) } catch (error) { if (process.env.DEBUG === 'true') console.log(cmd, error) + process.exit(0) } }) @@ -46,11 +48,14 @@ describe('playlist:validate', () => { try { const stdout = execSync(cmd, { encoding: 'utf8' }) if (process.env.DEBUG === 'true') console.log(cmd, stdout) - expect(stdout).toContain( - 'wrong_channel_id.m3u\n 2 warning "qib22lAq1L.us" is not in the database\n\n1 problems (0 errors, 1 warnings)\n' - ) + expect(stdout).toContain(`wrong_channel_id.m3u + 2 warning "qib22lAq1L.us@SD" is not in the database + 2 warning There is no feed with the ID "SD" in the database for the "qib22lAq1L.us" channel + +2 problems (0 errors, 2 warnings)`) } catch (error) { if (process.env.DEBUG === 'true') console.log(cmd, error) + process.exit(0) } }) @@ -64,6 +69,7 @@ describe('playlist:validate', () => { ) } catch (error) { if (process.env.DEBUG === 'true') console.log(cmd, error) + process.exit(0) } }) @@ -77,6 +83,7 @@ describe('playlist:validate', () => { ) } catch (error) { if (process.env.DEBUG === 'true') console.log(cmd, error) + process.exit(0) } }) @@ -109,4 +116,18 @@ describe('playlist:validate', () => { expect(stdout).toContain('missing_metadata.m3u') expect(stdout).toContain('is missing a channel ID') }) + + it('shows only errors if log level is error', () => { + const cmd = `${ENV_VAR} npm run playlist:validate -- --log-level=error log_level.m3u` + try { + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + process.exit(0) + } catch (error) { + if (process.env.DEBUG === 'true') console.log(cmd, error) + expect((error as ExecError).stdout).toContain( + 'log_level.m3u\n 2 error \"new: https://streamer2.nexgen.bz/07-CHANNEL7/index.m3u8\" is not a valid URL\n\n1 problems (1 errors, 0 warnings)\n' + ) + } + }) }) diff --git a/tests/commands/readme/update.test.ts b/tests/commands/readme/update.test.ts index 422a52d54f..4a98700ad0 100644 --- a/tests/commands/readme/update.test.ts +++ b/tests/commands/readme/update.test.ts @@ -1,3 +1,4 @@ +import { describe, beforeEach, it, expect } from 'vitest' import { pathToFileURL } from 'node:url' import { execSync } from 'child_process' import fs from 'fs-extra' diff --git a/tests/commands/report/create.test.ts b/tests/commands/report/create.test.ts index 704292b2e8..35a96a26d5 100644 --- a/tests/commands/report/create.test.ts +++ b/tests/commands/report/create.test.ts @@ -1,3 +1,4 @@ +import { describe, it, expect } from 'vitest' import { execSync } from 'child_process' const ENV_VAR =