Skip to content

Commit 43a1198

Browse files
authored
fix: [REL-11310] standardize context management (#440)
* feat: standardize context management * fix: fix selection bug * chore: run pnpm format
1 parent e21ea61 commit 43a1198

File tree

12 files changed

+1612
-256
lines changed

12 files changed

+1612
-256
lines changed

packages/toolbar/src/core/tests/AddContextForm.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ describe('AddContextForm', () => {
110110
key: 'test-user-123',
111111
name: 'Test User',
112112
});
113-
// anonymous should be false when not explicitly set
114-
expect(savedContexts[0].anonymous).toBe(false);
113+
// anonymous should be undefined when not explicitly set (LDContext omits false values)
114+
expect(savedContexts[0].anonymous).toBeUndefined();
115115

116116
expect(mockOnClose).toHaveBeenCalled();
117117
});

packages/toolbar/src/core/tests/ContextItem.test.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
22
import { expect, test, describe, vi, beforeEach } from 'vitest';
3+
import type { LDContext } from 'launchdarkly-js-client-sdk';
34
import { ContextItem } from '../ui/Toolbar/components/new/Contexts/ContextItem';
45
import { ContextsProvider } from '../ui/Toolbar/context/api/ContextsProvider';
56
import '@testing-library/jest-dom/vitest';
67
import React from 'react';
7-
import { Context } from '../ui/Toolbar/types/ldApi';
88
import { loadContexts, saveContexts } from '../ui/Toolbar/utils/localStorage';
99

1010
// Mock localStorage utilities
@@ -63,8 +63,7 @@ vi.mock('motion/react', () => ({
6363
}));
6464

6565
describe('ContextItem', () => {
66-
const mockContext: Context = {
67-
id: 'test-context-id-123',
66+
const mockContext: LDContext = {
6867
kind: 'user',
6968
key: 'test-user-123',
7069
name: 'Test User',
@@ -124,7 +123,7 @@ describe('ContextItem', () => {
124123

125124
describe('Delete Functionality', () => {
126125
test('deletes context when delete button is clicked', async () => {
127-
const storedContexts: Context[] = [mockContext];
126+
const storedContexts: LDContext[] = [mockContext];
128127
(loadContexts as any).mockReturnValue(storedContexts);
129128

130129
render(
@@ -160,7 +159,7 @@ describe('ContextItem', () => {
160159
});
161160

162161
test('prevents deletion when context is active (button not rendered)', async () => {
163-
const storedContexts: Context[] = [mockContext];
162+
const storedContexts: LDContext[] = [mockContext];
164163
(loadContexts as any).mockReturnValue(storedContexts);
165164

166165
render(

0 commit comments

Comments
 (0)