mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-05-18 14:53:05 +08:00
Cover advisory source renderer branches
This commit is contained in:
committed by
Affaan Mustafa
parent
2b387fb761
commit
714200fd20
@@ -23,6 +23,7 @@ const {
|
|||||||
DEFAULT_ADVISORY_SOURCES,
|
DEFAULT_ADVISORY_SOURCES,
|
||||||
buildAdvisorySourceReport,
|
buildAdvisorySourceReport,
|
||||||
parseArgs,
|
parseArgs,
|
||||||
|
renderText,
|
||||||
} = require(SCRIPT_PATH);
|
} = require(SCRIPT_PATH);
|
||||||
|
|
||||||
async function test(name, fn) {
|
async function test(name, fn) {
|
||||||
@@ -186,6 +187,13 @@ async function run() {
|
|||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
|
||||||
if (await test('CLI text output and invalid flag errors are stable', async () => {
|
if (await test('CLI text output and invalid flag errors are stable', async () => {
|
||||||
|
const help = spawnSync('node', [SCRIPT_PATH, '--help'], {
|
||||||
|
encoding: 'utf8',
|
||||||
|
shell: process.platform === 'win32',
|
||||||
|
});
|
||||||
|
assert.strictEqual(help.status, 0);
|
||||||
|
assert.match(help.stdout, /--strict-refresh/);
|
||||||
|
|
||||||
const text = spawnSync('node', [
|
const text = spawnSync('node', [
|
||||||
SCRIPT_PATH,
|
SCRIPT_PATH,
|
||||||
'--generated-at',
|
'--generated-at',
|
||||||
@@ -206,6 +214,30 @@ async function run() {
|
|||||||
assert.match(invalid.stderr, /Unknown argument/);
|
assert.match(invalid.stderr, /Unknown argument/);
|
||||||
})) passed++; else failed++;
|
})) passed++; else failed++;
|
||||||
|
|
||||||
|
if (await test('text renderer covers blocked and refresh-warning states', async () => {
|
||||||
|
const blocked = await buildAdvisorySourceReport({
|
||||||
|
generatedAt: '2026-05-16T00:00:00.000Z',
|
||||||
|
sources: [],
|
||||||
|
});
|
||||||
|
const blockedText = renderText(blocked);
|
||||||
|
assert.match(blockedText, /blocked/);
|
||||||
|
assert.match(blockedText, /not requested/);
|
||||||
|
|
||||||
|
const warning = await buildAdvisorySourceReport({
|
||||||
|
generatedAt: '2026-05-16T00:00:00.000Z',
|
||||||
|
refresh: true,
|
||||||
|
fetchSource: async source => ({
|
||||||
|
ok: source.id !== 'tanstack-postmortem',
|
||||||
|
statusCode: source.id === 'tanstack-postmortem' ? 500 : 200,
|
||||||
|
error: source.id === 'tanstack-postmortem' ? 'server error' : null,
|
||||||
|
checkedAt: '2026-05-16T00:00:00.000Z',
|
||||||
|
finalUrl: source.url,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const warningText = renderText(warning);
|
||||||
|
assert.match(warningText, /warnings=1/);
|
||||||
|
})) passed++; else failed++;
|
||||||
|
|
||||||
if (await test('default refresh follows redirects and retries GET for unsupported HEAD', async () => {
|
if (await test('default refresh follows redirects and retries GET for unsupported HEAD', async () => {
|
||||||
const server = http.createServer((request, response) => {
|
const server = http.createServer((request, response) => {
|
||||||
if (request.url === '/redirect') {
|
if (request.url === '/redirect') {
|
||||||
|
|||||||
Reference in New Issue
Block a user