From 630ae0c73298faa733cbc89b691809b82a8b834b Mon Sep 17 00:00:00 2001 From: Zair Leon <73313698+notzairdev@users.noreply.github.com> Date: Mon, 16 Nov 2026 18:46:59 -0600 Subject: [PATCH] Test ordering after edits and removals --- tests/commands/playlist/update.test.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/commands/playlist/update.test.ts b/tests/commands/playlist/update.test.ts index 33427b893e..95e65d5e37 100644 --- a/tests/commands/playlist/update.test.ts +++ b/tests/commands/playlist/update.test.ts @@ -13,6 +13,31 @@ beforeEach(() => { }) describe('playlist:update', () => { + it('sorts edited and removed playlists without losing entries or playback options', () => { + const entries = [ + '#EXTINF:-1 tvg-id="",Zulu (720p)', + 'https://example.com/zulu.m3u8', + '#EXTINF:-1 tvg-id="",Alpha (720p)', + '#EXTVLCOPT:http-referrer=https://example.com/', + 'https://example.com/alpha.m3u8', + '' + ].join('\r\n') + for (const country of ['cy', 'br_example']) { + fs.appendFileSync(`tests/__data__/output/streams/${country}.m3u`, entries) + } + + execSync(`${ENV_VAR} npm run playlist:update --silent`, { encoding: 'utf8' }) + for (const country of ['cy', 'br_example']) { + const output = content(`tests/__data__/output/streams/${country}.m3u`) + expect(output.indexOf(',Alpha (720p)')).toBeLessThan(output.indexOf(',Zulu (720p)')) + expect(output).toContain('#EXTVLCOPT:http-referrer=https://example.com/') + expect(output).toContain('https://example.com/alpha.m3u8') + expect(output).toContain('https://example.com/zulu.m3u8') + } + expect(content('tests/__data__/output/streams/cy.m3u')).toContain(',AdaTV') + expect(content('tests/__data__/output/streams/br_example.m3u')).toContain(',BBC America') + }) + it('leaves the order of unrelated playlists unchanged', () => { const filepath = 'tests/__data__/output/streams/zz.m3u' const original = [