Skip to content

Commit

Permalink
restore product tour test, fixing leak in dialogHelperTest (#57975)
Browse files Browse the repository at this point in the history
* re enable product tour unit test

* remove clock from product tour test

* delete window.jquery rather than assigning undefined

* fix comment and add safeguard
  • Loading branch information
davidsbailey committed Apr 12, 2024
1 parent 94c8aaf commit 2a4e0c1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
9 changes: 5 additions & 4 deletions apps/test/unit/code-studio/levels/dialogHelperTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ import {
} from '@cdo/apps/code-studio/levels/dialogHelper';

describe('dialogHelper', () => {
let stashedWindowJquery;
before(() => {
stashedWindowJquery = window.jQuery;
// We need bootstrap-sass for $.modal. In the real app, this is provided by dashboard
// We need bootstrap-sass for $.fn.modal. In the real app, this is provided by dashboard
// boostrap-sass also depends on window.jQuery being set. We use require instead
// of import for boostrap-sass, otherwise babel moves the import to the top of
// the file (before we've globalized jQuery)
if (Object.hasOwn(window, 'jQuery')) {
throw new Error('window.jQuery already set');
}
window.jQuery = $;
require('bootstrap-sass');
});

after(() => {
window.jQuery = stashedWindowJquery;
delete window.jQuery;
});
describe('showDialog', () => {
let parent;
Expand Down
49 changes: 23 additions & 26 deletions apps/test/unit/templates/rubrics/RubricContainerTest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -710,32 +710,29 @@ describe('RubricContainer', () => {
expect(wrapper.find('RubricSubmitFooter')).to.have.lengthOf(0);
});

// it('displays product tour when getTourStatus is false', async function () {
// const clock = sinon.useFakeTimers();
// stubFetchEvalStatusForUser(readyJson);
// stubFetchEvalStatusForAll(readyJsonAll);
// stubFetchAiEvaluations(mockAiEvaluations);
// stubFetchTeacherEvaluations(noEvals);
// stubFetchTourStatus({seen: null});

// const {queryByText} = render(
// <Provider store={store}>
// <RubricContainer
// rubric={defaultRubric}
// studentLevelInfo={defaultStudentInfo}
// teacherHasEnabledAi={true}
// currentLevelName={'test_level'}
// reportingData={{}}
// open
// />
// </Provider>
// );

// await wait();
// clock.tick(5000);
// expect(queryByText('Getting Started with AI Teaching Assistant')).to.exist;
// clock.restore();
// });
it('displays product tour when getTourStatus is false', async function () {
stubFetchEvalStatusForUser(readyJson);
stubFetchEvalStatusForAll(readyJsonAll);
stubFetchAiEvaluations(mockAiEvaluations);
stubFetchTeacherEvaluations(noEvals);
stubFetchTourStatus({seen: null});

const {queryByText} = render(
<Provider store={store}>
<RubricContainer
rubric={defaultRubric}
studentLevelInfo={defaultStudentInfo}
teacherHasEnabledAi={true}
currentLevelName={'test_level'}
reportingData={{}}
open
/>
</Provider>
);

await wait();
expect(queryByText('Getting Started with AI Teaching Assistant')).to.exist;
});

it('does not display product tour when getTourStatus returns true', async function () {
stubFetchEvalStatusForUser(readyJson);
Expand Down

0 comments on commit 2a4e0c1

Please sign in to comment.