Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Compare old results with new frontend api (#6476)
- Loading branch information
Showing
11 changed files
with
224 additions
and
28 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
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,54 @@ | ||
import { ProxyService, Config } from './proxy-service'; | ||
import { GlobalFrontendApiCache } from '../proxy/global-frontend-api-cache'; | ||
import { IApiUser } from '../types'; | ||
import { FeatureInterface } from 'unleash-client/lib/feature'; | ||
import noLogger from '../../test/fixtures/no-logger'; | ||
import { ApiTokenType } from '../types/models/api-token'; | ||
|
||
test('proxy service fetching features from global cache', async () => { | ||
const irrelevant = {} as any; | ||
const globalFrontendApiCache = { | ||
getToggles(_: IApiUser): FeatureInterface[] { | ||
return [ | ||
{ | ||
name: 'toggleA', | ||
enabled: true, | ||
project: 'projectA', | ||
type: 'release', | ||
variants: [], | ||
strategies: [ | ||
{ name: 'default', parameters: [], constraints: [] }, | ||
], | ||
}, | ||
{ | ||
name: 'toggleB', | ||
enabled: false, | ||
project: 'projectA', | ||
type: 'release', | ||
variants: [], | ||
strategies: [ | ||
{ name: 'default', parameters: [], constraints: [] }, | ||
], | ||
}, | ||
]; | ||
}, | ||
} as GlobalFrontendApiCache; | ||
const proxyService = new ProxyService( | ||
{ getLogger: noLogger } as unknown as Config, | ||
irrelevant, | ||
irrelevant, | ||
globalFrontendApiCache, | ||
); | ||
|
||
const features = await proxyService.getNewProxyFeatures( | ||
{ | ||
projects: ['irrelevant'], | ||
environment: 'irrelevant', | ||
type: ApiTokenType.FRONTEND, | ||
} as unknown as IApiUser, | ||
{}, | ||
); | ||
|
||
expect(features).toMatchObject([{ name: 'toggleA' }]); | ||
expect(features).toHaveLength(1); | ||
}); |
Oops, something went wrong.