Skip to content

Conversation

@raju-opti
Copy link
Contributor

Summary

Test plan

Issues

  • FSSDK-12097

@coveralls
Copy link

coveralls commented Dec 3, 2025

Coverage Status

coverage: 77.752%. remained the same
when pulling 3b198d5 on raju/usercontext
into fe00123 on master.

Copilot finished reviewing on behalf of raju-opti December 3, 2025 16:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the OptimizelyUserContext test suite from JavaScript (using Chai/Sinon) to TypeScript with vitest. The refactoring modernizes the test infrastructure while maintaining comprehensive test coverage for user context functionality including attribute management, decision-making, forced decisions, and segment qualification.

Key Changes

  • Migrated from Chai assertions to vitest's expect API
  • Replaced Sinon mocks with vitest's vi.fn() mocking utilities
  • Updated mock helpers to use TypeScript types and standardized mock functions (getMockLogger, getMockEventDispatcher)
  • Removed deprecated parameters (shouldIdentifyUser, isValidInstance, eventBatchSize) that are no longer part of the API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

expect(user.qualifiedSegments).toEqual(['a']);
});

it('should return true for empty returned segements', async () => {
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "segements" should be "segments".

Suggested change
it('should return true for empty returned segements', async () => {
it('should return true for empty returned segments', async () => {

Copilot uses AI. Check for mistakes.
* limitations under the License.
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import { describe, it, beforeEach, afterEach, expect, vi, Mocked } from 'vitest';
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import afterEach.

Suggested change
import { describe, it, beforeEach, afterEach, expect, vi, Mocked } from 'vitest';
import { describe, it, beforeEach, expect, vi, Mocked } from 'vitest';

Copilot uses AI. Check for mistakes.
import OptimizelyUserContext from './';
import Optimizely from '../optimizely';
import testData from '../tests/test_data';
import { EventDispatcher, NotificationCenter, OptimizelyDecideOption } from '../shared_types';
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports EventDispatcher, NotificationCenter.

Suggested change
import { EventDispatcher, NotificationCenter, OptimizelyDecideOption } from '../shared_types';
import { OptimizelyDecideOption } from '../shared_types';

Copilot uses AI. Check for mistakes.
import { getMockProjectConfigManager } from '../tests/mock/mock_project_config_manager';
import { createProjectConfig } from '../project_config/project_config';
import { getForwardingEventProcessor } from '../event_processor/event_processor_factory';
import { FORCED_DECISION_NULL_RULE_KEY } from './index';
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import FORCED_DECISION_NULL_RULE_KEY.

Suggested change
import { FORCED_DECISION_NULL_RULE_KEY } from './index';

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants