forked from binary-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CRO] NikitK/CRO-381/Questionary adding by ab testing approach for ne…
…w users right after email verification (binary-com#12553) * feat: quiestionary adding by ab testing approach * fix: ab feature fix
- Loading branch information
1 parent
c6b5bb1
commit 11f27bf
Showing
10 changed files
with
310 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
packages/core/src/App/Containers/QuestionnaireModal/__tests__/questionnaire-modal.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from 'react'; | ||
import { Formik } from 'formik'; | ||
import { render, screen } from '@testing-library/react'; | ||
import QuestionnaireModal from '../questionnaire-modal'; | ||
import userEvent from '@testing-library/user-event'; | ||
import crypto from 'crypto'; | ||
|
||
describe('QuestionnaireModal', () => { | ||
const mock_props = { | ||
ab_questionnaire: [ | ||
{ | ||
id: '1', | ||
question: 'Default question', | ||
show_answers_in_random_order: true, | ||
answers: [ | ||
{ code: 'a', text: 'Default A' }, | ||
{ code: 'b', text: 'Default B', header: 'Default Header B' }, | ||
], | ||
}, | ||
{ | ||
id: '1', | ||
question: 'Sample question', | ||
show_answers_in_random_order: false, | ||
answers: [ | ||
{ code: 'a', text: 'Option A' }, | ||
{ code: 'b', text: 'Option B', header: 'Header B' }, | ||
], | ||
}, | ||
], | ||
handleSignup: jest.fn(), | ||
}; | ||
|
||
let modal_root_el: HTMLDivElement; | ||
|
||
beforeAll(() => { | ||
modal_root_el = document.createElement('div'); | ||
modal_root_el.setAttribute('id', 'modal_root'); | ||
document.body.appendChild(modal_root_el); | ||
|
||
Object.defineProperty(global, 'crypto', { | ||
value: { | ||
getRandomValues: (arr: Uint32Array) => crypto.randomBytes(arr.length), | ||
}, | ||
}); | ||
}); | ||
|
||
afterAll(() => { | ||
document.body.removeChild(modal_root_el); | ||
}); | ||
|
||
it('renders QuestionnaireModal component correctly', () => { | ||
render( | ||
<Formik initialValues={{}} onSubmit={jest.fn()}> | ||
<QuestionnaireModal {...mock_props} /> | ||
</Formik> | ||
); | ||
expect(screen.getByText('Sample question')).toBeInTheDocument(); | ||
}); | ||
|
||
it('calls handleSignup when an answer is clicked', () => { | ||
render( | ||
<Formik initialValues={{}} onSubmit={jest.fn()}> | ||
<QuestionnaireModal {...mock_props} /> | ||
</Formik> | ||
); | ||
const option_a = screen.getByTestId('a_questionnaire'); | ||
userEvent.click(option_a); | ||
expect(mock_props.handleSignup).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import QuestionnaireModal from './questionnaire-modal'; | ||
|
||
export default QuestionnaireModal; |
Oops, something went wrong.