Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ensure router is ready in tests #2423

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions tests/javascript/unit/views/AppContent/General.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ describe('General.vue', async () => {
/*
* The all view shows uncompleted tasks
*/
it('Checks that we get the correct number of calendars for the all view', () => {
it('Checks that we get the correct number of calendars for the all view', async () => {
if (wrapper.vm.$route.params.collectionId !== 'all') {
router.push({ name: 'collections', params: { collectionId: 'all' } })
await router.push({ name: 'collections', params: { collectionId: 'all' } })
}
expect(wrapper.vm.calendars.length).toBe(2)
})

it('Checks that only uncompleted and not cancelled tasks show in the all view', () => {
it('Checks that only uncompleted and not cancelled tasks show in the all view', async () => {
if (wrapper.vm.$route.params.collectionId !== 'all') {
router.push({ name: 'collections', params: { collectionId: 'all' } })
await router.push({ name: 'collections', params: { collectionId: 'all' } })
}
expect(wrapper.find('li[task-id="pwen4kz18g.ics"]').exists()).toBe(true)
expect(wrapper.find('li[task-id="pwen4kz40g.ics"]').exists()).toBe(false)
Expand All @@ -35,16 +35,16 @@ describe('General.vue', async () => {
/*
* The starred view shows important and uncompleted tasks
*/
it('Checks that we get the correct number of calendars for the starred view', () => {
it('Checks that we get the correct number of calendars for the starred view', async () => {
if (wrapper.vm.$route.params.collectionId !== 'starred') {
router.push({ name: 'collections', params: { collectionId: 'starred' } })
await router.push({ name: 'collections', params: { collectionId: 'starred' } })
}
expect(wrapper.vm.filteredCalendars.length).toBe(1)
})

it('Checks that only important tasks show in the starred view', () => {
it('Checks that only important tasks show in the starred view', async () => {
if (wrapper.vm.$route.params.collectionId !== 'starred') {
router.push({ name: 'collections', params: { collectionId: 'starred' } })
await router.push({ name: 'collections', params: { collectionId: 'starred' } })
}
expect(wrapper.find('li[task-id="pwen4kz18g.ics"]').exists()).toBe(true) // Important task --> shown
expect(wrapper.find('li[task-id="pwen4kz19g.ics"]').exists()).toBe(false) // Not important task --> hidden
Expand All @@ -59,16 +59,16 @@ describe('General.vue', async () => {
/*
* The current view shows uncompleted tasks which don't have a start date in the future
*/
it('Checks that we get the correct number of calendars for the current view', () => {
it('Checks that we get the correct number of calendars for the current view', async () => {
if (wrapper.vm.$route.params.collectionId !== 'current') {
router.push({ name: 'collections', params: { collectionId: 'current' } })
await router.push({ name: 'collections', params: { collectionId: 'current' } })
}
expect(wrapper.vm.filteredCalendars.length).toBe(2)
})

it('Checks that only current tasks show in the current view', () => {
it('Checks that only current tasks show in the current view', async () => {
if (wrapper.vm.$route.params.collectionId !== 'current') {
router.push({ name: 'collections', params: { collectionId: 'current' } })
await router.push({ name: 'collections', params: { collectionId: 'current' } })
}
expect(wrapper.find('li[task-id="pwen4kz18g.ics"]').exists()).toBe(true) // No start or due date --> shown
expect(wrapper.find('li[task-id="pwen4kz19g.ics"]').exists()).toBe(false) // Start date in the future --> hidden
Expand All @@ -82,16 +82,16 @@ describe('General.vue', async () => {
/*
* The today view shows uncompleted tasks which started or are due today or earlier
*/
it('Checks that we get the correct number of calendars for the today view', () => {
it('Checks that we get the correct number of calendars for the today view', async () => {
if (wrapper.vm.$route.params.collectionId !== 'today') {
router.push({ name: 'collections', params: { collectionId: 'today' } })
await router.push({ name: 'collections', params: { collectionId: 'today' } })
}
expect(wrapper.vm.filteredCalendars.length).toBe(2)
})

it('Checks that only today tasks show in the today view', () => {
it('Checks that only today tasks show in the today view', async () => {
if (wrapper.vm.$route.params.collectionId !== 'today') {
router.push({ name: 'collections', params: { collectionId: 'today' } })
await router.push({ name: 'collections', params: { collectionId: 'today' } })
}
expect(wrapper.find('li[task-id="pwen4kz18g.ics"]').exists()).toBe(true) // Already due --> shown
expect(wrapper.find('li[task-id="pwen4kz19g.ics"]').exists()).toBe(false) // Start date in the future --> hidden
Expand All @@ -104,16 +104,16 @@ describe('General.vue', async () => {
/*
* The completed view shows completed tasks
*/
it('Checks that we get the correct number of calendars for the completed view', () => {
it('Checks that we get the correct number of calendars for the completed view', async () => {
if (wrapper.vm.$route.params.collectionId !== 'completed') {
router.push({ name: 'collections', params: { collectionId: 'completed' } })
await router.push({ name: 'collections', params: { collectionId: 'completed' } })
}
expect(wrapper.vm.filteredCalendars.length).toBe(1)
})

it('Checks that only completed or cancelled tasks show in the completed view', () => {
it('Checks that only completed or cancelled tasks show in the completed view', async () => {
if (wrapper.vm.$route.params.collectionId !== 'completed') {
router.push({ name: 'collections', params: { collectionId: 'completed' } })
await router.push({ name: 'collections', params: { collectionId: 'completed' } })
}
expect(wrapper.find('li[task-id="pwen4kz19g.ics"]').exists()).toBe(false) // Not completed --> hidden
expect(wrapper.find('li[task-id="pwen4kz40g.ics"]').exists()).toBe(true) // Completed --> shown
Expand Down
4 changes: 2 additions & 2 deletions tests/javascript/unit/views/AppContent/Week.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Week.vue', async () => {
await localVue.nextTick()

if (wrapper.vm.$route.params.taskId !== null && wrapper.vm.$route.params.collectionId !== 'week') {
router.push({ name: 'collections', params: { collectionId: 'week' } })
await router.push({ name: 'collections', params: { collectionId: 'week' } })
await localVue.nextTick()
}
expect(taskAtDay0.classes('task-item__body--active')).toBe(false)
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('Week.vue', async () => {
await localVue.nextTick()

if (wrapper.vm.$route.params.taskId !== null && wrapper.vm.$route.params.collectionId !== 'week') {
router.push({ name: 'collections', params: { collectionId: 'week' } })
await router.push({ name: 'collections', params: { collectionId: 'week' } })
await localVue.nextTick()
}
expect(taskAtDay0.classes('task-item__body--active')).toBe(false)
Expand Down
Loading