-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds a search box to the toolbar featureflag list (#6527)
* adds a search box to the toolbar featureflag list * test flakes because react is re-rendering between the get and the click. add an assertion to try and slow cypress down to avoid this * move filtering toolbar feature flags to a Set and out of CSS * support initKeaTestLogic() with no args * fix query-selector-all-deep jest bug * add simple test case for feature flags logic * combine selectors * with more understanding of Fuse * add simple test for flag filtering Co-authored-by: Marius Andra <[email protected]>
- Loading branch information
1 parent
f84b447
commit a957f0a
Showing
6 changed files
with
166 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { expectLogic } from 'kea-test-utils' | ||
import { initKeaTestLogic } from '~/test/init' | ||
import { featureFlagsLogic } from '~/toolbar/flags/featureFlagsLogic' | ||
import { toolbarLogic } from '~/toolbar/toolbarLogic' | ||
import { CombinedFeatureFlagAndOverrideType } from '~/types' | ||
|
||
const featureFlags = [ | ||
{ feature_flag: { name: 'flag 1' } }, | ||
{ feature_flag: { name: 'flag 2' } }, | ||
] as CombinedFeatureFlagAndOverrideType[] | ||
|
||
const featureFlagsWithExtraInfo = [ | ||
{ currentValue: undefined, hasVariants: false, feature_flag: { name: 'flag 1' } }, | ||
{ currentValue: undefined, hasVariants: false, feature_flag: { name: 'flag 2' } }, | ||
] | ||
|
||
global.fetch = jest.fn(() => | ||
Promise.resolve({ | ||
ok: true, | ||
json: () => Promise.resolve(featureFlags), | ||
} as any as Response) | ||
) | ||
|
||
describe('feature flags logic', () => { | ||
let logic: ReturnType<typeof featureFlagsLogic.build> | ||
|
||
initKeaTestLogic() | ||
|
||
beforeEach(() => { | ||
toolbarLogic({ apiURL: 'http://localhost' }).mount() | ||
logic = featureFlagsLogic() | ||
logic.mount() | ||
}) | ||
|
||
it('has expected defaults', () => { | ||
expectLogic(logic).toMatchValues({ | ||
userFlags: featureFlags, | ||
searchTerm: '', | ||
filteredFlags: featureFlagsWithExtraInfo, | ||
}) | ||
}) | ||
|
||
it('can filter the flags', async () => { | ||
await expectLogic(logic, () => { | ||
logic.actions.setSearchTerm('2') | ||
}).toMatchValues({ | ||
filteredFlags: [{ currentValue: undefined, hasVariants: false, feature_flag: { name: 'flag 2' } }], | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters