slightly unflakify tests

This commit is contained in:
Nate 2024-09-01 15:25:28 -07:00
parent 4f29ef7ff7
commit a9bf85c890
9 changed files with 24 additions and 9 deletions

View file

@ -50,10 +50,17 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
)`);
migrate("add_signature_column", async () => {
await db.exec(`
const tableInfo = await db.all("PRAGMA table_info(code_snippets)");
const signatureColumnExists = tableInfo.some(
(column) => column.name === "signature",
);
if (!signatureColumnExists) {
await db.exec(`
ALTER TABLE code_snippets
ADD COLUMN signature TEXT;
`);
}
});
migrate("delete_duplicate_code_snippets", async () => {

View file

@ -72,8 +72,9 @@ describe("CodebaseIndexer", () => {
tearDownTestDir();
setUpTestDir();
execSync('git config --global user.email "test@example.com"');
execSync('git config --global user.name "Test"');
execSync("git init", { cwd: TEST_DIR });
execSync('git config user.email "test@example.com"', { cwd: TEST_DIR });
execSync('git config user.name "Test"', { cwd: TEST_DIR });
});
afterAll(async () => {

View file

@ -25,7 +25,7 @@ describe("FullTextSearchCodebaseIndex", () => {
index = new FullTextSearchCodebaseIndex();
});
it.skip("should update the index and maintain expected database state", async () => {
it("should update the index and maintain expected database state", async () => {
const mockMarkComplete = jest
.fn()
.mockImplementation(() => Promise.resolve()) as any;

View file

@ -48,7 +48,7 @@ describe("ChunkCodebaseIndex", () => {
* - We cannot open either the 'dev' or 'main' tag tables ubtil after we
* can assume they've been created through `updateIndexAndAwaitGenerator`
*/
it.skip("should update the index and maintain expected database state", async () => {
it("should update the index and maintain expected database state", async () => {
const mainTag = mockTag;
const mainTagTableName = index.tableNameForTag(mainTag);

View file

@ -4,11 +4,11 @@
import { ConfigHandler } from "../../config/ConfigHandler.js";
import { ControlPlaneClient } from "../../control-plane/client.js";
import { SiteIndexingConfig } from "../../index.js";
import DocsService from "./DocsService.js";
import preIndexedDocs from "./preIndexedDocs.js";
import FreeTrialEmbeddingsProvider from "../embeddings/FreeTrialEmbeddingsProvider.js";
import FileSystemIde from "../../util/filesystem.js";
import { editConfigJson } from "../../util/paths.js";
import FreeTrialEmbeddingsProvider from "../embeddings/FreeTrialEmbeddingsProvider.js";
import DocsService from "./DocsService.js";
import preIndexedDocs from "./preIndexedDocs.js";
describe.skip("DocsService Integration Tests", () => {
let ide: FileSystemIde;

View file

@ -1,5 +1,9 @@
import fs from "fs";
import path from "path";
export default async function () {
process.env.CONTINUE_GLOBAL_DIR = path.join(__dirname, ".continue-test");
if (fs.existsSync(process.env.CONTINUE_GLOBAL_DIR)) {
fs.rmdirSync(process.env.CONTINUE_GLOBAL_DIR, { recursive: true });
}
}

View file

@ -14,6 +14,9 @@ export class Telemetry {
properties: { [key: string]: any },
sendToTeam: boolean = false,
) {
if (process.env.NODE_ENV === "test") {
return;
}
try {
Telemetry.client?.capture({
distinctId: Telemetry.uniqueId,
@ -44,7 +47,7 @@ export class Telemetry {
Telemetry.os = os.platform();
Telemetry.ideInfo = ideInfo;
if (!allow) {
if (!allow || process.env.NODE_ENV === "test") {
Telemetry.client = undefined;
} else {
try {