25 lines
1.7 KiB
JavaScript
25 lines
1.7 KiB
JavaScript
const { test } = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const { message } = require('./download-errors.js');
|
||
const { formatJobStatus } = require('./downloads-page.js');
|
||
test('unavailable songs get useful copy without claiming that they were removed', () => {
|
||
const raw = 'ERROR: [youtube] wZzRoXymOUU: Video unavailable\nYouTube clients tried: default, web_embedded, web_safari';
|
||
assert.equal(message(raw), 'YouTube isn’t letting the server save this video. Try Retry; it may still play on YouTube.');
|
||
assert.equal(formatJobStatus({ status: 'failed', error: raw }), 'Failed: ' + message(raw));
|
||
});
|
||
test('known restrictions and bot failures have distinct explanations', () => {
|
||
assert.match(message('Video unavailable. not available in your country'), /server’s region/);
|
||
assert.match(message('Video unavailable. Private video'), /requires access/);
|
||
assert.match(message('Video unavailable. Confirm your age'), /requires access/);
|
||
assert.match(message('Video has been removed'), /no longer/);
|
||
assert.match(message('Sign in to confirm you are not a bot'), /temporarily blocked/);
|
||
assert.match(message('Requested format is not available'), /other download methods/);
|
||
});
|
||
test('missing and raw tool failures get a short fallback; existing useful messages survive', () => {
|
||
assert.equal(message(null), 'Could not save this video. Try Retry.');
|
||
assert.equal(message('ERROR: mysterious extractor failure'), 'The server could not save this video. Try Retry.');
|
||
assert.equal(message('Connection lost'), 'Connection lost');
|
||
assert.equal(message('Please wait a few seconds before trying again.'), 'Please wait a few seconds before trying again.');
|
||
assert.equal(message('a'.repeat(200)), 'Could not save this video. Try Retry.');
|
||
});
|