testNothingLeftToFixAfterGoingBack

tcmts.cli.test.e2e.editing.testNothingLeftToFixAfterGoingBack · #qcqsscxb · term

What needs fixing is what's broken now: a change a dependent can't follow leaves it to fix, and going back to before the change (tcm reset) leaves nothing, though the record of it stays.

import { okIn, tcmIn, tempDir } from "#codebase/tcmts/cli/test/e2e/harness";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";

export const testNothingLeftToFixAfterGoingBack = () => {
  const dir = tempDir("fixing after reset");
  const tcm = (...args: string[]) => okIn(dir, ...args);
  const update = (code: string) => {
    fs.writeFileSync(path.join(dir, "scratch.ts"), `// tcm: namespace lib\n${code}\n`);
    tcm("update");
  };
  tcm("init");
  update(
    `export const f = (x: number): number => x + 1;\nexport const g = (): number => f(1) * 2;`,
  );
  // (g can't follow f: f is saved, g left to fix)
  fs.writeFileSync(
    path.join(dir, "scratch.ts"),
    `// tcm: namespace lib\nexport const f = (x: number): string => String(x);\n`,
  );
  tcmIn(dir, "update");
  assert.match(tcm("todo"), /needs fixing lib\.g/);
  tcm("reset", "1");
  const todo = tcm("todo");
  assert.doesNotMatch(todo, /needs fixing/, todo);
  assert.match(todo, /nothing to do/);
}

uses