From f994ea44f404610ca535dbbc40b98dec34dd5e03 Mon Sep 17 00:00:00 2001 From: shaun <58957909+shaunxp20@users.noreply.github.com> Date: Fri, 6 Mar 2020 09:25:06 -0700 Subject: [PATCH] Update @vue/test-utils I upgraded @vue/test-utils to version `v1.0.0-beta.31`. We were previously on `v1.0.0-beta25`, here's the changelog: - https://github.com/vuejs/vue-test-utils/releases This upgrade broke a bunch of tests; our tests had to refactored to run asynchronously, here are some links regarding that: - https://github.com/vuejs/vue-test-utils/issues/1137 - https://vue-test-utils.vuejs.org/guides/#writing-asynchronous-tests-using-nexttick-new Refs: #2380 --- .../components/Review.spec.js | 146 ++++++++++++------ .../components/MentorsSection.spec.js | 10 +- .../components/StudentsSection.spec.js | 10 +- .../components/TopCountriesSection.spec.js | 10 +- spec/javascript/components/DropDown.spec.js | 42 +++-- .../components/IntegerInput.spec.js | 16 +- .../judge/scores/QuestionSection.spec.js | 32 ++-- spec/javascript/location/LocationForm.spec.js | 10 +- .../javascript/mentor/DashboardHeader.spec.js | 10 +- .../components/DataUseTerms.spec.js | 6 +- .../student/DashboardHeader.spec.js | 10 +- yarn.lock | 94 ++++++++++- 12 files changed, 277 insertions(+), 119 deletions(-) diff --git a/spec/javascript/admin/content-settings/components/Review.spec.js b/spec/javascript/admin/content-settings/components/Review.spec.js index 337277bc52..62d579df31 100644 --- a/spec/javascript/admin/content-settings/components/Review.spec.js +++ b/spec/javascript/admin/content-settings/components/Review.spec.js @@ -53,10 +53,12 @@ describe('Admin Content & Settings - Review component', () => { describe('student signup field', () => { - it('displays "yes" if enabled', () => { + it('displays "yes" if enabled', async () => { wrapper.vm.$store.state.student_signup = 1 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'signupFieldStudents' }) .find('.on').exists() const no = wrapper.find({ ref: 'signupFieldStudents' }) @@ -66,10 +68,12 @@ describe('Admin Content & Settings - Review component', () => { expect(no).toBe(false) }) - it('displays "no" if not enabled', () => { + it('displays "no" if not enabled', async () => { wrapper.vm.$store.state.student_signup = 0 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'signupFieldStudents' }) .find('.on').exists() const no = wrapper.find({ ref: 'signupFieldStudents' }) @@ -83,10 +87,12 @@ describe('Admin Content & Settings - Review component', () => { describe('mentor signup field', () => { - it('displays "yes" if enabled', () => { + it('displays "yes" if enabled', async () => { wrapper.vm.$store.state.mentor_signup = 1 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'signupFieldMentors' }) .find('.on').exists() const no = wrapper.find({ ref: 'signupFieldMentors' }) @@ -96,10 +102,12 @@ describe('Admin Content & Settings - Review component', () => { expect(no).toBe(false) }) - it('displays "no" if not enabled', () => { + it('displays "no" if not enabled', async () => { wrapper.vm.$store.state.mentor_signup = 0 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'signupFieldMentors' }) .find('.on').exists() const no = wrapper.find({ ref: 'signupFieldMentors' }) @@ -117,9 +125,11 @@ describe('Admin Content & Settings - Review component', () => { describe('students field', () => { - it('displays a notice if no input available', () => { + it('displays a notice if no input available', async () => { wrapper.vm.$store.state.student_dashboard_text = '' + await wrapper.vm.$nextTick() + const notice = wrapper.find({ ref: 'noticeFieldHintStudents' }) const input = wrapper.find({ ref: 'noticeFieldLabelStudents' }) @@ -127,24 +137,28 @@ describe('Admin Content & Settings - Review component', () => { expect(input.exists()).toBe(false) }) - it('displays the input if available', () => { + it('displays the input if available', async () => { wrapper.vm.$store.state .student_dashboard_text = 'Hello world, this is a test.' - const notice = wrapper.find({ ref: 'noticeFieldHintStudents' }) - const input = wrapper.find({ ref: 'noticeFieldLabelStudents' }) + await wrapper.vm.$nextTick() - expect(notice.exists()).toBe(false) - expect(input.text()).toBe('Hello world, this is a test.') + const notice = wrapper.find({ ref: 'noticeFieldHintStudents' }) + const input = wrapper.find({ ref: 'noticeFieldLabelStudents' }) + + expect(notice.exists()).toBe(false) + expect(input.text()).toBe('Hello world, this is a test.') }) }) describe('mentors field', () => { - it('displays a notice if no input available', () => { + it('displays a notice if no input available', async () => { wrapper.vm.$store.state.mentor_dashboard_text = '' + await wrapper.vm.$nextTick() + const notice = wrapper.find({ ref: 'noticeFieldHintMentors' }) const input = wrapper.find({ ref: 'noticeFieldLabelMentors' }) @@ -152,24 +166,28 @@ describe('Admin Content & Settings - Review component', () => { expect(input.exists()).toBe(false) }) - it('displays the input if available', () => { + it('displays the input if available', async () => { wrapper.vm.$store.state .mentor_dashboard_text = 'Hello world, this is a test.' - const notice = wrapper.find({ ref: 'noticeFieldHintMentors' }) - const input = wrapper.find({ ref: 'noticeFieldLabelMentors' }) + await wrapper.vm.$nextTick() + + const notice = wrapper.find({ ref: 'noticeFieldHintMentors' }) + const input = wrapper.find({ ref: 'noticeFieldLabelMentors' }) - expect(notice.exists()).toBe(false) - expect(input.text()).toBe('Hello world, this is a test.') + expect(notice.exists()).toBe(false) + expect(input.text()).toBe('Hello world, this is a test.') }) }) describe('judges field', () => { - it('displays a notice if no input available', () => { + it('displays a notice if no input available', async () => { wrapper.vm.$store.state.judge_dashboard_text = '' + await wrapper.vm.$nextTick() + const notice = wrapper.find({ ref: 'noticeFieldHintJudges' }) const input = wrapper.find({ ref: 'noticeFieldLabelJudges' }) @@ -177,24 +195,28 @@ describe('Admin Content & Settings - Review component', () => { expect(input.exists()).toBe(false) }) - it('displays the input if available', () => { + it('displays the input if available', async () => { wrapper.vm.$store.state .judge_dashboard_text = 'Hello world, this is a test.' - const notice = wrapper.find({ ref: 'noticeFieldHintJudges' }) - const input = wrapper.find({ ref: 'noticeFieldLabelJudges' }) + await wrapper.vm.$nextTick() - expect(notice.exists()).toBe(false) - expect(input.text()).toBe('Hello world, this is a test.') + const notice = wrapper.find({ ref: 'noticeFieldHintJudges' }) + const input = wrapper.find({ ref: 'noticeFieldLabelJudges' }) + + expect(notice.exists()).toBe(false) + expect(input.text()).toBe('Hello world, this is a test.') }) }) describe('RA field', () => { - it('displays a notice if no input available', () => { + it('displays a notice if no input available', async () => { wrapper.vm.$store.state.regional_ambassador_dashboard_text = '' + await wrapper.vm.$nextTick() + const notice = wrapper .find({ ref: 'noticeFieldHintRegionalAmbassadors' }) const input = wrapper @@ -204,17 +226,19 @@ describe('Admin Content & Settings - Review component', () => { expect(input.exists()).toBe(false) }) - it('displays the input if available', () => { + it('displays the input if available', async () => { wrapper.vm.$store.state .regional_ambassador_dashboard_text = 'Hello world, this is a test.' - const notice = wrapper - .find({ ref: 'noticeFieldHintRegionalAmbassadors' }) - const input = wrapper - .find({ ref: 'noticeFieldLabelRegionalAmbassadors' }) + await wrapper.vm.$nextTick() - expect(notice.exists()).toBe(false) - expect(input.text()).toBe('Hello world, this is a test.') + const notice = wrapper + .find({ ref: 'noticeFieldHintRegionalAmbassadors' }) + const input = wrapper + .find({ ref: 'noticeFieldLabelRegionalAmbassadors' }) + + expect(notice.exists()).toBe(false) + expect(input.text()).toBe('Hello world, this is a test.') }) }) @@ -240,9 +264,11 @@ describe('Admin Content & Settings - Review component', () => { describe('students field', () => { - it('displays a notice if text or URL input is not available', () => { + it('displays a notice if text or URL input is not available', async () => { wrapper.vm.$store.state.student_survey_link.text = '' + await wrapper.vm.$nextTick() + let notice = wrapper.find({ ref: 'surveyFieldTextUrlHintStudents' }) let text = wrapper.find({ ref: 'surveyFieldTextStudents' }) let url = wrapper.find({ ref: 'surveyFieldUrlStudents' }) @@ -255,6 +281,8 @@ describe('Admin Content & Settings - Review component', () => { .text = 'Student Link' wrapper.vm.$store.state.student_survey_link.url = '' + await wrapper.vm.$nextTick() + notice = wrapper.find({ ref: 'surveyFieldTextUrlHintStudents' }) text = wrapper.find({ ref: 'surveyFieldTextStudents' }) url = wrapper.find({ ref: 'surveyFieldUrlStudents' }) @@ -274,9 +302,11 @@ describe('Admin Content & Settings - Review component', () => { expect(url.exists()).toBe(true) }) - it('displays a notice if long description is not available', () => { + it('displays a notice if long description is not available', async () => { wrapper.vm.$store.state.student_survey_link.long_desc = '' + await wrapper.vm.$nextTick() + const notice = wrapper.find({ ref: 'surveyFieldDescHintStudents' }) const description = wrapper.find({ ref: 'surveyFieldDescStudents' }) @@ -296,9 +326,11 @@ describe('Admin Content & Settings - Review component', () => { describe('mentors field', () => { - it('displays a notice if text or URL input is not available', () => { + it('displays a notice if text or URL input is not available', async () => { wrapper.vm.$store.state.mentor_survey_link.text = '' + await wrapper.vm.$nextTick() + let notice = wrapper.find({ ref: 'surveyFieldTextUrlHintMentors' }) let text = wrapper.find({ ref: 'surveyFieldTextMentors' }) let url = wrapper.find({ ref: 'surveyFieldUrlMentors' }) @@ -311,6 +343,8 @@ describe('Admin Content & Settings - Review component', () => { .text = 'Student Link' wrapper.vm.$store.state.mentor_survey_link.url = '' + await wrapper.vm.$nextTick() + notice = wrapper.find({ ref: 'surveyFieldTextUrlHintMentors' }) text = wrapper.find({ ref: 'surveyFieldTextMentors' }) url = wrapper.find({ ref: 'surveyFieldUrlMentors' }) @@ -330,9 +364,11 @@ describe('Admin Content & Settings - Review component', () => { expect(url.exists()).toBe(true) }) - it('displays a notice if long description is not available', () => { + it('displays a notice if long description is not available', async () => { wrapper.vm.$store.state.mentor_survey_link.long_desc = '' + await wrapper.vm.$nextTick() + const notice = wrapper.find({ ref: 'surveyFieldDescHintMentors' }) const description = wrapper.find({ ref: 'surveyFieldDescMentors' }) @@ -356,10 +392,12 @@ describe('Admin Content & Settings - Review component', () => { describe('team building enabled field', () => { - it('displays "yes" if enabled', () => { + it('displays "yes" if enabled', async () => { wrapper.vm.$store.state.team_building_enabled = 1 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'teamBuildingEnabledField' }) .find('.on').exists() const no = wrapper.find({ ref: 'teamBuildingEnabledField' }) @@ -369,10 +407,12 @@ describe('Admin Content & Settings - Review component', () => { expect(no).toBe(false) }) - it('displays "no" if not enabled', () => { + it('displays "no" if not enabled', async () => { wrapper.vm.$store.state.team_building_enabled = 0 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'teamBuildingEnabledField' }) .find('.on').exists() const no = wrapper.find({ ref: 'teamBuildingEnabledField' }) @@ -386,10 +426,12 @@ describe('Admin Content & Settings - Review component', () => { describe('team submissions editable field', () => { - it('displays "yes" if enabled', () => { + it('displays "yes" if enabled', async () => { wrapper.vm.$store.state.team_submissions_editable = 1 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'teamSubmissionsEditableField' }) .find('.on').exists() const no = wrapper.find({ ref: 'teamSubmissionsEditableField' }) @@ -399,10 +441,12 @@ describe('Admin Content & Settings - Review component', () => { expect(no).toBe(false) }) - it('displays "no" if not enabled', () => { + it('displays "no" if not enabled', async () => { wrapper.vm.$store.state.team_submissions_editable = 0 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'teamSubmissionsEditableField' }) .find('.on').exists() const no = wrapper.find({ ref: 'teamSubmissionsEditableField' }) @@ -420,10 +464,12 @@ describe('Admin Content & Settings - Review component', () => { describe('select regional pitch event field', () => { - it('displays "yes" if enabled', () => { + it('displays "yes" if enabled', async () => { wrapper.vm.$store.state.select_regional_pitch_event = 1 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'selectRegionalPitchEventField' }) .find('.on').exists() const no = wrapper.find({ ref: 'selectRegionalPitchEventField' }) @@ -433,10 +479,12 @@ describe('Admin Content & Settings - Review component', () => { expect(no).toBe(false) }) - it('displays "no" if not enabled', () => { + it('displays "no" if not enabled', async () => { wrapper.vm.$store.state.select_regional_pitch_event = 0 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'selectRegionalPitchEventField' }) .find('.on').exists() const no = wrapper.find({ ref: 'selectRegionalPitchEventField' }) @@ -454,21 +502,27 @@ describe('Admin Content & Settings - Review component', () => { describe('judging round field', () => { - it('displays the selected judging round', () => { + it('displays the selected judging round', async () => { wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + let round = wrapper.find({ ref: 'judgingRoundField' }).text() expect(round).toBe('Off') wrapper.vm.$store.state.judging_round = 'qf' + await wrapper.vm.$nextTick() + round = wrapper.find({ ref: 'judgingRoundField' }).text() expect(round).toBe('Quarterfinals') wrapper.vm.$store.state.judging_round = 'sf' + await wrapper.vm.$nextTick() + round = wrapper.find({ ref: 'judgingRoundField' }).text() expect(round).toBe('Semifinals') @@ -482,10 +536,12 @@ describe('Admin Content & Settings - Review component', () => { describe('scores and certificates accessible field', () => { - it('displays "yes" if enabled', () => { + it('displays "yes" if enabled', async () => { wrapper.vm.$store.state.display_scores = 1 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'displayScoresField' }) .find('.on').exists() const no = wrapper.find({ ref: 'displayScoresField' }) @@ -495,10 +551,12 @@ describe('Admin Content & Settings - Review component', () => { expect(no).toBe(false) }) - it('displays "no" if not enabled', () => { + it('displays "no" if not enabled', async () => { wrapper.vm.$store.state.display_scores = 0 wrapper.vm.$store.state.judging_round = 'off' + await wrapper.vm.$nextTick() + const yes = wrapper.find({ ref: 'displayScoresField' }) .find('.on').exists() const no = wrapper.find({ ref: 'displayScoresField' }) @@ -514,4 +572,4 @@ describe('Admin Content & Settings - Review component', () => { }) -}) \ No newline at end of file +}) diff --git a/spec/javascript/admin/dashboard/components/MentorsSection.spec.js b/spec/javascript/admin/dashboard/components/MentorsSection.spec.js index 7632e48da3..661f30d3e9 100644 --- a/spec/javascript/admin/dashboard/components/MentorsSection.spec.js +++ b/spec/javascript/admin/dashboard/components/MentorsSection.spec.js @@ -178,20 +178,24 @@ describe('Admin Dashboard - MentorSection component', () => { expect(returningChart.find(PieChart).exists()).toBe(true) }) - it('hides the mentors count label if the mentors total is not found', () => { + it('hides the mentors count label if the mentors total is not found', async () => { wrapper.vm.totals = {} + await wrapper.vm.$nextTick() + expect(wrapper.find('h3 span').exists()).toBe(false) }) - it('hides the mentors count label if the hideTotal prop is true', () => { + it('hides the mentors count label if the hideTotal prop is true', async () => { wrapper.setProps({ hideTotal: true, }) + await wrapper.vm.$nextTick() + expect(wrapper.find('h3 span').exists()).toBe(false) }) }) -}) \ No newline at end of file +}) diff --git a/spec/javascript/admin/dashboard/components/StudentsSection.spec.js b/spec/javascript/admin/dashboard/components/StudentsSection.spec.js index 676888b627..805b32743b 100644 --- a/spec/javascript/admin/dashboard/components/StudentsSection.spec.js +++ b/spec/javascript/admin/dashboard/components/StudentsSection.spec.js @@ -178,20 +178,24 @@ describe('Admin Dashboard - StudentsSection component', () => { expect(returningChart.find(PieChart).exists()).toBe(true) }) - it('hides the students count label if the students total is not found', () => { + it('hides the students count label if the students total is not found', async () => { wrapper.vm.totals = {} + await wrapper.vm.$nextTick() + expect(wrapper.find('h3 span').exists()).toBe(false) }) - it('hides the students count label if the hideTotal prop is true', () => { + it('hides the students count label if the hideTotal prop is true', async () => { wrapper.setProps({ hideTotal: true, }) + await wrapper.vm.$nextTick() + expect(wrapper.find('h3 span').exists()).toBe(false) }) }) -}) \ No newline at end of file +}) diff --git a/spec/javascript/admin/dashboard/components/TopCountriesSection.spec.js b/spec/javascript/admin/dashboard/components/TopCountriesSection.spec.js index d03ee91e17..b441b98aec 100644 --- a/spec/javascript/admin/dashboard/components/TopCountriesSection.spec.js +++ b/spec/javascript/admin/dashboard/components/TopCountriesSection.spec.js @@ -119,20 +119,24 @@ describe('Admin Dashboard - TopCountriesSection component', () => { expect(wrapper.find(BarChart).exists()).toBe(true) }) - it('hides the top countries count label if the top countries total is not found', () => { + it('hides the top countries count label if the top countries total is not found', async () => { wrapper.vm.totals = {} + await wrapper.vm.$nextTick() + expect(wrapper.find('h3 span').exists()).toBe(false) }) - it('hides the top countries count label if the hideTotal prop is true', () => { + it('hides the top countries count label if the hideTotal prop is true', async () => { wrapper.setProps({ hideTotal: true, }) + await wrapper.vm.$nextTick() + expect(wrapper.find('h3 span').exists()).toBe(false) }) }) -}) \ No newline at end of file +}) diff --git a/spec/javascript/components/DropDown.spec.js b/spec/javascript/components/DropDown.spec.js index 9e240f5898..76947bb87d 100644 --- a/spec/javascript/components/DropDown.spec.js +++ b/spec/javascript/components/DropDown.spec.js @@ -1,4 +1,4 @@ -import { TransitionStub, shallowMount } from '@vue/test-utils' +import { enableAutoDestroy, TransitionStub, shallowMount } from '@vue/test-utils' import DropDown from 'components/DropDown' import Icon from 'components/Icon' @@ -26,9 +26,6 @@ describe('DropDown Vue component', () => { `, }, - stubs: { - transition: TransitionStub, - }, }) }) @@ -128,7 +125,7 @@ describe('DropDown Vue component', () => { expect(wrapper.classes('drop-down')).toBe(true) }) - it('contains a link that toggles the drop down open and closed', (done) => { + it('contains a link that toggles the drop down open and closed', async () => { const toggleCollapseSpy = spyOn(wrapper.vm, 'toggleCollapse') .and.callThrough() const toggleLink = wrapper.find('a') @@ -141,27 +138,25 @@ describe('DropDown Vue component', () => { expect(toggleCollapseSpy).not.toHaveBeenCalled() toggleLink.element.click() + await wrapper.vm.$nextTick() - wrapper.vm.$nextTick(() => { - expect(dropDownContent.isVisible()).toBe(true) - expect(toggleCollapseSpy).toHaveBeenCalledTimes(1) + expect(dropDownContent.isVisible()).toBe(true) + expect(toggleCollapseSpy).toHaveBeenCalledTimes(1) - toggleLink.element.click() + toggleLink.element.click() + await wrapper.vm.$nextTick() - wrapper.vm.$nextTick(() => { - expect(dropDownContent.isVisible()).toBe(false) - expect(toggleCollapseSpy).toHaveBeenCalledTimes(2) - done() - }) - }) + expect(dropDownContent.isVisible()).toBe(false) + expect(toggleCollapseSpy).toHaveBeenCalledTimes(2) }) - it('contains a caret icon which changes based on expanded/collpased state', () => { + it('contains a caret icon which changes based on expanded/collpased state', async () => { const caretIcon = wrapper.find(Icon) expect(caretIcon.exists()).toBe(true) wrapper.setData({ expanded: true }) + await wrapper.vm.$nextTick() expect(caretIcon.props('title')).toEqual('Collapse') expect(caretIcon.props('name')).toEqual('caret-up') @@ -169,6 +164,7 @@ describe('DropDown Vue component', () => { expect(caretIcon.props('size')).toEqual(12) wrapper.setData({ expanded: false }) + await wrapper.vm.$nextTick() expect(caretIcon.props('title')).toEqual('Expand') expect(caretIcon.props('name')).toEqual('caret-down') @@ -176,7 +172,7 @@ describe('DropDown Vue component', () => { expect(caretIcon.props('size')).toEqual(12) }) - it('uses the v-click-outside directive to collapse the drop down', (done) => { + it('uses the v-click-outside directive to collapse the drop down', async () => { const dropDownContent = wrapper.find('.drop-down__content') const divNode = document.createElement('div') @@ -185,19 +181,17 @@ describe('DropDown Vue component', () => { document.body.appendChild(divNode) wrapper.setData({ expanded: true }) + await wrapper.vm.$nextTick() expect(dropDownContent.exists()).toBe(true) expect(dropDownContent.isVisible()).toBe(true) divNode.click() + await wrapper.vm.$nextTick() - wrapper.vm.$nextTick(() => { - expect(dropDownContent.isVisible()).toBe(false) - - divNode.remove() + expect(dropDownContent.isVisible()).toBe(false) - done() - }) + divNode.remove() }) }) -}) \ No newline at end of file +}) diff --git a/spec/javascript/components/IntegerInput.spec.js b/spec/javascript/components/IntegerInput.spec.js index 8405a0c9c3..d44b625ed2 100644 --- a/spec/javascript/components/IntegerInput.spec.js +++ b/spec/javascript/components/IntegerInput.spec.js @@ -44,21 +44,25 @@ describe('IntegerInput Vue component', () => { }); }); - it('sets numericValue based on the value prop passed in', () => { + it('sets numericValue based on the value prop passed in', async () => { const valueProps = [ 33, 99, 2808 ]; - valueProps.forEach((value) => { + valueProps.forEach(async (value) => { wrapper.setProps({ value }); + await wrapper.vm.$nextTick() + expect(wrapper.vm.numericValue).toEqual(value); }); }); - it('sets the input name according to the input-name prop', () => { + it('sets the input name according to the input-name prop', async () => { const inputName = 'this-is-a-test-input'; wrapper.setProps({ inputName }); + await wrapper.vm.$nextTick() + expect(wrapper.find('input').attributes().name).toEqual(inputName); }) @@ -141,7 +145,7 @@ describe('IntegerInput Vue component', () => { expect(wrapper.vm.numericValue).toEqual(expectedValue); }); - it('does not change numericValue if value passed is not a number', () => { + it('does not change numericValue if value passed is not a number', async () => { const minimum = 0; const maximum = 99; const expectedValue = 34; @@ -152,6 +156,8 @@ describe('IntegerInput Vue component', () => { value: expectedValue, }); + await wrapper.vm.$nextTick() + wrapper.vm.recalculateValue('test'); expect(wrapper.vm.numericValue).toEqual(expectedValue); @@ -160,4 +166,4 @@ describe('IntegerInput Vue component', () => { }); -}); \ No newline at end of file +}); diff --git a/spec/javascript/judge/scores/QuestionSection.spec.js b/spec/javascript/judge/scores/QuestionSection.spec.js index 675f2a2618..9b44cffb8c 100644 --- a/spec/javascript/judge/scores/QuestionSection.spec.js +++ b/spec/javascript/judge/scores/QuestionSection.spec.js @@ -59,19 +59,16 @@ describe('Question comments section', () => { }) }) - test('saves comments after changes', (done) => { + test('saves comments after changes', async() => { const storeCommitSpy = jest.spyOn(wrapper.vm.$store, 'commit') wrapper.vm.comment.text = 'hello' + await wrapper.vm.$nextTick() - wrapper.vm.$nextTick(() => { - wrapper.vm.handleCommentChange() + wrapper.vm.handleCommentChange() + await wrapper.vm.$nextTick() - setImmediate(() => { - expect(storeCommitSpy).toHaveBeenLastCalledWith('saveComment', 'ideation') - done() - }) - }) + expect(storeCommitSpy).toHaveBeenLastCalledWith('saveComment', 'ideation') }) test('debouncedCommentWatcher calls handleCommentChange', () => { @@ -98,21 +95,16 @@ describe('Question comments section', () => { expect(handleCommentChangeSpy).toHaveBeenCalled() }) - test('it resets the word count when the text is deleted', (done) => { - wrapper.vm.$nextTick(() => { - wrapper.vm.comment.text = 'hello beautiful world' + test('it resets the word count when the text is deleted', async() => { + wrapper.vm.comment.text = 'hello beautiful world' + await wrapper.vm.$nextTick() - wrapper.vm.$nextTick(() => { - expect(wrapper.vm.comment.word_count).toEqual(3) + expect(wrapper.vm.comment.word_count).toEqual(3) - wrapper.vm.comment.text = '' + wrapper.vm.comment.text = '' + await wrapper.vm.$nextTick() - wrapper.vm.$nextTick(() => { - expect(wrapper.vm.comment.word_count).toEqual(0) - done() - }) - }) - }) + expect(wrapper.vm.comment.word_count).toEqual(0) }) test('textarea should update comment text in store on change', (done) => { diff --git a/spec/javascript/location/LocationForm.spec.js b/spec/javascript/location/LocationForm.spec.js index 22453a150b..507cc69dee 100644 --- a/spec/javascript/location/LocationForm.spec.js +++ b/spec/javascript/location/LocationForm.spec.js @@ -105,9 +105,11 @@ describe('location/components/LocationForm', () => { expect(suggestions.length).toEqual(3) }) - it('is not visible if there are no suggestions present', () => { + it('is not visible if there are no suggestions present', async () => { wrapper.setData({ suggestions: [] }) + await wrapper.vm.$nextTick() + const suggestionsTable = wrapper.find({ ref: 'suggestionsTable' }) expect(suggestionsTable.exists()).toBe(false) @@ -209,9 +211,11 @@ describe('location/components/LocationForm', () => { expect(savedLocationText).toContain('United States') }) - it('is not visible if there is no saved location', () => { + it('is not visible if there is no saved location', async () => { wrapper.setData({ savedLocation: null }) + await wrapper.vm.$nextTick() + const savedLocationTable = wrapper.find({ ref: 'savedLocationTable' }) expect(savedLocationTable.exists()).toBe(false) @@ -372,4 +376,4 @@ describe('location/components/LocationForm', () => { }) }) }) -}) \ No newline at end of file +}) diff --git a/spec/javascript/mentor/DashboardHeader.spec.js b/spec/javascript/mentor/DashboardHeader.spec.js index acd21e436d..36125c6147 100644 --- a/spec/javascript/mentor/DashboardHeader.spec.js +++ b/spec/javascript/mentor/DashboardHeader.spec.js @@ -43,18 +43,20 @@ describe("mentor/DashboardHeader.vue", () => { expect(dropDown.vm.label).toEqual("More Information") }) - it("displays the currentAccount's name", () => { + it("displays the currentAccount's name", async () => { defaultWrapper.vm.$store.commit('authenticated/htmlDataset', { currentAccount: '{"data":{"attributes":{"name":"Saul Goodman"}}}' }) + await defaultWrapper.vm.$nextTick() + expect(defaultWrapper.find( '.dashboard-notices .grid__col-sm-6:nth-child(2)' ).text()).toContain("Saul Goodman") }) describe("when the RA has not provided an intro", () => { - it("displays the default left header", () => { + it("displays the default left header", async () => { defaultWrapper.setProps({ defaultTitle: "Mentor Dashboard", resourceLinks: [ @@ -66,6 +68,8 @@ describe("mentor/DashboardHeader.vue", () => { ] }) + await defaultWrapper.vm.$nextTick() + expect(defaultWrapper.find( '.dashboard-notices .grid__col-sm-6:first-child' ).text()).toContain("Mentor Dashboard") @@ -91,4 +95,4 @@ describe("mentor/DashboardHeader.vue", () => { expect(text).toContain("Technovation[MN]") }) }) -}) \ No newline at end of file +}) diff --git a/spec/javascript/registration/components/DataUseTerms.spec.js b/spec/javascript/registration/components/DataUseTerms.spec.js index 6f75e3474c..47a7d26bb5 100644 --- a/spec/javascript/registration/components/DataUseTerms.spec.js +++ b/spec/javascript/registration/components/DataUseTerms.spec.js @@ -58,9 +58,11 @@ describe("Registration::Components::DataUseTerms.vue", () => { }); describe('submitButtonText', () => { - it('sets the text on the "Next" button accoring to the prop value', () => { + it('sets the text on the "Next" button according to the prop value', async () => { defaultWrapper.setProps({ submitButtonText: 'Submit' }); + await defaultWrapper.vm.$nextTick() + const submitButtonText = defaultWrapper .find({ ref: 'dataUseTermsSubmitButton' }).text(); @@ -75,4 +77,4 @@ describe("Registration::Components::DataUseTerms.vue", () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/spec/javascript/student/DashboardHeader.spec.js b/spec/javascript/student/DashboardHeader.spec.js index f2f1009d0a..8c2b660dd6 100644 --- a/spec/javascript/student/DashboardHeader.spec.js +++ b/spec/javascript/student/DashboardHeader.spec.js @@ -43,18 +43,20 @@ describe("student/DashboardHeader.vue", () => { expect(dropDown.vm.label).toEqual("More Information") }) - it("displays the currentAccount's name", () => { + it("displays the currentAccount's name", async () => { defaultWrapper.vm.$store.commit('authenticated/htmlDataset', { currentAccount: '{"data":{"attributes":{"name":"Saul Goodman"}}}' }) + await defaultWrapper.vm.$nextTick() + expect(defaultWrapper.find( '.dashboard-notices .grid__col-sm-6:nth-child(2)' ).text()).toContain("Saul Goodman") }) describe("when the RA has not provided an intro", () => { - it("displays the default left header", () => { + it("displays the default left header", async () => { defaultWrapper.setProps({ defaultTitle: "Student Dashboard", resourceLinks: [ @@ -66,6 +68,8 @@ describe("student/DashboardHeader.vue", () => { ] }) + await defaultWrapper.vm.$nextTick() + expect(defaultWrapper.find( '.dashboard-notices .grid__col-sm-6:first-child' ).text()).toContain("Student Dashboard") @@ -91,4 +95,4 @@ describe("student/DashboardHeader.vue", () => { expect(text).toContain("Technovation[MN]") }) }) -}) \ No newline at end of file +}) diff --git a/yarn.lock b/yarn.lock index f6446d80d8..fa784a6f4a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -66,10 +66,13 @@ resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1" "@vue/test-utils@^1.0.0-beta.25": - version "1.0.0-beta.25" - resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.25.tgz#4703076de3076bac42cdd242cd53e6fb8752ed8c" + version "1.0.0-beta.31" + resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.31.tgz#580d6e45f07452e497d69807d80986e713949b73" + integrity sha512-IlhSx5hyEVnbvDZ3P98R1jNmy88QAd/y66Upn4EcvxSD5D4hwOutl3dIdfmSTSXs4b9DIMDnEVjX7t00cvOnvg== dependencies: - lodash "^4.17.4" + dom-event-types "^1.0.0" + lodash "^4.17.15" + pretty "^2.0.0" abab@^2.0.0: version "2.0.0" @@ -1593,6 +1596,11 @@ commander@*, commander@^2.11.0, commander@^2.13.0: version "2.18.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970" +commander@^2.19.0: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" @@ -1650,7 +1658,16 @@ concat-stream@^1.5.0: readable-stream "^2.2.2" typedarray "^0.0.6" -config-chain@~1.1.5: +condense-newlines@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/condense-newlines/-/condense-newlines-0.2.1.tgz#3de985553139475d32502c83b02f60684d24c55f" + integrity sha1-PemFVTE5R10yUCyDsC9gaE0kxV8= + dependencies: + extend-shallow "^2.0.1" + is-whitespace "^0.3.0" + kind-of "^3.0.2" + +config-chain@^1.1.12, config-chain@~1.1.5: version "1.1.12" resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa" dependencies: @@ -2141,6 +2158,11 @@ dns-txt@^2.0.2: dependencies: buffer-indexof "^1.0.0" +dom-event-types@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/dom-event-types/-/dom-event-types-1.0.0.tgz#5830a0a29e1bf837fe50a70cd80a597232813cae" + integrity sha512-2G2Vwi2zXTHBGqXHsJ4+ak/iP0N8Ar+G8a7LiD2oup5o4sQWytwqqrZu/O6hIMV0KMID2PL69OhpshLO0n7UJQ== + domain-browser@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda" @@ -2199,6 +2221,16 @@ editorconfig@^0.15.0: semver "^5.4.1" sigmund "^1.0.1" +editorconfig@^0.15.3: + version "0.15.3" + resolved "https://registry.yarnpkg.com/editorconfig/-/editorconfig-0.15.3.tgz#bef84c4e75fb8dcb0ce5cee8efd51c15999befc5" + integrity sha512-M9wIMFx96vq0R4F+gRpY3o2exzb8hEj/n9S8unZtHSvYjibBp/iMufSzvmOcV/laG0ZtuTVGtiJggPOSW2r93g== + dependencies: + commander "^2.19.0" + lru-cache "^4.1.5" + semver "^5.6.0" + sigmund "^1.0.1" + ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -2908,6 +2940,18 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@~7.1.1: once "^1.3.0" path-is-absolute "^1.0.0" +glob@^7.1.3: + version "7.1.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" + integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" @@ -3543,6 +3587,11 @@ is-utf8@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" +is-whitespace@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/is-whitespace/-/is-whitespace-0.3.0.tgz#1639ecb1be036aec69a54cbb401cfbed7114ab7f" + integrity sha1-Fjnssb4DauxppUy7QBz77XEUq38= + is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" @@ -3915,6 +3964,17 @@ js-base64@^2.1.8, js-base64@^2.1.9: version "2.4.9" resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.9.tgz#748911fb04f48a60c4771b375cac45a80df11c03" +js-beautify@^1.6.12: + version "1.10.3" + resolved "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.10.3.tgz#c73fa10cf69d3dfa52d8ed624f23c64c0a6a94c1" + integrity sha512-wfk/IAWobz1TfApSdivH5PJ0miIHgDoYb1ugSqHcODPmaYu46rYe5FVuIEkhjg8IQiv6rDNPyhsqbsohI/C2vQ== + dependencies: + config-chain "^1.1.12" + editorconfig "^0.15.3" + glob "^7.1.3" + mkdirp "~0.5.1" + nopt "~4.0.1" + js-beautify@^1.6.14: version "1.8.6" resolved "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.8.6.tgz#6a7e61e47a6e45fb58c5e22499eed350f8607d98" @@ -4199,11 +4259,11 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" -lodash@4.x, "lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.2, lodash@^4.17.4, lodash@~4.17.10: +lodash@4.x, "lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.2, lodash@~4.17.10: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" -lodash@^4.17.11, lodash@^4.17.12: +lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.15, lodash@^4.17.4: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== @@ -4246,6 +4306,14 @@ lru-cache@^4.0.1, lru-cache@^4.1.1: pseudomap "^1.0.2" yallist "^2.1.2" +lru-cache@^4.1.5: + version "4.1.5" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" + integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== + dependencies: + pseudomap "^1.0.2" + yallist "^2.1.2" + make-dir@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" @@ -5688,6 +5756,15 @@ pretty-format@^22.4.0, pretty-format@^22.4.3: ansi-regex "^3.0.0" ansi-styles "^3.2.0" +pretty@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pretty/-/pretty-2.0.0.tgz#adbc7960b7bbfe289a557dc5f737619a220d06a5" + integrity sha1-rbx5YLe7/iiaVX3F9zdhmiINBqU= + dependencies: + condense-newlines "^0.2.1" + extend-shallow "^2.0.1" + js-beautify "^1.6.12" + private@^0.1.6, private@^0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -6249,6 +6326,11 @@ selfsigned@^1.9.1: version "5.5.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477" +semver@^5.6.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + semver@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"