1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

fix: add regression tests for feature toggle validation (#695)

This commit is contained in:
Fredrik Strand Oseberg 2022-02-11 00:43:23 +01:00 committed by GitHub
parent c2842c81e6
commit 76db12db2b
3 changed files with 39 additions and 0 deletions

View File

@ -94,6 +94,40 @@ describe('feature toggle', () => {
cy.url().should('include', featureToggleName); cy.url().should('include', featureToggleName);
}); });
it('Gives an error if a toggle exists with the same name', () => {
cy.get('[data-test=NAVIGATE_TO_CREATE_FEATURE').click();
cy.intercept('POST', '/api/admin/projects/default/features').as(
'createFeature'
);
cy.get("[data-test='CF_NAME_ID'").type(featureToggleName);
cy.get("[data-test='CF_DESC_ID'").type('hellowrdada');
cy.get("[data-test='CF_CREATE_BTN_ID']").click();
cy.get("[data-test='INPUT_ERROR_TEXT']").contains(
'A feature with this name already exists'
);
});
it('Gives an error if a toggle name is url unsafe', () => {
cy.get('[data-test=NAVIGATE_TO_CREATE_FEATURE').click();
cy.intercept('POST', '/api/admin/projects/default/features').as(
'createFeature'
);
cy.get("[data-test='CF_NAME_ID'").type('featureToggleUnsafe####$#//');
cy.get("[data-test='CF_DESC_ID'").type('hellowrdada');
cy.get("[data-test='CF_CREATE_BTN_ID']").click();
cy.get("[data-test='INPUT_ERROR_TEXT']").contains(
`"name" must be URL friendly`
);
});
it('Can add a gradual rollout strategy to the development environment', () => { it('Can add a gradual rollout strategy to the development environment', () => {
cy.wait(500); cy.wait(500);
cy.visit(`/projects/default/features/${featureToggleName}/strategies`); cy.visit(`/projects/default/features/${featureToggleName}/strategies`);

View File

@ -1,4 +1,5 @@
import { TextField } from '@material-ui/core'; import { TextField } from '@material-ui/core';
import { INPUT_ERROR_TEXT } from '../../../testIds';
import { useStyles } from './Input.styles.ts'; import { useStyles } from './Input.styles.ts';
interface IInputProps extends React.InputHTMLAttributes<HTMLInputElement> { interface IInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
@ -41,6 +42,7 @@ const Input = ({
value={value} value={value}
onChange={onChange} onChange={onChange}
FormHelperTextProps={{ FormHelperTextProps={{
['data-test']: INPUT_ERROR_TEXT,
classes: { classes: {
root: styles.helperText, root: styles.helperText,
}, },

View File

@ -39,3 +39,6 @@ export const ADD_TO_STRATEGY_INPUT_LIST = 'ADD_TO_STRATEGY_INPUT_LIST';
/* SPLASH */ /* SPLASH */
export const CLOSE_SPLASH = 'CLOSE_SPLASH'; export const CLOSE_SPLASH = 'CLOSE_SPLASH';
/* GENERAL */
export const INPUT_ERROR_TEXT = 'INPUT_ERROR_TEXT';