Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus committed Dec 17, 2024
1 parent 43ea720 commit cf1da07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class ClientFeatureToggleDelta {

private delta: Revisions = {};

private segments: IClientSegment[] = [];
private segments: IClientSegment[];

private eventStore: IEventStore;

Expand Down Expand Up @@ -156,6 +156,10 @@ export class ClientFeatureToggleDelta {
if (!hasDelta) {
await this.initEnvironmentDelta(environment);
}
const hasSegments = this.segments;
if (!hasSegments) {
await this.updateSegments();
}

// Should get the latest state if revision does not exist or if sdkRevision is not present
// We should be able to do this without going to the database by merging revisions from the delta with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,21 +346,3 @@ test('should match snapshot from /api/client/features', async () => {

expect(result.body).toMatchSnapshot();
});

test('should match with /api/client/delta', async () => {
await setupFeatures(db, app);

const { body } = await app.request
.get('/api/client/features')
.set('Unleash-Client-Spec', '4.2.0')
.expect('Content-Type', /json/)
.expect(200);

const { body: deltaBody } = await app.request
.get('/api/client/delta')
.expect('Content-Type', /json/)
.expect(200);

expect(body.features).toMatchObject(deltaBody.updated);
expect(body.segments).toMatchObject(deltaBody.segments);
});

0 comments on commit cf1da07

Please sign in to comment.