From 76e0d3b6386dd5f431333a6a057bb12bda100e3d Mon Sep 17 00:00:00 2001 From: Milorad Filipovic Date: Tue, 20 Aug 2024 08:51:35 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=94=EF=B8=8F=20Enabling=20the=20feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cypress/e2e/45-ai-assistant.cy.ts | 13 +++---------- cypress/pages/features/ai-assistant.ts | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/cypress/e2e/45-ai-assistant.cy.ts b/cypress/e2e/45-ai-assistant.cy.ts index e835ddeecf828..4431007df0065 100644 --- a/cypress/e2e/45-ai-assistant.cy.ts +++ b/cypress/e2e/45-ai-assistant.cy.ts @@ -1,20 +1,13 @@ -import { overrideFeatureFlag } from '../composables/featureFlags'; import { NDV, WorkflowPage } from '../pages'; import { AIAssistant } from '../pages/features/ai-assistant'; -const AI_ASSISTANT_FEATURE = { - flagName: '021_ai_debug_helper', - enabledFor: 'variant', - disabledFor: 'control', -}; - const wf = new WorkflowPage(); const ndv = new NDV(); const aiAssistant = new AIAssistant(); describe('AI Assistant::disabled', () => { beforeEach(() => { - overrideFeatureFlag(AI_ASSISTANT_FEATURE.flagName, AI_ASSISTANT_FEATURE.disabledFor); + aiAssistant.actions.disableAssistant(); wf.actions.visit(); }); @@ -25,12 +18,12 @@ describe('AI Assistant::disabled', () => { describe('AI Assistant::enabled', () => { beforeEach(() => { - overrideFeatureFlag(AI_ASSISTANT_FEATURE.flagName, AI_ASSISTANT_FEATURE.enabledFor); + aiAssistant.actions.enableAssistant(); wf.actions.visit(); }); after(() => { - overrideFeatureFlag(AI_ASSISTANT_FEATURE.flagName, AI_ASSISTANT_FEATURE.disabledFor); + aiAssistant.actions.disableAssistant(); }); it('renders placeholder UI', () => { diff --git a/cypress/pages/features/ai-assistant.ts b/cypress/pages/features/ai-assistant.ts index fb6a57fc97c58..abca07fbbe84d 100644 --- a/cypress/pages/features/ai-assistant.ts +++ b/cypress/pages/features/ai-assistant.ts @@ -1,5 +1,13 @@ +import { overrideFeatureFlag } from '../../composables/featureFlags'; import { BasePage } from '../base'; +const AI_ASSISTANT_FEATURE = { + name: 'aiAssistant', + experimentName: '021_ai_debug_helper', + enabledFor: 'variant', + disabledFor: 'control', +}; + export class AIAssistant extends BasePage { url = '/workflows/new'; @@ -27,4 +35,15 @@ export class AIAssistant extends BasePage { nodeErrorViewAssistantButton: () => cy.getByTestId('node-error-view-ask-assistant-button').find('button').first(), }; + + actions = { + enableAssistant(): void { + overrideFeatureFlag(AI_ASSISTANT_FEATURE.experimentName, AI_ASSISTANT_FEATURE.enabledFor); + cy.enableFeature(AI_ASSISTANT_FEATURE.name); + }, + disableAssistant(): void { + overrideFeatureFlag(AI_ASSISTANT_FEATURE.experimentName, AI_ASSISTANT_FEATURE.disabledFor); + cy.disableFeature(AI_ASSISTANT_FEATURE.name); + }, + }; }