Skip to content

Commit

Permalink
test: enforce behavior via test (#4701)
Browse files Browse the repository at this point in the history
This test enforces that descriptions and examples are cleared if they
are not present in the feature naming data.

This behavior is already present, but it hasn't been encoded in any
tests before.
  • Loading branch information
thomasheartman committed Sep 14, 2023
1 parent ab4c1e0 commit bf451f6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/test/e2e/services/project-service.e2e.test.ts
Expand Up @@ -1777,3 +1777,43 @@ test('should return average time to production per toggle and include archived t

expect(resultProject1.features).toHaveLength(3);
});

describe('feature flag naming patterns', () => {
test(`should clear existing example and description if the payload doesn't contain them`, async () => {
const featureNaming = {
pattern: '.+',
example: 'example',
description: 'description',
};

const project = {
id: 'feature-flag-naming-patterns-cleanup',
name: 'Project',
mode: 'open' as const,
defaultStickiness: 'clientId',
description: 'description',
featureNaming,
};

await projectService.createProject(project, user.id);

expect(
(await projectService.getProject(project.id)).featureNaming,
).toMatchObject(featureNaming);

const newPattern = 'new-pattern.+';
await projectService.updateProject(
{
...project,
featureNaming: { pattern: newPattern },
},
user.id,
);

const updatedProject = await projectService.getProject(project.id);

expect(updatedProject.featureNaming!.pattern).toBe(newPattern);
expect(updatedProject.featureNaming!.example).toBeFalsy();
expect(updatedProject.featureNaming!.description).toBeFalsy();
});
});

0 comments on commit bf451f6

Please sign in to comment.