feat(cli): Add missing database integrations, add tests for all CLI integrations add and edit commands#321
Conversation
…lution; remove unnecessary TypeScript error suppression in integration tests.
…er to V8 and adjust lint-staged commands
…s for @inquirer/testing; modify lint-staged commands to use nvm; remove inline dependency configuration from vitest setup.
There was a problem hiding this comment.
♻️ Duplicate comments (2)
packages/cli/src/commands/integrations/tests/add-integration.redshift.test.ts (2)
51-213:⚠️ Potential issue | 🟠 MajorStill missing enabled SSH/SSL path coverage.
Line 77, Line 81, Line 142, Line 146, Line 188, and Line 192 always take default
No, so enabled branches are still untested. Add at least one scenario that answersy, fills SSH fields, and asserts persisted SSH/SSL metadata in YAML.As per coding guidelines, "Create comprehensive tests for all new features using Vitest" and "Test edge cases, error handling, and special characters in test files".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.redshift.test.ts` around lines 51 - 213, The tests never exercise the "Enable SSH tunnel" and "Enable SSL" affirmative path; add at least one new test (or extend an existing it block) that, after calling createIntegration(...) and fillBaseFields(), when prompted for "Enable SSH tunnel: (y/N)" and "Enable SSL: (y/N)" answers 'y', supplies the SSH fields (e.g., bastion host, bastion user, bastion port, private key or key path) via the same screen.type()/keypress flows used elsewhere, awaits the promise, then reads the generated YAML and asserts the resulting metadata contains the SSH and SSL properties (matching the app's metadata keys used when writing the file); use the same helpers (createIntegration, fillBaseFields, screen.next) and the mocked UUID to keep consistency.
89-108:⚠️ Potential issue | 🟡 MinorUse
dedentfor multiline inline snapshots.These snapshot blocks should be wrapped with
dedent(...)for consistent indentation normalization.Proposed fix
+import dedent from 'ts-dedent' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' @@ - expect(yamlContent).toMatchInlineSnapshot(` + expect(yamlContent).toMatchInlineSnapshot(dedent(` "#yaml-language-server: $schema=https://raw.githubusercontent.com/deepnote/deepnote/refs/heads/tk/integrations-config-file-schema/json-schemas/integrations-file-schema.json @@ " - `) - expect(envContent).toMatchInlineSnapshot(` + `)) + expect(envContent).toMatchInlineSnapshot(dedent(` "AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__PASSWORD=redshift-pass " - `) + `)) @@ - expect(yamlContent).toMatchInlineSnapshot(` + expect(yamlContent).toMatchInlineSnapshot(dedent(` @@ " - `) + `)) @@ - expect(yamlContent).toMatchInlineSnapshot(` + expect(yamlContent).toMatchInlineSnapshot(dedent(` @@ " - `) + `))#!/bin/bash # Verify multiline snapshots are present and dedent is used in this test file. rg -n "toMatchInlineSnapshot\\(" packages/cli/src/commands/integrations/tests/add-integration.redshift.test.ts rg -n "dedent\\(" packages/cli/src/commands/integrations/tests/add-integration.redshift.test.tsAs per coding guidelines, "Use
dedentfromts-dedentfor multiline string comparisons in tests".Also applies to: 153-169, 199-212
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.redshift.test.ts` around lines 89 - 108, The inline multiline snapshots passed to expect(yamlContent).toMatchInlineSnapshot(...) and expect(envContent).toMatchInlineSnapshot(...) should be wrapped with dedent(...) to normalize indentation; add an import for dedent from 'ts-dedent' if missing and replace the raw backtick snapshot arguments with dedent(`...`) for each toMatchInlineSnapshot occurrence (also update the other two similar blocks referenced around the file), keeping the exact snapshot text but wrapped with dedent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@packages/cli/src/commands/integrations/tests/add-integration.redshift.test.ts`:
- Around line 51-213: The tests never exercise the "Enable SSH tunnel" and
"Enable SSL" affirmative path; add at least one new test (or extend an existing
it block) that, after calling createIntegration(...) and fillBaseFields(), when
prompted for "Enable SSH tunnel: (y/N)" and "Enable SSL: (y/N)" answers 'y',
supplies the SSH fields (e.g., bastion host, bastion user, bastion port, private
key or key path) via the same screen.type()/keypress flows used elsewhere,
awaits the promise, then reads the generated YAML and asserts the resulting
metadata contains the SSH and SSL properties (matching the app's metadata keys
used when writing the file); use the same helpers (createIntegration,
fillBaseFields, screen.next) and the mocked UUID to keep consistency.
- Around line 89-108: The inline multiline snapshots passed to
expect(yamlContent).toMatchInlineSnapshot(...) and
expect(envContent).toMatchInlineSnapshot(...) should be wrapped with dedent(...)
to normalize indentation; add an import for dedent from 'ts-dedent' if missing
and replace the raw backtick snapshot arguments with dedent(`...`) for each
toMatchInlineSnapshot occurrence (also update the other two similar blocks
referenced around the file), keeping the exact snapshot text but wrapped with
dedent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 119817f7-4ede-438e-850b-5764a00a8a25
📒 Files selected for processing (2)
packages/cli/src/commands/integrations/tests/add-integration.redshift.test.tspackages/cli/src/commands/integrations/tests/add-integration.trino.test.ts
|
@coderabbitai resolve all dedent comments |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 1084 🏁 Script executed: Length of output: 797
✏️ Learnings added
|
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (3)
packages/cli/src/commands/integrations/tests/add-integration.clickhouse.test.ts (1)
183-205:⚠️ Potential issue | 🟡 MinorMissing
.envassertion for SSH flow.Password was provided via
fillBaseFields(), YAML shows env reference, but.envcontent is never verified. Add assertion afterawait promise:await promise const yamlContent = await readFile(filePath, 'utf-8') + const envContent = await readFile(envFilePath, 'utf-8') expect(yamlContent).toMatchInlineSnapshot(` ... `) + expect(envContent).toContain('AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__PASSWORD=supersecret')🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.clickhouse.test.ts` around lines 183 - 205, The test adds a ClickHouse integration using fillBaseFields() and verifies the YAML but misses asserting the generated .env contents; after the existing await promise line in the test (the variable named promise), read the created .env file (using the same filePath root or helper used elsewhere) and assert it contains the expected environment variable mapping for AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__PASSWORD => the plain password value supplied by fillBaseFields(); update the test to include this .env assertion so both the YAML env reference and the actual .env secret are verified.packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts (2)
109-168:⚠️ Potential issue | 🟡 MinorMissing
.envverification.Password is re-entered but
.envcontent isn't asserted. Add a check to ensure the env var wasn't corrupted or duplicated.Suggested addition
const yamlContent = await readFile(filePath, 'utf-8') expect(yamlContent).toMatchInlineSnapshot(` ... `) + + const envContent = await readFile(envFilePath, 'utf-8') + expect(envContent).toMatchInlineSnapshot(` + "ID001__PASSWORD=secret-pass + " + `) })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts` around lines 109 - 168, The test updates the integration password via interactive prompts but never asserts the .env file content; add a check after awaiting promise to read the env file (use envFilePath and readFile) and assert the env variable is still present and unchanged (e.g., equals or contains "ID001__PASSWORD=secret-pass\n") so the password env var wasn't corrupted or duplicated by editIntegration; locate this assertion near the existing yamlContent check in the 'updates host and database when user types new values' test.
170-247:⚠️ Potential issue | 🟡 MinorAlso missing
.envverification.Same gap as the previous test. Verify
.envcontent is preserved when enabling SSH.Suggested addition after line 246
expect(yamlContent).toMatchInlineSnapshot(` ... `) + + const envContent = await readFile(envFilePath, 'utf-8') + expect(envContent).toMatchInlineSnapshot(` + "ID001__PASSWORD=secret-pass + " + `) })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts` around lines 170 - 247, In the test "adds SSH fields when SSH is enabled on a plain integration" add a check that the .env file was not modified after running editIntegration: after awaiting promise, read envFilePath (the .env variable used in the test) and assert its contents still include "ID001__PASSWORD=secret-pass" (or match the original .env string), ensuring enabling SSH preserved the .env file; keep this assertion next to the existing yamlContent assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/cli/src/commands/integrations/tests/add-integration.mysql.test.ts`:
- Around line 99-100: The test snapshot for yamlContent is asserting a schema
header that points to a feature branch ref
(refs/heads/tk/integrations-config-file-schema); update the YAML generator (the
code that produces the value asserted by yamlContent) to emit a stable schema
URL (for example using the main branch or a tagged release/commit SHA in the
raw.githubusercontent.com path instead of the feature-branch ref), then
regenerate/update the inline snapshots in the tests to match the new stable
header.
- Around line 210-243: Read the current .env using readDotEnv(envFilePath)
before calling updateDotEnv and assert that the CA secret key
AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__CACERTIFICATETEXT contains the certificate
value created earlier by the test flow (i.e., verify createIntegration persisted
the multiline cert); then proceed with updateDotEnv and the existing post-update
assertion to validate the roundtrip. Ensure you reference the readDotEnv and
updateDotEnv helpers and the env key
AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__CACERTIFICATETEXT when adding the
pre-update assertion.
---
Duplicate comments:
In
`@packages/cli/src/commands/integrations/tests/add-integration.clickhouse.test.ts`:
- Around line 183-205: The test adds a ClickHouse integration using
fillBaseFields() and verifies the YAML but misses asserting the generated .env
contents; after the existing await promise line in the test (the variable named
promise), read the created .env file (using the same filePath root or helper
used elsewhere) and assert it contains the expected environment variable mapping
for AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__PASSWORD => the plain password value
supplied by fillBaseFields(); update the test to include this .env assertion so
both the YAML env reference and the actual .env secret are verified.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts`:
- Around line 109-168: The test updates the integration password via interactive
prompts but never asserts the .env file content; add a check after awaiting
promise to read the env file (use envFilePath and readFile) and assert the env
variable is still present and unchanged (e.g., equals or contains
"ID001__PASSWORD=secret-pass\n") so the password env var wasn't corrupted or
duplicated by editIntegration; locate this assertion near the existing
yamlContent check in the 'updates host and database when user types new values'
test.
- Around line 170-247: In the test "adds SSH fields when SSH is enabled on a
plain integration" add a check that the .env file was not modified after running
editIntegration: after awaiting promise, read envFilePath (the .env variable
used in the test) and assert its contents still include
"ID001__PASSWORD=secret-pass" (or match the original .env string), ensuring
enabling SSH preserved the .env file; keep this assertion next to the existing
yamlContent assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 69dc3dae-a2aa-4559-a2fe-26771cb3e8c4
📒 Files selected for processing (6)
packages/cli/src/commands/integrations/tests/add-integration.clickhouse.test.tspackages/cli/src/commands/integrations/tests/add-integration.mindsdb.test.tspackages/cli/src/commands/integrations/tests/add-integration.mysql.test.tspackages/cli/src/commands/integrations/tests/add-integration.pgsql.test.tspackages/cli/src/commands/integrations/tests/add-integration.sql-server.test.tspackages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@packages/cli/src/commands/integrations/tests/edit-integration.dremio.test.ts`:
- Around line 43-95: Add an assertion to verify the .env file was preserved
after running editIntegration: after awaiting promise and reading yamlContent,
read the env file (envFilePath) and assert its contents still include the
original token line ("DR_ID_001__TOKEN=secret-token\n"); reference the test case
"edits dremio integration keeping all defaults" and the editIntegration call so
you place the new check after the existing YAML assertion to confirm .env
preservation.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.mindsdb.test.ts`:
- Around line 182-262: The test "adds SSH fields when SSH is enabled on a plain
integration" currently declines the "Enable SSL" prompt; update the test to also
enable SSL by answering 'y' to the "Enable SSL: (y/N)" prompt, fill in any
subsequent SSL-related prompts (e.g., certificate/CA path or verify toggle) via
screen.type + screen.keypress, and then update the final YAML assertion (the
inline snapshot) to include sslEnabled: true and the corresponding SSL metadata
fields added by editIntegration; reference the editIntegration invocation and
the final YAML snapshot in the test to locate where to change the interactions
and expected output.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: a2eeb10d-305c-4978-b6bc-3f1b9cf29cd4
📒 Files selected for processing (19)
packages/cli/src/commands/integrations/edit-integration.tspackages/cli/src/commands/integrations/tests/edit-integration.alloydb.test.tspackages/cli/src/commands/integrations/tests/edit-integration.athena.test.tspackages/cli/src/commands/integrations/tests/edit-integration.big-query.test.tspackages/cli/src/commands/integrations/tests/edit-integration.clickhouse.test.tspackages/cli/src/commands/integrations/tests/edit-integration.databricks.test.tspackages/cli/src/commands/integrations/tests/edit-integration.dremio.test.tspackages/cli/src/commands/integrations/tests/edit-integration.mariadb.test.tspackages/cli/src/commands/integrations/tests/edit-integration.materialize.test.tspackages/cli/src/commands/integrations/tests/edit-integration.mindsdb.test.tspackages/cli/src/commands/integrations/tests/edit-integration.mongodb.test.tspackages/cli/src/commands/integrations/tests/edit-integration.mysql.test.tspackages/cli/src/commands/integrations/tests/edit-integration.pgsql.test.tspackages/cli/src/commands/integrations/tests/edit-integration.redshift.test.tspackages/cli/src/commands/integrations/tests/edit-integration.snowflake.test.tspackages/cli/src/commands/integrations/tests/edit-integration.spanner.test.tspackages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.tspackages/cli/src/commands/integrations/tests/edit-integration.trino.test.tspackages/cli/src/utils/process-env.ts
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (1)
packages/cli/src/commands/integrations/tests/edit-integration.databricks.test.ts (1)
39-41:⚠️ Potential issue | 🟠 MajorAdd explicit global env cleanup in teardown.
Line 39-Line 41 removes files, but it does not clear
process.env.DB_ID_001__TOKEN(or similarDB_*__TOKENkeys). If any code path mutatesprocess.env, later tests can get false positives.Proposed fix
afterEach(async () => { + for (const key of Object.keys(process.env)) { + if (/^DB_.*__TOKEN$/.test(key)) { + delete process.env[key] + } + } await rm(tempDir, { recursive: true, force: true }) })Based on learnings, dotenv should only be read for metadata resolution and tests should prevent global
process.envside effects.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.databricks.test.ts` around lines 39 - 41, The afterEach teardown currently removes tempDir but doesn't clear mutated env vars; update the afterEach in edit-integration.databricks.test.ts to explicitly remove any process.env keys matching the Databricks token pattern (e.g., process.env.DB_ID_001__TOKEN or the /^DB_.*__TOKEN$/ pattern) after each test so later tests don't see leaked values; locate the afterEach block and add logic to iterate process.env keys that match that pattern and delete them (or restore any saved originals if you saved pre-test copies) to ensure global env is cleaned up between tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/cli/src/commands/integrations/tests/add-integration.mysql.test.ts`:
- Around line 78-251: Add a new test case to the MySQL integration tests that
exercises secrets with special characters (e.g. '=', '#', quotes,
leading/trailing spaces) to validate dotenv/YAML serialization; copy the pattern
from the existing "creates mysql integration with SSL enabled" test (use
createIntegration, fillBaseFields, screen flows to enable SSL and provide CA
fields), but supply a password and caCertificateText containing special
characters (or write the multiline/complex value directly via updateDotEnv),
then assert the written integrations YAML contains the env: ref and that
readDotEnv returns the exact original secret values (use updateDotEnv/readDotEnv
imported from ../../../utils/dotenv and the same mock UUID setup via
crypto.randomUUID to keep env var names stable).
- Around line 23-24: The temp directory name uses only Date.now(), which can
collide in parallel tests; update the tempDir creation in the
add-integration-mysql-test to append a unique random component (for example use
fs.mkdtemp with a prefix like join(tmpdir(), 'add-integration-mysql-test-') or
append process.pid + crypto.randomUUID()/Math.random()) instead of relying
solely on Date.now(), and keep the existing mkdir usage or remove it if using
mkdtemp which already creates the directory; update the tempDir variable
assignment accordingly so tests get isolated directories.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.databricks.test.ts`:
- Around line 43-268: Add two new tests in this file: one failing-path that
calls editIntegration({ file: filePath, envFile: envFilePath, id: 'unknown-id'
}) and asserts the CLI shows an appropriate error (or the promise rejects) when
the id is not found (use screen.next()/screen.getScreen() and expect
rejection/err message), and one special-character test that uses EXISTING_YAML
as base but types values containing YAML-significant characters (e.g., name:
"Prod: Databricks – v1", token with = and spaces or quotes, httpPath with
leading '|' or ':' and/or newline chars) via screen.type(...) through the edit
flow, then assert the resulting integrations.yaml and .env preserve/serialize
those special characters correctly (check both yamlContent and envContent).
Target the editIntegration flow and assertions already used in nearby tests to
locate insertion points.
---
Duplicate comments:
In
`@packages/cli/src/commands/integrations/tests/edit-integration.databricks.test.ts`:
- Around line 39-41: The afterEach teardown currently removes tempDir but
doesn't clear mutated env vars; update the afterEach in
edit-integration.databricks.test.ts to explicitly remove any process.env keys
matching the Databricks token pattern (e.g., process.env.DB_ID_001__TOKEN or the
/^DB_.*__TOKEN$/ pattern) after each test so later tests don't see leaked
values; locate the afterEach block and add logic to iterate process.env keys
that match that pattern and delete them (or restore any saved originals if you
saved pre-test copies) to ensure global env is cleaned up between tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 24918f95-eb00-4b93-b24a-dccc8062cfa7
📒 Files selected for processing (5)
packages/cli/src/commands/integrations/tests/add-integration.mysql.test.tspackages/cli/src/commands/integrations/tests/add-integration.spanner.test.tspackages/cli/src/commands/integrations/tests/edit-integration.databricks.test.tspackages/cli/src/commands/integrations/tests/edit-integration.dremio.test.tspackages/cli/src/commands/integrations/tests/edit-integration.snowflake.test.ts
There was a problem hiding this comment.
Actionable comments posted: 13
♻️ Duplicate comments (13)
packages/cli/src/commands/integrations/tests/add-integration.clickhouse.test.ts (1)
149-204:⚠️ Potential issue | 🟡 MinorStill missing
.envassertion for SSH-enabled ClickHouse path.Line 184+ verifies YAML, but the secret write to
.envis not validated in this branch.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.clickhouse.test.ts` around lines 149 - 204, The test for SSH-enabled ClickHouse currently asserts the YAML but doesn't verify the .env secret write; after awaiting promise and before/after reading yamlContent, read the envFilePath (use readFile(envFilePath, 'utf-8')) and assert it contains the generated env var key/value derived from mockUUID (the same env var referenced in YAML: AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__PASSWORD) so the secret was written; update the test that uses mockUUID, envFilePath, createIntegration, and readFile to include this .env content assertion.packages/cli/src/commands/integrations/tests/add-integration.sql-server.test.ts (1)
30-174:⚠️ Potential issue | 🟠 MajorPlease use
fillBaseFieldsoverrides for at least one special-char/error-path spec.Current SQL Server suite is success-only despite the helper already supporting variant inputs.
As per coding guidelines, "Test edge cases, error handling, and special characters in test files".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.sql-server.test.ts` around lines 30 - 174, Add a test that calls the existing helper fillBaseFields with an overrides object to exercise special characters / edge input (e.g., name containing symbols, host with uncommon chars, and a password with punctuation/whitespace) and assert the resulting integrations YAML and .env contain properly escaped/encoded values; update or add an it(...) in the SQL Server suite that uses fillBaseFields({ name: 'My DB `#1` — test', host: 'db.exämple.com', password: 'p@$$ word!'}), then run through the same steps (enable/disable SSH as desired) and include expectations that readFile(filePath, 'utf-8') and readFile(envFilePath, 'utf-8') match snapshots or contain the env ref with the exact special-char password to verify handling of special characters.packages/cli/src/commands/integrations/tests/add-integration.dremio.test.ts (1)
56-145:⚠️ Potential issue | 🟠 MajorCoverage remains happy-path only for Dremio add flow.
Please add negative/validation/special-character cases (e.g., invalid port, empty required fields, token with symbols).
As per coding guidelines, "Test edge cases, error handling, and special characters in test files".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.dremio.test.ts` around lines 56 - 145, The test file only covers the happy path for Dremio; add unit tests exercising validation and edge cases: create three new tests (e.g., "rejects invalid port", "rejects empty required fields", "handles token with special characters stored as env ref") that call createIntegration({ file, envFile }) and reuse the existing helpers/mockUUID/vi.spyOn(crypto, 'randomUUID') and fillBaseFields(); for the invalid-port test drive the interactive prompts via screen.type to supply a non-numeric or out-of-range port and assert the CLI shows a validation error or re-prompts (use screen.next()/screen.getScreen() expectations and assert the promise rejects or stalls as appropriate); for empty-required-fields simulate submitting blanks for required prompts (name/host/token) and assert validation messages; for special-character token type a token with symbols, ensure it is saved to the .env (envFilePath) and that the integrations YAML uses the env:<KEY> ref as in existing tests.packages/cli/src/commands/integrations/tests/add-integration.big-query.test.ts (1)
25-136:⚠️ Potential issue | 🟠 MajorBigQuery tests still miss failure-path coverage.
Add cases for invalid service-account JSON, missing required OAuth fields, and special-character inputs.
As per coding guidelines, "Test edge cases, error handling, and special characters in test files".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.big-query.test.ts` around lines 25 - 136, The test suite add-integration.big-query.test.ts lacks negative and edge-case coverage; add new tests alongside the existing "creates big-query integration..." cases that call createIntegration to verify failure behavior for (1) invalid Service Account JSON (e.g., malformed JSON) by asserting the command fails and no files are written, (2) missing required Google OAuth fields (omit project, clientId, or clientSecret one at a time) by asserting the CLI shows validation errors and exits non-zero, and (3) inputs containing special characters (e.g., quotes, newlines, env-key-unfriendly chars) to ensure env file escaping and YAML generation handle them; reference the existing test helpers/screen interactions and the createIntegration promise pattern so the new tests reuse screen.type(), screen.keypress(), await screen.next(), and readFile assertions to confirm correct error messages or properly escaped outputs.packages/cli/src/commands/integrations/tests/add-integration.spanner.test.ts (1)
25-126:⚠️ Potential issue | 🟠 MajorDrive a JSON-shaped service account through the CLI.
Right now the suite types a plain placeholder, then tests multiline handling by calling
updateDotEnv()directly. That proves the dotenv helper, not the add flow. Please add one prompt-driven case with quotes / escaped newlines in the service-account JSON, plus an empty or invalid submission if this field is validated.As per coding guidelines "Test edge cases, error handling, and special characters in test files".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.spanner.test.ts` around lines 25 - 126, Add a new prompt-driven test case that exercises entering a JSON-shaped service account containing quotes and escaped newlines via the interactive flow: call createIntegration(...) and use fillBaseFields() but when the prompt for "Service Account (JSON):" appears use screen.type to enter a quoted JSON string with escaped newlines and quotes (e.g. "{\"private_key\":\"line1\\nline2\",\"client_email\":\"x@example.com\"}") and submit; then await the promise, read the written env file (readFile or readDotEnv) and assert the env var value equals the exact escaped string stored by the CLI, and also add a second sub-case that submits an empty/invalid value to assert validation behavior (expect an error message or retry prompt) so the interactive validation for the service account field is covered; reference fillBaseFields, createIntegration, screen.type, readDotEnv/updateDotEnv in your test additions.packages/cli/src/commands/integrations/tests/add-integration.redshift.test.ts (1)
50-212:⚠️ Potential issue | 🟠 MajorExercise the SSH and SSL branches too.
The Redshift prompt appends SSH and SSL after auth selection, but every scenario here declines both. Please add at least one SSH-enabled and one SSL-enabled flow so the new shared-field wiring is covered.
As per coding guidelines "Create comprehensive tests for all new features using Vitest".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.redshift.test.ts` around lines 50 - 212, The tests never exercise the SSH/SSL branches; update the Redshift test cases that call createIntegration and use screen.next/screen.keypress so at least one flow answers 'y' to the "Enable SSH tunnel" prompt and another answers 'y' to the "Enable SSL" prompt. Concretely, modify one of the flows (e.g., the IAM-role test) to press 'y' when the SSH prompt appears and adjust its yamlContent snapshot to include the SSH-related metadata field(s) emitted by the code (look for metadata keys in the output produced by createIntegration), and modify a different flow (e.g., the individual-credentials test) to press 'y' for the SSL prompt and update that test's yamlContent snapshot to include the SSL-related metadata field(s); keep the existing username/password test unchanged. Ensure you still call fillBaseFields, await promise, and update any expected envContent snapshots if enabling SSH/SSL changes environment variable output.packages/cli/src/commands/integrations/tests/add-integration.mariadb.test.ts (1)
77-237:⚠️ Potential issue | 🟠 MajorAdd a validation case and an escaping case.
These three tests are still happy-path only. Please add one invalid-port-then-corrected flow and one password /
caCertificateTextcase with quotes or newlines so the shared prompt +.envserialization path is exercised under failure and escaping.As per coding guidelines "Test edge cases, error handling, and special characters in test files".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.mariadb.test.ts` around lines 77 - 237, Add two tests to the existing suite that use the same helpers (createIntegration, fillBaseFields, screen, tempDir, readFile) and mocked UUID (vi.spyOn(crypto, 'randomUUID')). First test: "invalid port then corrected" — start createIntegration, fillBaseFields, when prompted for "Enable SSH tunnel:" skip, at "Enable SSL:" skip, at "Port:" type an invalid value like "not-a-number", assert the interactive prompt shows a validation/error message, then type the corrected numeric port "3306" and proceed; finally assert the YAML contains port: "3306" and .env unchanged. Second test: "password and caCertificateText with special chars" — createIntegration, fillBaseFields, skip SSH, enable SSL, for "CA Certificate:" provide a value with quotes and newlines (e.g. "line1\n\"quoted\" line2"), and for the password field input a value containing quotes/newlines as well when prompted; await completion and assert the YAML references env vars (env:UUID__PASSWORD and env:UUID__CACERTIFICATETEXT) and the .env file contains the exact password and the multi-line/quoted certificate value preserved/escaped correctly (including literal newlines), so the shared prompt + .env serialization path is exercised under escaping and special characters.packages/cli/src/commands/integrations/tests/edit-integration.athena.test.ts (1)
96-150: 🧹 Nitpick | 🔵 TrivialAdd workgroup persistence test.
Both tests leave workgroup empty. Add a case that enters a workgroup value and verifies it persists.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.athena.test.ts` around lines 96 - 150, The test suite is missing a case that verifies the Workgroup field is persisted; add a new test (or extend the existing 'updates region when user types new value' test) that types a non-empty workgroup before submitting and then asserts the written YAML includes metadata.workgroup with the entered value. Locate the editIntegration invocation and the screen interactions (screen.next(), screen.type(...), screen.keypress('enter')) and add a step after the "Workgroup:" prompt to screen.type('my-workgroup') and press enter, then read the file (readFile(filePath, 'utf-8')) and include an expect that the YAML contains workgroup: my-workgroup for the integration with id 'ath-id-001' (using EXISTING_YAML fixture and same file/env setup).packages/cli/src/commands/integrations/tests/edit-integration.mariadb.test.ts (1)
175-255: 🧹 Nitpick | 🔵 TrivialAdd SSL enablement coverage.
SSH is tested. SSL toggle (
Enable SSL: (y/N)→y) is missing. Add a test case.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.mariadb.test.ts` around lines 175 - 255, The test "adds SSH fields when SSH is enabled on a plain integration" is missing coverage for the SSL prompt — update the test in edit-integration.mariadb.test.ts to answer the "Enable SSL: (y/N)" prompt with "y" (use screen.type('y') and screen.keypress('enter')) after the SSH prompts, then update the final YAML assertion (the inline snapshot) to include the expected SSL metadata (e.g., add sslEnabled: true under metadata or whatever the integration code writes when SSL is enabled) so the snapshot reflects enabling SSL.packages/cli/src/commands/integrations/tests/add-integration.trino.test.ts (1)
182-259: 🧹 Nitpick | 🔵 TrivialAdd an SSL-enabled test case.
SSH is covered. SSL enablement (
Enable SSL: (y/N)→y) is not. Add a test to verify SSL fields persist.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/add-integration.trino.test.ts` around lines 182 - 259, Add a new test (e.g., "creates trino integration with SSH tunnel and SSL enabled") next to the existing creates trino integration with SSH tunnel enabled test that follows the same flow (calls createIntegration, awaits fillBaseFields, navigates prompts) but answers the "Enable SSL: (y/N)" prompt with "y" and fills any additional SSL prompts that follow; then await the promise and assert the resulting YAML and .env include SSL-specific fields (e.g., sslEnabled: true and any ssl certificate/key/config entries) and still include the SSH fields. Reference the existing test's use of createIntegration, fillBaseFields, the "Enable SSL: (y/N)" prompt, and the final YAML/env assertions as the pattern to replicate.packages/cli/src/commands/integrations/tests/edit-integration.clickhouse.test.ts (1)
111-174: 🧹 Nitpick | 🔵 TrivialAdd SSH and SSL enablement tests.
ClickHouse supports both SSH tunnel and SSL. Current tests decline both. Add coverage for enabling each.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.clickhouse.test.ts` around lines 111 - 174, The test currently declines SSH and SSL; update the interactive steps in the 'updates host when user types new value' test (the editIntegration flow using promise, screen, and EXISTING_YAML) to accept both prompts by replacing the two screen.keypress('enter') calls for "Enable SSH tunnel: (y/N)" and "Enable SSL: (y/N)" with screen.type('y') followed by screen.keypress('enter') for each, and then update the final YAML assertion (the yamlContent / inline snapshot) to include the corresponding metadata flags (e.g., add metadata.ssh_tunnel: "true" and metadata.ssl: "true" or the project's canonical field names for SSH/SSL) so the snapshot/assert matches the enabled options.packages/cli/src/commands/integrations/tests/edit-integration.alloydb.test.ts (1)
175-256: 🧹 Nitpick | 🔵 TrivialMissing SSL-enabled edit scenario.
SSH is covered; add a test enabling SSL and asserting
sslEnabled: trueplus certificate fields in the output YAML.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.alloydb.test.ts` around lines 175 - 256, Add a new test alongside the existing "adds SSH fields when SSH is enabled on a plain integration" that exercises enabling SSL: call editIntegration (same as the SSH test), drive the interactive prompts to answer the SSL question with "y" and provide certificate-related values (e.g., client cert, client key, ca cert or whatever prompts the CLI shows), then await the promise and assert the resulting YAML (readFile(filePath, 'utf-8')) includes sslEnabled: true and the expected certificate fields under metadata. Reuse EXISTING_YAML, tempDir, envFilePath setup and the screen interaction pattern from the SSH test to locate where to inject the SSL responses and add the inline snapshot/assertion for the sslEnabled and cert fields.packages/cli/src/commands/integrations/tests/edit-integration.mysql.test.ts (1)
175-256: 🧹 Nitpick | 🔵 TrivialMissing SSL-enabled edit scenario.
Same gap as AlloyDB/MindsDB tests.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.mysql.test.ts` around lines 175 - 256, Add a new test in edit-integration.mysql.test.ts (similar to the existing "adds SSH fields..." test) that exercises enabling SSL: call editIntegration with the same EXISTING_YAML and env file, use screen to accept defaults until the "Enable SSL: (y/N)" prompt, type 'y' and fill any SSL-specific prompts (e.g., sslMode or sslCert fields if present), await the promise, then read yamlContent and add an inline snapshot asserting the resulting YAML contains SSL-enabled fields (e.g., sslEnabled: true and any ssl* entries). Use the same test helpers and symbols: editIntegration, EXISTING_YAML, screen, yamlContent and expect(...).toMatchInlineSnapshot to mirror the AlloyDB/MindsDB SSL-enabled tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@packages/cli/src/commands/integrations/tests/add-integration.alloydb.test.ts`:
- Around line 119-173: In the "creates alloydb integration with SSH tunnel
enabled" test, add an assertion that reads the env file at envFilePath (using
readFile(envFilePath, 'utf-8')) and verifies the secret was written—e.g. that
the generated key AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__PASSWORD (matching the
mocked crypto.randomUUID) and its value are present—so the test fails if the SSH
branch omits writing to the .env; place this check after awaiting promise and
before or alongside the YAML snapshot assertion to mirror the other tests
(createIntegration, fillBaseFields, promise, filePath, envFilePath).
In
`@packages/cli/src/commands/integrations/tests/add-integration.databricks.test.ts`:
- Around line 138-188: The test for SSH-enabled Databricks integration checks
only the generated YAML but misses asserting the .env file output; update the
test (in create databricks integration with SSH tunnel enabled) to read the env
file at envFilePath (use readFile(envFilePath, 'utf-8')) after await promise and
assert it contains the expected env var entry whose name is derived from the
mocked UUID (mockUUID) and shown in the YAML as
AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__TOKEN (or the exact env var string used by
the code), so add an expect on that env content to catch token-write
regressions.
In
`@packages/cli/src/commands/integrations/tests/add-integration.materialize.test.ts`:
- Around line 73-200: Add tests for Materialize flow to cover invalid-port
validation, required-field retry/abort, and special-character inputs: in the
test suite around createIntegration and fillBaseFields add one test that types
an invalid port (e.g., "not-a-number") via screen.type, asserts the
validation/error prompt is shown, then corrects it and completes the flow
(assert YAML contains corrected "port"); add a test that leaves a required field
blank (e.g., host or user), assert the CLI reprompts and test both retry
(provide valid value) and abort (simulate ctrl+c or appropriate abort key and
assert no file written); add a test that uses special characters in
name/password (e.g., spaces, punctuation, unicode) and verify the written
integrations YAML and .env preserve/escape those characters correctly. Target
functions/objects: createIntegration, fillBaseFields, screen, readFile and the
test cases named 'creates materialize integration...' to place these new
assertions.
In
`@packages/cli/src/commands/integrations/tests/add-integration.mongodb.test.ts`:
- Around line 98-253: The tests are missing a case that enables SSL for MongoDB;
add a new "creates mongodb integration with SSL enabled" test in the same file
that uses createIntegration({ file, envFile }), calls fillMongoCredentials(),
then simulates enabling SSL via the shared prompts (use screen to answer 'y' on
the "Enable SSL" prompt instead of declineSshAndSsl()), awaits the promise, and
then assert that the written YAML (readFile) contains the ssl-related metadata
fields (e.g., sslEnabled/sslCert/sslKey or whatever the schema uses) and that
the .env contains the corresponding cert/key env variables; reuse helpers
already in the file (fillMongoCredentials, createIntegration, screen, tempDir,
readFile) and mirror the structure of the existing SSH test for consistency.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.athena.test.ts`:
- Around line 42-94: Add an assertion that the .env file contains the expected
secret after running the test: read envFilePath (the variable in this test) and
assert it equals "ATH_ID_001__SECRET_ACCESS_KEY=secret-key\n" (or contains that
line) after awaiting promise in the "edits athena integration keeping all
defaults" test; reference the test variables filePath, envFilePath,
EXISTING_YAML and the env var key ATH_ID_001__SECRET_ACCESS_KEY to locate where
to add the check.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.big-query.test.ts`:
- Around line 148-152: The test currently asserts env contents but doesn't
document that switching auth to OAuth leaves the previous
BQ_ID_001__SERVICE_ACCOUNT env var in the file due to append-only behavior;
update the test by either renaming the test case (in
edit-integration.big-query.test.ts) to explicitly state "append-only: stale
SERVICE_ACCOUNT remains after switching to OAuth" or add a concise inline
comment above the expect(envContent) assertion explaining that the
BQ_ID_001__SERVICE_ACCOUNT is intentionally retained and not removed when
switching auth methods.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.databricks.test.ts`:
- Around line 42-268: Tests only cover happy paths for editIntegration; add at
least one error-path test and one edge-case test. Create a new test that calls
editIntegration({ file, envFile, id: 'non-existent-id' }) and asserts the CLI
shows an appropriate error message or the promise rejects (check behavior of
editIntegration) to cover unknown id handling; create another test that uses
EXISTING_YAML but writes an env value and HTTP Path containing special
characters (e.g., spaces, slashes, symbols) and assert the written
integrations.yaml and .env preserve/escape them correctly (reference the
existing tests' use of editIntegration, EXISTING_YAML, tempDir, and
DB_ID_001__TOKEN to locate where to add these cases).
In
`@packages/cli/src/commands/integrations/tests/edit-integration.materialize.test.ts`:
- Around line 113-176: The test edits the Materialize integration but doesn't
assert the .env file contents; after awaiting promise (the editIntegration call)
add a check that reads envFilePath (use readFile(envFilePath, 'utf-8')) and
expect the returned string to contain the original secret key/value (e.g.,
expect(envContent).toContain('MZ_ID_001__PASSWORD=secret-pass')) to ensure the
.env entry is present/unchanged.
- Around line 49-111: The test edits the Materialize integration but never
asserts the .env file contents; after awaiting promise and reading yamlContent,
also read the envFilePath (using readFile(envFilePath, 'utf-8')) and assert its
content includes the expected environment variable line
"MZ_ID_001__PASSWORD=secret-pass\n" (or use toMatchInlineSnapshot/toEqual like
the other tests) so the test verifies the env-backed password was written/kept
correctly; reference variables: editIntegration, envFilePath, EXISTING_YAML,
MZ_ID_001__PASSWORD.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.mindsdb.test.ts`:
- Around line 181-261: The test for SSH in edit-integration.mindsdb.test.ts
exercises SSH but always declines SSL; update or add a test case that, after
answering the 'Enable SSL: (y/N)' prompt, types 'y' and completes the flow, then
assert that the written YAML (read from filePath) contains the SSL-related
metadata keys (e.g., sslEnabled: true and caCertificateName or other SSL fields
your integration writes). Locate the interactive flow driven by
editIntegration({ file: filePath, envFile: envFilePath, id: 'id-001' }) and the
sequence that reaches the 'Enable SSL: (y/N)' prompt, change the
screen.keypress/keyboard input to enter 'y' and any subsequent SSL inputs, then
add assertions against yamlContent (the variable already used) to verify
sslEnabled and the expected SSL metadata are present.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.spanner.test.ts`:
- Around line 42-90: Add an assertion to verify the .env file contains the
expected env-backed service account after editIntegration completes: after
awaiting promise and before/after reading yamlContent, read envFilePath (the
.env created earlier) and assert it includes the line
"SP_ID_001__SERVICE_ACCOUNT=service-account-data" to ensure the test checks both
YAML and env file updates for the Service Account; locate this near the existing
assertions in the test case that uses editIntegration, filePath, envFilePath,
and EXISTING_YAML.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts`:
- Around line 112-171: The test "updates host and database when user types new
values" updates the YAML to use an env-backed password but doesn't assert the
.env file contents; after awaiting promise and before or after asserting
yamlContent, read the envFilePath (envFilePath variable) and assert its contents
include the expected line "ID001__PASSWORD=secret-pass" (or exact string used in
the other test) to mirror the first test's .env assertion, referencing the
existing envFilePath variable and the editIntegration invocation to locate where
to add the check.
- Around line 173-250: The test "it adds SSH fields when SSH is enabled on a
plain integration" doesn't assert the .env file after running editIntegration;
add a check after awaiting promise that reads envFilePath (use
readFile(envFilePath, 'utf-8')) and assert it contains the expected secret line
(e.g., expect(envContent).toContain('ID001__PASSWORD=secret-pass') or an inline
snapshot) so the test verifies the .env was written/unchanged as expected.
---
Duplicate comments:
In
`@packages/cli/src/commands/integrations/tests/add-integration.big-query.test.ts`:
- Around line 25-136: The test suite add-integration.big-query.test.ts lacks
negative and edge-case coverage; add new tests alongside the existing "creates
big-query integration..." cases that call createIntegration to verify failure
behavior for (1) invalid Service Account JSON (e.g., malformed JSON) by
asserting the command fails and no files are written, (2) missing required
Google OAuth fields (omit project, clientId, or clientSecret one at a time) by
asserting the CLI shows validation errors and exits non-zero, and (3) inputs
containing special characters (e.g., quotes, newlines, env-key-unfriendly chars)
to ensure env file escaping and YAML generation handle them; reference the
existing test helpers/screen interactions and the createIntegration promise
pattern so the new tests reuse screen.type(), screen.keypress(), await
screen.next(), and readFile assertions to confirm correct error messages or
properly escaped outputs.
In
`@packages/cli/src/commands/integrations/tests/add-integration.clickhouse.test.ts`:
- Around line 149-204: The test for SSH-enabled ClickHouse currently asserts the
YAML but doesn't verify the .env secret write; after awaiting promise and
before/after reading yamlContent, read the envFilePath (use
readFile(envFilePath, 'utf-8')) and assert it contains the generated env var
key/value derived from mockUUID (the same env var referenced in YAML:
AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__PASSWORD) so the secret was written;
update the test that uses mockUUID, envFilePath, createIntegration, and readFile
to include this .env content assertion.
In `@packages/cli/src/commands/integrations/tests/add-integration.dremio.test.ts`:
- Around line 56-145: The test file only covers the happy path for Dremio; add
unit tests exercising validation and edge cases: create three new tests (e.g.,
"rejects invalid port", "rejects empty required fields", "handles token with
special characters stored as env ref") that call createIntegration({ file,
envFile }) and reuse the existing helpers/mockUUID/vi.spyOn(crypto,
'randomUUID') and fillBaseFields(); for the invalid-port test drive the
interactive prompts via screen.type to supply a non-numeric or out-of-range port
and assert the CLI shows a validation error or re-prompts (use
screen.next()/screen.getScreen() expectations and assert the promise rejects or
stalls as appropriate); for empty-required-fields simulate submitting blanks for
required prompts (name/host/token) and assert validation messages; for
special-character token type a token with symbols, ensure it is saved to the
.env (envFilePath) and that the integrations YAML uses the env:<KEY> ref as in
existing tests.
In
`@packages/cli/src/commands/integrations/tests/add-integration.mariadb.test.ts`:
- Around line 77-237: Add two tests to the existing suite that use the same
helpers (createIntegration, fillBaseFields, screen, tempDir, readFile) and
mocked UUID (vi.spyOn(crypto, 'randomUUID')). First test: "invalid port then
corrected" — start createIntegration, fillBaseFields, when prompted for "Enable
SSH tunnel:" skip, at "Enable SSL:" skip, at "Port:" type an invalid value like
"not-a-number", assert the interactive prompt shows a validation/error message,
then type the corrected numeric port "3306" and proceed; finally assert the YAML
contains port: "3306" and .env unchanged. Second test: "password and
caCertificateText with special chars" — createIntegration, fillBaseFields, skip
SSH, enable SSL, for "CA Certificate:" provide a value with quotes and newlines
(e.g. "line1\n\"quoted\" line2"), and for the password field input a value
containing quotes/newlines as well when prompted; await completion and assert
the YAML references env vars (env:UUID__PASSWORD and
env:UUID__CACERTIFICATETEXT) and the .env file contains the exact password and
the multi-line/quoted certificate value preserved/escaped correctly (including
literal newlines), so the shared prompt + .env serialization path is exercised
under escaping and special characters.
In
`@packages/cli/src/commands/integrations/tests/add-integration.redshift.test.ts`:
- Around line 50-212: The tests never exercise the SSH/SSL branches; update the
Redshift test cases that call createIntegration and use
screen.next/screen.keypress so at least one flow answers 'y' to the "Enable SSH
tunnel" prompt and another answers 'y' to the "Enable SSL" prompt. Concretely,
modify one of the flows (e.g., the IAM-role test) to press 'y' when the SSH
prompt appears and adjust its yamlContent snapshot to include the SSH-related
metadata field(s) emitted by the code (look for metadata keys in the output
produced by createIntegration), and modify a different flow (e.g., the
individual-credentials test) to press 'y' for the SSL prompt and update that
test's yamlContent snapshot to include the SSL-related metadata field(s); keep
the existing username/password test unchanged. Ensure you still call
fillBaseFields, await promise, and update any expected envContent snapshots if
enabling SSH/SSL changes environment variable output.
In
`@packages/cli/src/commands/integrations/tests/add-integration.spanner.test.ts`:
- Around line 25-126: Add a new prompt-driven test case that exercises entering
a JSON-shaped service account containing quotes and escaped newlines via the
interactive flow: call createIntegration(...) and use fillBaseFields() but when
the prompt for "Service Account (JSON):" appears use screen.type to enter a
quoted JSON string with escaped newlines and quotes (e.g.
"{\"private_key\":\"line1\\nline2\",\"client_email\":\"x@example.com\"}") and
submit; then await the promise, read the written env file (readFile or
readDotEnv) and assert the env var value equals the exact escaped string stored
by the CLI, and also add a second sub-case that submits an empty/invalid value
to assert validation behavior (expect an error message or retry prompt) so the
interactive validation for the service account field is covered; reference
fillBaseFields, createIntegration, screen.type, readDotEnv/updateDotEnv in your
test additions.
In
`@packages/cli/src/commands/integrations/tests/add-integration.sql-server.test.ts`:
- Around line 30-174: Add a test that calls the existing helper fillBaseFields
with an overrides object to exercise special characters / edge input (e.g., name
containing symbols, host with uncommon chars, and a password with
punctuation/whitespace) and assert the resulting integrations YAML and .env
contain properly escaped/encoded values; update or add an it(...) in the SQL
Server suite that uses fillBaseFields({ name: 'My DB `#1` — test', host:
'db.exämple.com', password: 'p@$$ word!'}), then run through the same steps
(enable/disable SSH as desired) and include expectations that readFile(filePath,
'utf-8') and readFile(envFilePath, 'utf-8') match snapshots or contain the env
ref with the exact special-char password to verify handling of special
characters.
In `@packages/cli/src/commands/integrations/tests/add-integration.trino.test.ts`:
- Around line 182-259: Add a new test (e.g., "creates trino integration with SSH
tunnel and SSL enabled") next to the existing creates trino integration with SSH
tunnel enabled test that follows the same flow (calls createIntegration, awaits
fillBaseFields, navigates prompts) but answers the "Enable SSL: (y/N)" prompt
with "y" and fills any additional SSL prompts that follow; then await the
promise and assert the resulting YAML and .env include SSL-specific fields
(e.g., sslEnabled: true and any ssl certificate/key/config entries) and still
include the SSH fields. Reference the existing test's use of createIntegration,
fillBaseFields, the "Enable SSL: (y/N)" prompt, and the final YAML/env
assertions as the pattern to replicate.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.alloydb.test.ts`:
- Around line 175-256: Add a new test alongside the existing "adds SSH fields
when SSH is enabled on a plain integration" that exercises enabling SSL: call
editIntegration (same as the SSH test), drive the interactive prompts to answer
the SSL question with "y" and provide certificate-related values (e.g., client
cert, client key, ca cert or whatever prompts the CLI shows), then await the
promise and assert the resulting YAML (readFile(filePath, 'utf-8')) includes
sslEnabled: true and the expected certificate fields under metadata. Reuse
EXISTING_YAML, tempDir, envFilePath setup and the screen interaction pattern
from the SSH test to locate where to inject the SSL responses and add the inline
snapshot/assertion for the sslEnabled and cert fields.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.athena.test.ts`:
- Around line 96-150: The test suite is missing a case that verifies the
Workgroup field is persisted; add a new test (or extend the existing 'updates
region when user types new value' test) that types a non-empty workgroup before
submitting and then asserts the written YAML includes metadata.workgroup with
the entered value. Locate the editIntegration invocation and the screen
interactions (screen.next(), screen.type(...), screen.keypress('enter')) and add
a step after the "Workgroup:" prompt to screen.type('my-workgroup') and press
enter, then read the file (readFile(filePath, 'utf-8')) and include an expect
that the YAML contains workgroup: my-workgroup for the integration with id
'ath-id-001' (using EXISTING_YAML fixture and same file/env setup).
In
`@packages/cli/src/commands/integrations/tests/edit-integration.clickhouse.test.ts`:
- Around line 111-174: The test currently declines SSH and SSL; update the
interactive steps in the 'updates host when user types new value' test (the
editIntegration flow using promise, screen, and EXISTING_YAML) to accept both
prompts by replacing the two screen.keypress('enter') calls for "Enable SSH
tunnel: (y/N)" and "Enable SSL: (y/N)" with screen.type('y') followed by
screen.keypress('enter') for each, and then update the final YAML assertion (the
yamlContent / inline snapshot) to include the corresponding metadata flags
(e.g., add metadata.ssh_tunnel: "true" and metadata.ssl: "true" or the project's
canonical field names for SSH/SSL) so the snapshot/assert matches the enabled
options.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.mariadb.test.ts`:
- Around line 175-255: The test "adds SSH fields when SSH is enabled on a plain
integration" is missing coverage for the SSL prompt — update the test in
edit-integration.mariadb.test.ts to answer the "Enable SSL: (y/N)" prompt with
"y" (use screen.type('y') and screen.keypress('enter')) after the SSH prompts,
then update the final YAML assertion (the inline snapshot) to include the
expected SSL metadata (e.g., add sslEnabled: true under metadata or whatever the
integration code writes when SSL is enabled) so the snapshot reflects enabling
SSL.
In `@packages/cli/src/commands/integrations/tests/edit-integration.mysql.test.ts`:
- Around line 175-256: Add a new test in edit-integration.mysql.test.ts (similar
to the existing "adds SSH fields..." test) that exercises enabling SSL: call
editIntegration with the same EXISTING_YAML and env file, use screen to accept
defaults until the "Enable SSL: (y/N)" prompt, type 'y' and fill any
SSL-specific prompts (e.g., sslMode or sslCert fields if present), await the
promise, then read yamlContent and add an inline snapshot asserting the
resulting YAML contains SSL-enabled fields (e.g., sslEnabled: true and any ssl*
entries). Use the same test helpers and symbols: editIntegration, EXISTING_YAML,
screen, yamlContent and expect(...).toMatchInlineSnapshot to mirror the
AlloyDB/MindsDB SSL-enabled tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: f6278ddd-e36a-4842-b03b-71d9984043a2
📒 Files selected for processing (35)
packages/cli/src/commands/integrations.test.tspackages/cli/src/commands/integrations/edit-integration.test.tspackages/cli/src/commands/integrations/tests/add-integration.alloydb.test.tspackages/cli/src/commands/integrations/tests/add-integration.athena.test.tspackages/cli/src/commands/integrations/tests/add-integration.big-query.test.tspackages/cli/src/commands/integrations/tests/add-integration.clickhouse.test.tspackages/cli/src/commands/integrations/tests/add-integration.databricks.test.tspackages/cli/src/commands/integrations/tests/add-integration.dremio.test.tspackages/cli/src/commands/integrations/tests/add-integration.mariadb.test.tspackages/cli/src/commands/integrations/tests/add-integration.materialize.test.tspackages/cli/src/commands/integrations/tests/add-integration.mindsdb.test.tspackages/cli/src/commands/integrations/tests/add-integration.mongodb.test.tspackages/cli/src/commands/integrations/tests/add-integration.mysql.test.tspackages/cli/src/commands/integrations/tests/add-integration.pgsql.test.tspackages/cli/src/commands/integrations/tests/add-integration.redshift.test.tspackages/cli/src/commands/integrations/tests/add-integration.spanner.test.tspackages/cli/src/commands/integrations/tests/add-integration.sql-server.test.tspackages/cli/src/commands/integrations/tests/add-integration.trino.test.tspackages/cli/src/commands/integrations/tests/edit-integration.alloydb.test.tspackages/cli/src/commands/integrations/tests/edit-integration.athena.test.tspackages/cli/src/commands/integrations/tests/edit-integration.big-query.test.tspackages/cli/src/commands/integrations/tests/edit-integration.clickhouse.test.tspackages/cli/src/commands/integrations/tests/edit-integration.databricks.test.tspackages/cli/src/commands/integrations/tests/edit-integration.dremio.test.tspackages/cli/src/commands/integrations/tests/edit-integration.mariadb.test.tspackages/cli/src/commands/integrations/tests/edit-integration.materialize.test.tspackages/cli/src/commands/integrations/tests/edit-integration.mindsdb.test.tspackages/cli/src/commands/integrations/tests/edit-integration.mongodb.test.tspackages/cli/src/commands/integrations/tests/edit-integration.mysql.test.tspackages/cli/src/commands/integrations/tests/edit-integration.pgsql.test.tspackages/cli/src/commands/integrations/tests/edit-integration.redshift.test.tspackages/cli/src/commands/integrations/tests/edit-integration.snowflake.test.tspackages/cli/src/commands/integrations/tests/edit-integration.spanner.test.tspackages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.tspackages/cli/src/commands/integrations/tests/edit-integration.trino.test.ts
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (4)
packages/cli/src/commands/integrations/tests/edit-integration.mindsdb.test.ts (1)
48-267:⚠️ Potential issue | 🟠 MajorCoverage is still happy-path heavy; add edge/error/special-char cases (including SSL-enabled path).
This suite currently validates normal flows, but it still misses required edge/error coverage (e.g., invalid port input, empty required fields, missing env file/password var, special characters) and a positive SSL path assertion.
As per coding guidelines "
**/*.test.{ts,tsx}: Create comprehensive tests for all new features using Vitest" and "**/*.test.{ts,tsx}: Test edge cases, error handling, and special characters in test files".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.mindsdb.test.ts` around lines 48 - 267, Add new Vitest cases in this test file around the existing edit-integration.mindsdb.test.ts suite to cover error and edge scenarios: (1) a test using editIntegration where the user enters an invalid port (non-numeric/out-of-range) and assert validation/failure behavior; (2) a test where required fields (e.g., Database or User) are cleared and assert the CLI prompts/error handling; (3) a test where the .env file is missing or the ID001__PASSWORD variable is absent and assert password handling/error; (4) a test that enters special characters/unicode in name/host/database to ensure correct YAML escaping; and (5) a positive SSL-enabled path that chooses Enable SSL: (y/N) => y and asserts ssl-related metadata written. Use the same helpers and symbols from this file (editIntegration, EXISTING_YAML, filePath/envFilePath/tempDir, screen, promise) so tests integrate with the existing flow and assertions.packages/cli/src/commands/integrations/tests/edit-integration.spanner.test.ts (1)
42-150:⚠️ Potential issue | 🟠 MajorAdd
process.envisolation assertions in both edit-flow tests.Line 49 and Line 105 invoke
editIntegration, but neither test verifies global env immutability. Add an env snapshot before invocation and assert unchanged afterawait promise.Suggested patch
it('edits spanner integration keeping all defaults', async () => { const filePath = join(tempDir, 'integrations.yaml') const envFilePath = join(tempDir, '.env') + const originalEnv = { ...process.env } await writeFile(filePath, EXISTING_YAML) await writeFile(envFilePath, 'SP_ID_001__SERVICE_ACCOUNT=service-account-data\n') const promise = editIntegration({ file: filePath, envFile: envFilePath, id: 'sp-id-001' }) @@ await promise + expect(process.env).toEqual(originalEnv) const yamlContent = await readFile(filePath, 'utf-8') expect(yamlContent).toMatchInlineSnapshot(` @@ it('updates instance and enables data boost', async () => { const filePath = join(tempDir, 'integrations.yaml') const envFilePath = join(tempDir, '.env') + const originalEnv = { ...process.env } await writeFile(filePath, EXISTING_YAML) await writeFile(envFilePath, 'SP_ID_001__SERVICE_ACCOUNT=service-account-data\n') const promise = editIntegration({ file: filePath, envFile: envFilePath, id: 'sp-id-001' }) @@ await promise + expect(process.env).toEqual(originalEnv) const yamlContent = await readFile(filePath, 'utf-8') expect(yamlContent).toMatchInlineSnapshot(`Based on learnings: "Do not load dotenv into process.env during the CLI integrations edit flow. dotenv should only be read to resolve environment variable references in the integration metadata, not applied to the global runtime environment. In tests, avoid side effects by mocking dotenv or isolating environment loading so process.env remains unchanged during edit integration tests."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.spanner.test.ts` around lines 42 - 150, Capture a shallow snapshot of process.env before calling editIntegration in both tests (the ones that create promise = editIntegration({...})), then after await promise assert that process.env matches the snapshot to ensure the edit flow did not mutate global env; update the two tests in edit-integration.spanner.test.ts to save const envBefore = { ...process.env } immediately before invoking editIntegration and add expect(process.env).toEqual(envBefore) right after await promise (or use a deep-equality matcher), keeping references to editIntegration and the promise variable to locate the change.packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts (2)
14-16:⚠️ Potential issue | 🟠 MajorTests can still miss dotenv →
process.envregressions.Line 14-16 stubs
getProcessEnv, and Line 38-46 does not snapshot/restoreprocess.env. A direct dotenv load ineditIntegrationcould leak env state and this suite would not assert against it.Suggested hardening
describe('edit-integration sql-server', () => { let tempDir: string + let passwordEnvSnapshot: string | undefined @@ beforeEach(async () => { vi.clearAllMocks() vi.restoreAllMocks() + passwordEnvSnapshot = process.env.ID001__PASSWORD + delete process.env.ID001__PASSWORD tempDir = await mkdtemp(join(tmpdir(), 'edit-integration-sql-server-test-')) }) afterEach(async () => { + if (passwordEnvSnapshot === undefined) { + delete process.env.ID001__PASSWORD + } else { + process.env.ID001__PASSWORD = passwordEnvSnapshot + } await rm(tempDir, { recursive: true, force: true }) })// After `await promise` in each test: expect(process.env.ID001__PASSWORD).toBeUndefined()Based on learnings: "Do not load dotenv into process.env during the CLI integrations edit flow... In tests, avoid side effects... so process.env remains unchanged."
Also applies to: 38-46
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts` around lines 14 - 16, The test stubs getProcessEnv() which can hide dotenv side-effects and the suite never asserts or restores process.env, risking leaked env vars when editIntegration runs; after each await of the test promise in packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts add an assertion that the potentially loaded env key is not present (for example expect(process.env.ID001__PASSWORD).toBeUndefined()) and ensure any tests that modify process.env save/restore the original object (or reset the specific keys) so editIntegration and getProcessEnv stubbing cannot leak dotenv into process.env.
48-110:⚠️ Potential issue | 🟡 MinorAdd one edge/error + special-character edit scenario.
Current coverage is all happy-path. Please add a case with invalid port input and special characters in name/host (then correction), and assert final YAML output.
As per coding guidelines, "Test edge cases, error handling, and special characters in test files".
Also applies to: 112-177, 179-262
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts` around lines 48 - 110, Add a new test in the same file that uses editIntegration (and the existing helpers EXISTING_YAML, tempDir, writeFile, readFile, screen) to simulate an invalid port input followed by correction and inputs containing special characters in the integration name and host; drive the interactive prompts via screen.next()/screen.keypress()/screen.type(), first entering an invalid port (e.g., "not-a-number") and asserting the validation/error prompt appears, then correct it to a valid numeric port and continue, set name/host to values with special characters, finish the flow, and finally assert the resulting YAML (and .env file) contains the corrected port and the escaped/sanitized special-character name and host as expected.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@packages/cli/src/commands/integrations/tests/add-integration.databricks.test.ts`:
- Around line 104-136: The test 'creates databricks integration with optional
schema and catalog' is missing verification of the generated env file; update
the test that calls createIntegration({ file: filePath, envFile: envFilePath })
to also read and assert the contents of envFilePath (similar to other tests),
ensuring the token env variable name matches the mocked UUID pattern (mockUUID)
and expected value (e.g., AAAAAAAA_BBBB_CCCC_DDDD_EEEEEEEEEEEE__TOKEN); locate
the test block using identifiers createIntegration, filePath, envFilePath,
mockUUID and add a readFile + expect check for the .env contents after awaiting
promise and before/after asserting yamlContent.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.materialize.test.ts`:
- Around line 190-273: The SSH test "adds SSH fields when SSH is enabled" is
missing an assertion that the .env file still contains the expected secret
(other tests assert .env contents); after awaiting promise (or before/after
reading yamlContent) read the envFilePath and assert its contents include
"MZ_ID_001__PASSWORD=secret-pass" (or the exact expected line including newline)
so the test mirrors the other cases and verifies the environment file was
preserved/updated; reference the test name and the editIntegration call to
locate where to insert the readFile(envFilePath, 'utf-8') + expect(...)
assertion.
---
Duplicate comments:
In
`@packages/cli/src/commands/integrations/tests/edit-integration.mindsdb.test.ts`:
- Around line 48-267: Add new Vitest cases in this test file around the existing
edit-integration.mindsdb.test.ts suite to cover error and edge scenarios: (1) a
test using editIntegration where the user enters an invalid port
(non-numeric/out-of-range) and assert validation/failure behavior; (2) a test
where required fields (e.g., Database or User) are cleared and assert the CLI
prompts/error handling; (3) a test where the .env file is missing or the
ID001__PASSWORD variable is absent and assert password handling/error; (4) a
test that enters special characters/unicode in name/host/database to ensure
correct YAML escaping; and (5) a positive SSL-enabled path that chooses Enable
SSL: (y/N) => y and asserts ssl-related metadata written. Use the same helpers
and symbols from this file (editIntegration, EXISTING_YAML,
filePath/envFilePath/tempDir, screen, promise) so tests integrate with the
existing flow and assertions.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.spanner.test.ts`:
- Around line 42-150: Capture a shallow snapshot of process.env before calling
editIntegration in both tests (the ones that create promise =
editIntegration({...})), then after await promise assert that process.env
matches the snapshot to ensure the edit flow did not mutate global env; update
the two tests in edit-integration.spanner.test.ts to save const envBefore = {
...process.env } immediately before invoking editIntegration and add
expect(process.env).toEqual(envBefore) right after await promise (or use a
deep-equality matcher), keeping references to editIntegration and the promise
variable to locate the change.
In
`@packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts`:
- Around line 14-16: The test stubs getProcessEnv() which can hide dotenv
side-effects and the suite never asserts or restores process.env, risking leaked
env vars when editIntegration runs; after each await of the test promise in
packages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts
add an assertion that the potentially loaded env key is not present (for example
expect(process.env.ID001__PASSWORD).toBeUndefined()) and ensure any tests that
modify process.env save/restore the original object (or reset the specific keys)
so editIntegration and getProcessEnv stubbing cannot leak dotenv into
process.env.
- Around line 48-110: Add a new test in the same file that uses editIntegration
(and the existing helpers EXISTING_YAML, tempDir, writeFile, readFile, screen)
to simulate an invalid port input followed by correction and inputs containing
special characters in the integration name and host; drive the interactive
prompts via screen.next()/screen.keypress()/screen.type(), first entering an
invalid port (e.g., "not-a-number") and asserting the validation/error prompt
appears, then correct it to a valid numeric port and continue, set name/host to
values with special characters, finish the flow, and finally assert the
resulting YAML (and .env file) contains the corrected port and the
escaped/sanitized special-character name and host as expected.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2e040bff-8417-4859-8621-3ce9036c5a7a
📒 Files selected for processing (9)
packages/cli/src/commands/integrations/tests/add-integration.alloydb.test.tspackages/cli/src/commands/integrations/tests/add-integration.databricks.test.tspackages/cli/src/commands/integrations/tests/add-integration.materialize.test.tspackages/cli/src/commands/integrations/tests/edit-integration.athena.test.tspackages/cli/src/commands/integrations/tests/edit-integration.big-query.test.tspackages/cli/src/commands/integrations/tests/edit-integration.materialize.test.tspackages/cli/src/commands/integrations/tests/edit-integration.mindsdb.test.tspackages/cli/src/commands/integrations/tests/edit-integration.spanner.test.tspackages/cli/src/commands/integrations/tests/edit-integration.sql-server.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@packages/cli/src/commands/integrations/tests/edit-integration.materialize.test.ts`:
- Around line 119-278: Add a new test case alongside the existing ones that uses
editIntegration, EXISTING_YAML, tempDir, screen and envFile to exercise
special-character inputs (e.g., set cluster to a value with symbols like
"prod-cluster!@#" and sshUser to "tunnel$user%") and enable SSH, then assert the
written YAML preserves those exact special characters in metadata.cluster and
metadata.sshUser and that the .env content remains unchanged; mirror the
interaction pattern used in the existing tests (calls to screen.next(),
screen.type(), screen.keypress(), awaiting promise) and add the appropriate
inline snapshot expectations for yamlContent and envContent to lock
serialization and prompt handling for non-alphanumeric input.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0471d691-ba02-4a46-9d0f-a4ee5ceec5eb
📒 Files selected for processing (1)
packages/cli/src/commands/integrations/tests/edit-integration.materialize.test.ts
dinohamzic
left a comment
There was a problem hiding this comment.
Chunky one, let's go 🚀
Summary by CodeRabbit
New Features
User Experience
Tests