fix(plan): a 1.9 entry keeps its wrapped paths, and a numbered File line names its test
Review findings b4fa1927 and 4b6460e5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1320e3a4d5
commit
fddd0a078c
2 changed files with 103 additions and 10 deletions
|
|
@ -269,3 +269,63 @@ test('below 1.9: the step check reads a mid-line File: as before', () => {
|
|||
const r = validatePlanContent(planTestFirst19('1.8', ' - see File: `tests/mod1.test.mjs` for the test'), { strict: true });
|
||||
assert.equal(r.errors.find((e) => e.code === 'PLAN_STEP_NO_TEST_FIRST'), undefined, errCodes(r).join(','));
|
||||
});
|
||||
|
||||
// ---- Step 3 (trial 4): a wrapped 1.9 entry keeps its paths, and a numbered
|
||||
// `File:` line names its test (reviews b4fa1927, 4b6460e5) ----
|
||||
|
||||
const WRAPPED = '`tests/a.test.mjs`,\n `src/a.mjs`';
|
||||
const step1Fields = (text) => schema.parseStepFields(text.split('### Step 1:')[1].split('### Step 2:')[0]);
|
||||
|
||||
test('1.9: a Files list wrapped after a comma names both files and no issue', () => {
|
||||
const r = entryPaths(WRAPPED);
|
||||
assert.deepEqual(r.files, ['tests/a.test.mjs', 'src/a.mjs']);
|
||||
assert.deepEqual(r.issues, []);
|
||||
const v = validatePlanContent(plan19(WRAPPED));
|
||||
assert.deepEqual(pathIssues(v.errors), [], JSON.stringify(v.errors));
|
||||
// An issue keeps the entry's first line number.
|
||||
const bad = entryPaths('- `src/a.mjs`\n- the CLI,\n `src/b.mjs`');
|
||||
assert.deepEqual(bad.files, ['src/a.mjs']);
|
||||
assert.deepEqual(bad.issues.map((i) => [i.code, i.line]), [['PLAN_STEP_PATH_NOT_FIRST', 2]]);
|
||||
});
|
||||
|
||||
test('1.9: a step whose wrapped Files list names its source is not tests-only', () => {
|
||||
const body = `- **Files:** ${WRAPPED}\n- **Changes:** x\n- **Test first:**\n - File: \`tests/a.test.mjs\` (new)\n - Verifies: x\n`;
|
||||
assert.deepEqual(schema.stepTestsOnly(body, '1.9'), { testsOnly: false, files: ['tests/a.test.mjs', 'src/a.mjs'] });
|
||||
});
|
||||
|
||||
test('1.9: K6 plans the second file of a wrapped Files list', () => {
|
||||
const text = buildPlan({ version: '1.9', steps: [
|
||||
{ filesRaw: WRAPPED, test: 'tests/a.test.mjs', manifestPaths: ['tests/a.test.mjs'] },
|
||||
{ endToEnd: 'bash tests/e2e.sh' },
|
||||
] });
|
||||
assert.ok(text.includes(`- **Files:** ${WRAPPED}\n`), 'the builder writes the raw Files value');
|
||||
assert.ok(plannedPaths(text).includes('src/a.mjs'), JSON.stringify(plannedPaths(text)));
|
||||
});
|
||||
|
||||
test('1.9: a numbered File line (`1.` and `1)`) names its test - no PLAN_STEP_NO_TEST_FIRST', () => {
|
||||
for (const line of [' 1. File: `tests/mod1.test.mjs` (new)', ' 1) File: `tests/mod1.test.mjs` (new)']) {
|
||||
const text = planTestFirst19('1.9', line);
|
||||
assert.ok(text.includes(`${line}\n`), 'the builder writes the raw File line');
|
||||
assert.deepEqual(schema.testFirstFiles(step1Fields(text), '1.9'), ['tests/mod1.test.mjs'], line);
|
||||
const r = validatePlanContent(text, { strict: true });
|
||||
assert.equal(r.errors.find((e) => e.code === 'PLAN_STEP_NO_TEST_FIRST'), undefined, `${line}: ${errCodes(r).join(',')}`);
|
||||
}
|
||||
});
|
||||
|
||||
test('1.9: a wrapped File line keeps its second test; a wrapped description stays description', () => {
|
||||
const wrapped = planTestFirst19('1.9', ' - File: `tests/mod1.test.mjs`,\n `tests/mod1b.test.mjs` (new)');
|
||||
assert.deepEqual(schema.testFirstFiles(step1Fields(wrapped), '1.9'), ['tests/mod1.test.mjs', 'tests/mod1b.test.mjs']);
|
||||
const described = planTestFirst19('1.9', ' - File: `tests/mod1.test.mjs` - covers\n `src/parse.mjs` and the CLI');
|
||||
assert.deepEqual(schema.testFirstFiles(step1Fields(described), '1.9'), ['tests/mod1.test.mjs']);
|
||||
});
|
||||
|
||||
test('1.9: a Verifies item that wraps onto a backticked source path gives only the File line\'s test', () => {
|
||||
const text = planTestFirst19('1.9',
|
||||
' - File: `tests/mod1.test.mjs` (new)\n - Verifies: the parser in\n `src/mod1.mjs` reads the CLI options');
|
||||
assert.deepEqual(schema.testFirstFiles(step1Fields(text), '1.9'), ['tests/mod1.test.mjs']);
|
||||
});
|
||||
|
||||
test('1.9: two unmarked File lines in a row give both tests', () => {
|
||||
const text = planTestFirst19('1.9', ' File: `tests/mod1.test.mjs`\n File: `tests/mod1b.test.mjs`');
|
||||
assert.deepEqual(schema.testFirstFiles(step1Fields(text), '1.9'), ['tests/mod1.test.mjs', 'tests/mod1b.test.mjs']);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue