Skip to content

Commit

Permalink
Merge pull request #2423 from nextcloud/fix/noid/async-router
Browse files Browse the repository at this point in the history
chore: ensure router is ready in tests
  • Loading branch information
raimund-schluessler authored Dec 30, 2023
2 parents 1b3de54 + 9efc878 commit 58c58bf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
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

0 comments on commit 58c58bf

Please sign in to comment.