Skip to content

Commit

Permalink
Disable AI in e2e tests (#4149)
Browse files Browse the repository at this point in the history
* (Draft) Disable AI in e2e tests

* Fix lint

* Add the setting while building the binary

---------

Co-authored-by: Aditya Hegde <adityahegderocks@gmail.com>
  • Loading branch information
2 people authored and nishantmonu51 committed Feb 24, 2024
1 parent 805b6a2 commit 9dd4929
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/web-test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
run: npm install

- name: Build and embed static UI
run: make cli
run: PLAYWRIGHT_TEST=true make cli

- name: Install browser for UI tests
run: npx playwright install
Expand Down
1 change: 1 addition & 0 deletions web-common/src/features/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const flags = {
readOnly: false,
pivot: features?.includes("pivot") || false,
alerts: features?.includes("alerts") || false,
ai: true,
};

export type FeatureFlags = typeof flags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useDashboardFileNames } from "../../dashboards/selectors";
import { getFilePathFromNameAndType } from "../../entity-management/entity-mappers";
import { getName } from "../../entity-management/name-utils";
import { EntityType } from "../../entity-management/types";
import { featureFlags } from "../../feature-flags";
import OptionToCancelAIGeneration from "./OptionToCancelAIGeneration.svelte";

/**
Expand Down Expand Up @@ -52,6 +53,8 @@ export function useCreateDashboardFromTableUIAction(
behaviourEventMedium: BehaviourEventMedium,
metricsEventSpace: MetricsEventSpace,
) {
const isAiEnabled = get(featureFlags).ai;

// Get the list of existing dashboards to generate a unique name
// We call here to avoid: `Error: Function called outside component initialization`
const dashboardNames = useDashboardFileNames(instanceId);
Expand Down Expand Up @@ -91,7 +94,7 @@ export function useCreateDashboardFromTableUIAction(
{
table: tableName,
path: newFilePath,
useAi: true,
useAi: isAiEnabled, // AI isn't enabled during e2e tests
},
abortController.signal,
);
Expand Down Expand Up @@ -149,6 +152,8 @@ export async function createDashboardFromTableInMetricsEditor(
modelName: string,
metricsViewName: string,
) {
const isAiEnabled = get(featureFlags).ai;

const tableName = modelName;
let isAICancelled = false;
const abortController = new AbortController();
Expand Down Expand Up @@ -177,7 +182,7 @@ export async function createDashboardFromTableInMetricsEditor(
{
table: tableName,
path: filePath,
useAi: true,
useAi: isAiEnabled, // AI isn't enabled during e2e tests
},
abortController.signal,
);
Expand Down
2 changes: 2 additions & 0 deletions web-common/src/layout/RillDeveloperLayout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
featureFlags.set(false, "adminServer");
featureFlags.set(config.readonly, "readOnly");
// Disable AI when running e2e tests
featureFlags.set(!import.meta.env.VITE_PLAYWRIGHT_TEST, "ai");
appBuildMetaStore.set({
version: config.version,
Expand Down
2 changes: 1 addition & 1 deletion web-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. .",
"test": "npx playwright test",
"test": "PLAYWRIGHT_TEST=true npx playwright test",
"test:watch": "npm run test -- --watch",
"manual-publish": "./build-tools/npm_publish.sh"
},
Expand Down
1 change: 1 addition & 0 deletions web-local/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const config = defineConfig(({ mode }) => ({
},
define: {
RILL_RUNTIME_URL: `"${runtimeUrl}"`,
"import.meta.env.VITE_PLAYWRIGHT_TEST": process.env.PLAYWRIGHT_TEST,
},
plugins: [sveltekit()],
}));
Expand Down

0 comments on commit 9dd4929

Please sign in to comment.