1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-24 01:18:01 +02:00

test: filter by created by/author (#7307)

This commit is contained in:
Mateusz Kwasniewski 2024-06-06 13:20:38 +02:00 committed by GitHub
parent a91b77a7ce
commit 7df1321128
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 2 deletions

View File

@ -25,10 +25,18 @@ const setupApi = () => {
features,
total: features.length,
});
testServerRoute(server, '/api/admin/ui-config', {});
testServerRoute(server, '/api/admin/ui-config', {
flags: {
flagCreator: true,
},
});
testServerRoute(server, '/api/admin/tags', {
tags: [{ type: 'backend', value: 'sdk' }],
});
testServerRoute(server, '/api/admin/projects/default/flag-creators', [
{ id: 1, name: 'AuthorA' },
{ id: 2, name: 'AuthorB' },
]);
};
test('selects project features', async () => {
@ -124,3 +132,32 @@ test('filters by flag type', async () => {
await screen.findByText('Flag type');
await screen.findByText('Operational');
});
test('filters by flag author', async () => {
setupApi();
render(
<Routes>
<Route
path={'/projects/:projectId'}
element={
<ProjectFeatureToggles
environments={['development', 'production']}
/>
}
/>
</Routes>,
{
route: '/projects/default',
},
);
const addFilter = await screen.findByText('Add Filter');
fireEvent.click(addFilter);
const createdBy = await screen.findByText('Created by');
fireEvent.click(createdBy);
const authorA = await screen.findByText('AuthorA');
fireEvent.click(authorA);
expect(window.location.href).toContain('createdBy=IS%3A1');
});

View File

@ -83,7 +83,11 @@ export const ProjectOverviewFilters: VFC<IProjectOverviewFilters> = ({
}
setAvailableFilters(availableFilters);
}, [JSON.stringify(tags), JSON.stringify(flagCreators)]);
}, [
JSON.stringify(tags),
JSON.stringify(flagCreators),
flagCreatorEnabled,
]);
return (
<Filters