feat: Redirect users without feature flag from template cred setup (no-changelog) (#8302)

This commit is contained in:
Tomi Turtiainen
2024-01-12 12:10:39 +02:00
committed by GitHub
parent c2748802a2
commit 135553bd6b
10 changed files with 63 additions and 62 deletions

View File

@@ -0,0 +1,12 @@
export const overrideFeatureFlag = (name: string, value: boolean | string) => {
cy.window().then((win) => {
// If feature flags hasn't been initialized yet, we store the override
// in local storage and it gets loaded when the feature flags are
// initialized.
win.localStorage.setItem('N8N_EXPERIMENT_OVERRIDES', JSON.stringify({ [name]: value }));
if (win.featureFlags) {
win.featureFlags.override(name, value);
}
});
};

View File

@@ -38,6 +38,7 @@ describe('Template credentials setup', () => {
it('can be opened from template workflow page', () => {
templateWorkflowPage.actions.visit(testTemplate.id);
templateCredentialsSetupPage.enableTemplateCredentialSetupFeatureFlag();
templateWorkflowPage.getters.useTemplateButton().should('be.visible');
templateCredentialsSetupPage.enableTemplateCredentialSetupFeatureFlag();
templateWorkflowPage.actions.clickUseThisWorkflowButton();
@@ -57,14 +58,6 @@ describe('Template credentials setup', () => {
.should('be.visible');
});
it('can be opened with a direct url', () => {
templateCredentialsSetupPage.visitTemplateCredentialSetupPage(testTemplate.id);
templateCredentialsSetupPage.getters
.title(`Set up 'Promote new Shopify products on Twitter and Telegram' template`)
.should('be.visible');
});
it('has all the elements on page', () => {
templateCredentialsSetupPage.visitTemplateCredentialSetupPage(testTemplate.id);

View File

@@ -1,5 +1,6 @@
import { CredentialsModal, MessageBox } from './modals';
import * as formStep from '../composables/setup-template-form-step';
import { overrideFeatureFlag } from '../composables/featureFlags';
export type TemplateTestData = {
id: number;
@@ -28,15 +29,14 @@ export const getters = {
};
export const enableTemplateCredentialSetupFeatureFlag = () => {
cy.window().then((win) => {
win.featureFlags.override('017_template_credential_setup_v2', true);
});
overrideFeatureFlag('017_template_credential_setup_v2', true);
};
export const visitTemplateCredentialSetupPage = (templateId: number) => {
cy.visit(`/templates/${templateId}/setup`);
formStep.getFormStep().eq(0).should('be.visible');
cy.visit(`templates/${templateId}/setup`);
enableTemplateCredentialSetupFeatureFlag();
formStep.getFormStep().eq(0).should('be.visible');
};
/**

View File

@@ -5,7 +5,7 @@ export class TemplateWorkflowPage extends BasePage {
getters = {
useTemplateButton: () => cy.get('[data-test-id="use-template-button"]'),
description: () => cy.get('[data-test-id="template-description"]')
description: () => cy.get('[data-test-id="template-description"]'),
};
actions = {
@@ -17,7 +17,15 @@ export class TemplateWorkflowPage extends BasePage {
this.getters.useTemplateButton().click();
},
openTemplate: (template: {workflow: {id: number, name: string, description: string, user: {username: string}, image: {id: number, url: string}[] }}) => {
openTemplate: (template: {
workflow: {
id: number;
name: string;
description: string;
user: { username: string };
image: { id: number; url: string }[];
};
}) => {
cy.intercept('GET', `https://api.n8n.io/api/templates/workflows/${template.workflow.id}`, {
statusCode: 200,
body: template,