mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-10 04:46:07 -08:00
test(plugins): cover second same-text delayed cue in subtitle e2e
- Extract a reportSubtitle helper that returns the nth probe log line - Seek to the second cue with identical text and assert its 6-8 timings
This commit is contained in:
1 file changed
+22
-17
+22
-17
@@ -237,6 +237,20 @@ test(
|
||||
`1\n00:00:01,000 --> 00:00:03,000\n${text}\n\n2\n00:00:06,000 --> 00:00:08,000\n${text}\n`,
|
||||
);
|
||||
const originalSid = await session.mpv.command('get_property', 'sid');
|
||||
// Runs the probe action and returns the cue it logged on its nth run.
|
||||
const reportSubtitle = async (run: number): Promise<unknown> => {
|
||||
await session.runAppCommand('--plugin-action', 'e2e-probe/subtitle');
|
||||
const line = await waitUntil(
|
||||
() =>
|
||||
fs
|
||||
.readFileSync(path.join(session.root, 'app.log'), 'utf8')
|
||||
.split('\n')
|
||||
.filter((entry) => entry.includes('probe subtitle '))[run - 1],
|
||||
{ description: `the plugin to report its current subtitle (run ${run})` },
|
||||
);
|
||||
assert.ok(line);
|
||||
return JSON.parse(line.slice(line.indexOf('probe subtitle ') + 'probe subtitle '.length));
|
||||
};
|
||||
try {
|
||||
await session.mpv.command('seek', 0, 'absolute+exact');
|
||||
await session.mpv.command('sub-add', subtitlePath, 'select');
|
||||
@@ -251,24 +265,15 @@ test(
|
||||
`document.getElementById('subtitleRoot').textContent === ${JSON.stringify(text)}`,
|
||||
{ description: 'the first delayed line to be visible' },
|
||||
);
|
||||
await session.runAppCommand('--plugin-action', 'e2e-probe/subtitle');
|
||||
const line = await waitUntil(
|
||||
() =>
|
||||
fs
|
||||
.readFileSync(path.join(session.root, 'app.log'), 'utf8')
|
||||
.split('\n')
|
||||
.find((entry) => entry.includes('probe subtitle ')),
|
||||
{ description: 'the plugin to report its current subtitle' },
|
||||
);
|
||||
assert.ok(line);
|
||||
assert.deepEqual(
|
||||
JSON.parse(line.slice(line.indexOf('probe subtitle ') + 'probe subtitle '.length)),
|
||||
{
|
||||
text,
|
||||
startTime: 1,
|
||||
endTime: 3,
|
||||
},
|
||||
assert.deepEqual(await reportSubtitle(1), { text, startTime: 1, endTime: 3 });
|
||||
|
||||
// Same text again at 6-8 on the subtitle clock, so only the timings tell the cues apart.
|
||||
await session.mpv.command('seek', 12, 'absolute+exact');
|
||||
await overlay.waitFor(
|
||||
`document.querySelectorAll('#subtitleSidebarList .subtitle-sidebar-item')[1]?.classList.contains('active') === true`,
|
||||
{ description: 'the second delayed line to become active' },
|
||||
);
|
||||
assert.deepEqual(await reportSubtitle(2), { text, startTime: 6, endTime: 8 });
|
||||
} finally {
|
||||
await session.mpv.command('set_property', 'sub-delay', 0);
|
||||
await session.mpv.command('set_property', 'sid', originalSid);
|
||||
|
||||
Reference in new issue
Block a user