Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions test/migrate-directory.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,17 @@ describe('detectProjectType: .NET extensions (.slnx, .fsproj, .vbproj)', () => {
beforeEach(() => { tmpDir = makeTempDir(); });
afterEach(() => cleanDir(tmpDir));

it('init in a dir with .slnx generates a dotnet stub CI workflow', () => {
it('upgrade in a dir with .slnx generates a dotnet stub CI workflow', () => {
fs.writeFileSync(path.join(tmpDir, 'MyApp.slnx'), '');
const result = runSquad([], tmpDir);
assert.equal(result.exitCode, 0, `init should succeed: ${result.stdout}`);
// init creates .squad/ structure but skips CI workflows (by design since PR #847)
const initResult = runSquad([], tmpDir);
assert.equal(initResult.exitCode, 0, `init should succeed: ${initResult.stdout}`);
// upgrade installs CI/CD workflows including project-type-specific ones
const result = runSquad(['upgrade'], tmpDir);
assert.equal(result.exitCode, 0, `upgrade should succeed: ${result.stdout}`);

const ciPath = path.join(tmpDir, '.github', 'workflows', 'squad-ci.yml');
assert.ok(fs.existsSync(ciPath), 'squad-ci.yml should be created');
assert.ok(fs.existsSync(ciPath), 'squad-ci.yml should be created by upgrade');
const ciContent = fs.readFileSync(ciPath, 'utf8');
assert.ok(
ciContent.includes('dotnet') || ciContent.toLowerCase().includes('dotnet'),
Expand All @@ -268,10 +272,12 @@ describe('detectProjectType: .NET extensions (.slnx, .fsproj, .vbproj)', () => {
);
});

it('init in a dir with .fsproj generates a dotnet stub CI workflow', () => {
it('upgrade in a dir with .fsproj generates a dotnet stub CI workflow', () => {
fs.writeFileSync(path.join(tmpDir, 'MyLib.fsproj'), '');
const result = runSquad([], tmpDir);
assert.equal(result.exitCode, 0, `init should succeed: ${result.stdout}`);
const initResult = runSquad([], tmpDir);
assert.equal(initResult.exitCode, 0, `init should succeed: ${initResult.stdout}`);
const result = runSquad(['upgrade'], tmpDir);
assert.equal(result.exitCode, 0, `upgrade should succeed: ${result.stdout}`);

const ciPath = path.join(tmpDir, '.github', 'workflows', 'squad-ci.yml');
const ciContent = fs.readFileSync(ciPath, 'utf8');
Comment on lines +279 to 283

Copilot AI Apr 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.readFileSync(ciPath, 'utf8') is called without first asserting that squad-ci.yml exists. If upgrade fails to write the workflow, the test will throw with a less-informative ENOENT stack trace instead of a clear assertion failure. Add an assert.ok(fs.existsSync(ciPath), ...) before reading the file (as done in the .slnx test).

Copilot uses AI. Check for mistakes.
Expand All @@ -281,10 +287,12 @@ describe('detectProjectType: .NET extensions (.slnx, .fsproj, .vbproj)', () => {
);
});

it('init in a dir with .vbproj generates a dotnet stub CI workflow', () => {
it('upgrade in a dir with .vbproj generates a dotnet stub CI workflow', () => {
fs.writeFileSync(path.join(tmpDir, 'MyApp.vbproj'), '');
const result = runSquad([], tmpDir);
assert.equal(result.exitCode, 0, `init should succeed: ${result.stdout}`);
const initResult = runSquad([], tmpDir);
assert.equal(initResult.exitCode, 0, `init should succeed: ${initResult.stdout}`);
const result = runSquad(['upgrade'], tmpDir);
assert.equal(result.exitCode, 0, `upgrade should succeed: ${result.stdout}`);

const ciPath = path.join(tmpDir, '.github', 'workflows', 'squad-ci.yml');
const ciContent = fs.readFileSync(ciPath, 'utf8');
Comment on lines +294 to 298

Copilot AI Apr 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fs.readFileSync(ciPath, 'utf8') is executed without verifying the workflow file exists first. If upgrade doesn't create squad-ci.yml, the test will fail with an ENOENT error rather than an assertion message. Add an assert.ok(fs.existsSync(ciPath), ...) before reading the file for clearer failures.

Copilot uses AI. Check for mistakes.
Expand Down
Loading