fix(ui): fix falling tests
This commit is contained in:
parent
c1feac389f
commit
24b09458ce
4 changed files with 9 additions and 8 deletions
|
|
@ -122,9 +122,8 @@ export default class FeatureFlagsStore {
|
||||||
if (this.currentFflag) {
|
if (this.currentFflag) {
|
||||||
this.setLoading(true);
|
this.setLoading(true);
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
|
||||||
const result = await this.client.createFlag(this.currentFflag.toJS());
|
|
||||||
this.currentFflag.setHasChanged(false)
|
this.currentFflag.setHasChanged(false)
|
||||||
|
const result = await this.client.createFlag(this.currentFflag.toJS());
|
||||||
this.addFlag(new FeatureFlag(result));
|
this.addFlag(new FeatureFlag(result));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,10 @@ type FFlagType = 'single' | 'multi';
|
||||||
type FFlagCondition = {
|
type FFlagCondition = {
|
||||||
name: string;
|
name: string;
|
||||||
rolloutPercentage: number;
|
rolloutPercentage: number;
|
||||||
filters: [];
|
filters: any[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface SimpleFlag {
|
export interface SimpleFlag {
|
||||||
name: string;
|
|
||||||
flagKey: string;
|
flagKey: string;
|
||||||
description: string;
|
description: string;
|
||||||
flagType: FFlagType;
|
flagType: FFlagType;
|
||||||
|
|
|
||||||
|
|
@ -64,13 +64,13 @@ describe('Feature flag type test', () => {
|
||||||
expect(featureFlag.payload).toBe('payload');
|
expect(featureFlag.payload).toBe('payload');
|
||||||
|
|
||||||
featureFlag.addVariant();
|
featureFlag.addVariant();
|
||||||
expect(featureFlag.variants.length).toBe(2);
|
expect(featureFlag.variants.length).toBe(3);
|
||||||
|
|
||||||
featureFlag.removeVariant(1);
|
featureFlag.removeVariant(1);
|
||||||
expect(featureFlag.variants.length).toBe(1);
|
expect(featureFlag.variants.length).toBe(2);
|
||||||
|
|
||||||
featureFlag.redistributeVariants();
|
featureFlag.redistributeVariants();
|
||||||
expect(featureFlag.variants[0].rolloutPercentage).toBe(100);
|
expect(featureFlag.variants[0].rolloutPercentage).toBe(50);
|
||||||
|
|
||||||
featureFlag.addCondition();
|
featureFlag.addCondition();
|
||||||
expect(featureFlag.conditions.length).toBe(2);
|
expect(featureFlag.conditions.length).toBe(2);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@ jest.mock('App/mstore/types/FeatureFlag', () => {
|
||||||
constructor(data) {
|
constructor(data) {
|
||||||
Object.assign(this, data);
|
Object.assign(this, data);
|
||||||
}
|
}
|
||||||
|
setHasChanged() {
|
||||||
|
return jest.fn(() => this)
|
||||||
|
}
|
||||||
|
|
||||||
toJS() {
|
toJS() {
|
||||||
return jest.fn(() => this)
|
return jest.fn(() => this)
|
||||||
|
|
@ -48,7 +51,7 @@ describe('FeatureFlagsStore', () => {
|
||||||
const mockFlag = { featureFlagId: 3 };
|
const mockFlag = { featureFlagId: 3 };
|
||||||
mockFflagsService.createFlag.mockResolvedValueOnce(mockFlag);
|
mockFflagsService.createFlag.mockResolvedValueOnce(mockFlag);
|
||||||
const store = new FeatureFlagsStore(mockFflagsService);
|
const store = new FeatureFlagsStore(mockFflagsService);
|
||||||
store.currentFflag = new FeatureFlag();
|
store.setCurrentFlag(new FeatureFlag())
|
||||||
|
|
||||||
await store.createFlag();
|
await store.createFlag();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue