Skip to content

Commit

Permalink
fix: Swapped active for enabled for optimizely prop
Browse files Browse the repository at this point in the history
  • Loading branch information
rijuma committed Jul 17, 2024
1 parent 1b28cf5 commit 7cf1004
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/components/MessageForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const MessageForm = ({ courseId, shouldAutofocus, unitId }) => {

const { userId } = getAuthenticatedUser();
const [decision] = useDecision(OPTIMIZELY_PROMPT_EXPERIMENT_KEY, { autoUpdate: true }, { id: userId.toString() });
const { active, variationKey } = decision || {};
const promptExperimentVariationKey = active ? variationKey : undefined;
const { enabled, variationKey } = decision || {};
const promptExperimentVariationKey = enabled ? variationKey : undefined;

useEffect(() => {
if (inputRef.current && !apiError && !apiIsLoading && shouldAutofocus) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/MessageForm/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('<MessageForm />', () => {
describe('prmpt experiment', () => {
beforeEach(() => {
useDecision.mockReturnValue([{
active: true,
enabled: true,
variationKey: OPTIMIZELY_PROMPT_EXPERIMENT_VARIATION_KEYS.UPDATED_PROMPT,
}]);
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/Sidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const Sidebar = ({

const { userId } = getAuthenticatedUser();
const [decision] = useDecision(OPTIMIZELY_PROMPT_EXPERIMENT_KEY, { autoUpdate: true }, { id: userId.toString() });
const { active: activeExperiment, variationKey } = decision || {};
const experimentPayload = activeExperiment ? {
const { enabled: enabledExperiment, variationKey } = decision || {};
const experimentPayload = enabledExperiment ? {
experiment_name: OPTIMIZELY_PROMPT_EXPERIMENT_KEY,
variation_key: variationKey,
} : {};
Expand Down Expand Up @@ -81,7 +81,7 @@ const Sidebar = ({
setIsOpen(false);

if (messageList.length >= 2) {
if (activeExperiment && variationKey === OPTIMIZELY_PROMPT_EXPERIMENT_VARIATION_KEYS.UPDATED_PROMPT) {
if (enabledExperiment && variationKey === OPTIMIZELY_PROMPT_EXPERIMENT_VARIATION_KEYS.UPDATED_PROMPT) {
showVariationSurvey();
} else {
showControlSurvey();
Expand Down
8 changes: 4 additions & 4 deletions src/components/Sidebar/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ describe('<Sidebar />', () => {
}],
};

it('should call showVariationSurvey if experiment is active', () => {
it('should call showVariationSurvey if experiment is enabled', () => {
useDecision.mockReturnValue([{
active: true,
enabled: true,
variationKey: OPTIMIZELY_PROMPT_EXPERIMENT_VARIATION_KEYS.UPDATED_PROMPT,
}]);

Expand All @@ -139,7 +139,7 @@ describe('<Sidebar />', () => {
expect(showControlSurvey).not.toHaveBeenCalled();
});

it('should call showControlSurvey if experiment is not active', () => {
it('should call showControlSurvey if experiment disabled', () => {
render(undefined, {
...defaultState,
experiments: {},
Expand All @@ -155,7 +155,7 @@ describe('<Sidebar />', () => {

it('should dispatch clearMessages() and call sendTrackEvent() with the expected props on clear', () => {
useDecision.mockReturnValue([{
active: true,
enabled: true,
variationKey: OPTIMIZELY_PROMPT_EXPERIMENT_VARIATION_KEYS.UPDATED_PROMPT,
}]);

Expand Down
4 changes: 2 additions & 2 deletions src/components/ToggleXpertButton/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const ToggleXpert = ({
const { userId } = getAuthenticatedUser();

const [decision] = useDecision(OPTIMIZELY_PROMPT_EXPERIMENT_KEY, { autoUpdate: true }, { id: userId.toString() });
const { active, variationKey } = decision || {};
const experimentPayload = active ? {
const { enabled, variationKey } = decision || {};
const experimentPayload = enabled ? {
experiment_name: OPTIMIZELY_PROMPT_EXPERIMENT_KEY,
variation_key: variationKey,
} : {};
Expand Down
2 changes: 1 addition & 1 deletion src/components/ToggleXpertButton/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('<ToggleXpert />', () => {
describe('prompt experiment', () => {
beforeEach(() => {
useDecision.mockReturnValue([{
active: true,
enabled: true,
variationKey: OPTIMIZELY_PROMPT_EXPERIMENT_VARIATION_KEYS.UPDATED_PROMPT,
}]);
});
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/Xpert.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ test('survey monkey variation survey should appear if user is in experiment', as
const user = userEvent.setup();

useDecision.mockReturnValue([{
active: true,
enabled: true,
variationKey: OPTIMIZELY_PROMPT_EXPERIMENT_VARIATION_KEYS.UPDATED_PROMPT,
}]);

Expand Down

0 comments on commit 7cf1004

Please sign in to comment.