Skip to content

Commit 1871937

Browse files
committed
fix: Test and type fixes
1 parent 441ab31 commit 1871937

File tree

7 files changed

+14
-6
lines changed

7 files changed

+14
-6
lines changed

src/commands/login.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import chalk from 'chalk';
44
import { BaseCommand } from '../common/base-command.js';
55
import { LoginOrchestrator } from '../orchestrators/login.js';
66

7+
// @ts-ignore
78
export default class Login extends BaseCommand {
89
static description =
910
`Logins to Codify cloud account.

src/connect/http-routes/handlers/import-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function importHandler() {
3737
throw new Error('Invalid codify config');
3838
}
3939

40-
const tmpDir = await fs.mkdtemp(os.tmpdir());
40+
const tmpDir = await fs.mkdtemp(os.tmpdir() + '/');
4141
const filePath = path.join(tmpDir, 'codify.jsonc');
4242
await fs.writeFile(filePath, JSON.stringify(codifyConfig, null, 2));
4343
session.additionalData.filePath = filePath;

src/connect/http-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function listen(app: express.Application, reporter: Reporter, onOpen: (server: S
7676
}
7777

7878
function createAuthHandler(connectionCode: string) {
79-
return (req, res, next) => {
79+
return (req: any, res: any, next: any) => {
8080
if (req.header('Authorization') !== connectionCode) {
8181
return res.status(400).json({ error: 'Invalid authorization' })
8282
}
@@ -85,7 +85,7 @@ function createAuthHandler(connectionCode: string) {
8585
}
8686
}
8787

88-
function errorHandler(err, req, res, next) {
88+
function errorHandler(err: Error, req: any, res: any, next: any) {
8989
console.log(err.message);
9090
res.status(500).json({ error: err.message });
9191
}

src/orchestrators/login.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export class LoginOrchestrator {
4848
try {
4949
const accessToken = await DashboardApiClient.login(username, password);
5050
await LoginHelper.save(accessToken);
51-
} catch (e) {
52-
console.error(chalk.red(JSON.parse(e.message).error));
51+
} catch (error: any) {
52+
console.error(chalk.red(JSON.parse(error.message).error));
5353

5454
process.exit(1);
5555
}

test/orchestrator/connect/connect-command.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ describe('Connect orchestrator tests', () => {
4444
const reporter = new MockReporter();
4545
await fakeLogin();
4646

47+
config.connectServerPort = Math.floor(Math.random() * 10000)
48+
4749
const openSpy = vi.spyOn(open, 'default');
4850

4951
await new Promise<void>((done) => {
@@ -64,7 +66,7 @@ describe('Connect orchestrator tests', () => {
6466
await fakeLogout();
6567

6668
const loginRunSpy = vi.spyOn(LoginOrchestrator, 'run');
67-
const openSpy = vi.spyOn(open, 'default');
69+
config.connectServerPort = Math.floor(Math.random() * 10000)
6870

6971
await new Promise<void>((done) => {
7072
ConnectOrchestrator.run('codify', reporter, false, async (connectionCode: string, server: Server) => {

test/orchestrator/connect/socket-server.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ describe('Connect orchestrator tests', () => {
239239
})
240240
});
241241

242+
console.log(await commandResponse.text());
242243
expect(commandResponse.ok).to.be.true;
243244

244245
server.close();
@@ -362,6 +363,8 @@ describe('Connect orchestrator tests', () => {
362363
})
363364

364365
function startServer(reporter: Reporter, onOpen: (connectionCode: string, clientId: string, server: Server) => void) {
366+
config.connectServerPort = Math.floor(Math.random() * 10000)
367+
365368
ConnectOrchestrator.run('codify', reporter, false, async (connectionCode: string, server: Server) => {
366369
expect(connectionCode).to.be.a('string');
367370

test/orchestrator/edit/edit.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ describe('Edit orchestrator tests', () => {
5050

5151
await expect.poll(async () => {
5252
return checkPortStatus(config.connectServerPort);
53+
}, {
54+
timeout: 4000,
5355
}).toBeTruthy()
5456
});
5557

0 commit comments

Comments
 (0)