Skip to content

Commit

Permalink
test: unskip some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Jan 29, 2024
1 parent 1c46473 commit bac1e48
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('Projects view', () => {
expect(wrapper.vm.items).toEqual([spacesResources[1]])
})
})
it.skip('should display the "Create Space"-button when permission given', () => {
it('should display the "Create Space"-button when permission given', () => {
const { wrapper } = getMountedWrapper({
abilities: [{ action: 'create-all', subject: 'Drive' }],
stubAppBar: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ describe('Search Bar portal component', () => {
expect(wrapper.vm.term).toBe('alice')
expect((wrapper.get('input').element as HTMLInputElement).value).toBe('alice')
})
test.skip('sets active preview item via keyboard navigation', async () => {
test('sets active preview item via keyboard navigation', async () => {
wrapper = getMountedWrapper().wrapper
wrapper.find(selectors.searchInput).setValue('albert')
await flushPromises()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ export const useFileActionsRestore = () => {
return {
actions,
// HACK: exported for unit tests:
restoreResources
restoreResources,
collectConflicts
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,57 +90,58 @@ describe('restore', () => {
})
})

it.skip('should show message on error', () => {
it('should show message on error', () => {
vi.spyOn(console, 'error').mockImplementation(() => undefined)

const { wrapper } = getWrapper({
getWrapper({
resolveClearTrashBin: false,
setup: async () => {
const showErrorMessageStub = vi.spyOn(wrapper.vm, 'showErrorMessage')
const removeFilesFromTrashbinStub = vi.spyOn(wrapper.vm, 'removeFilesFromTrashbin')
await wrapper.vm.$_restore_restoreResources([{ id: '1', path: '/1' }], [])
setup: async ({ restoreResources }, { space }) => {
await restoreResources(
space,
[{ id: '1', path: '/1' }],
[],
mock<LoadingTaskCallbackArguments>()
)

const { showErrorMessage } = useMessages()
expect(showErrorMessage).toHaveBeenCalledTimes(1)

expect(showErrorMessageStub).toHaveBeenCalledTimes(1)
expect(removeFilesFromTrashbinStub).toHaveBeenCalledTimes(0)
const { removeResources } = useResourcesStore()
expect(removeResources).toHaveBeenCalledTimes(0)
}
})
})

it.skip('should request parent folder on collecting restore conflicts', () => {
const { wrapper } = getWrapper({
setup: async () => {
await wrapper.vm.$_restore_collectConflicts([{ id: '1', path: '1', name: '1' }])
it('should request parent folder on collecting restore conflicts', () => {
getWrapper({
setup: async ({ collectConflicts }, { space, clientService }) => {
const resource = { id: '1', path: '1', name: '1' } as Resource
await collectConflicts(space, [resource])

expect(wrapper.vm.$clientService.webdav.listFiles).toHaveBeenCalledWith(
expect.anything(),
{
path: '.'
}
)
expect(clientService.webdav.listFiles).toHaveBeenCalledWith(expect.anything(), {
path: '.'
})
}
})
})

it.skip('should find conflict within resources', () => {
const { wrapper } = getWrapper({
setup: async () => {
const resourceOne = { id: '1', path: '1', name: '1' }
const resourceTwo = { id: '2', path: '1', name: '1' }
const { conflicts } = await wrapper.vm.$_restore_collectConflicts([
resourceOne,
resourceTwo
])
it('should find conflict within resources', () => {
getWrapper({
setup: async ({ collectConflicts }, { space }) => {
const resourceOne = { id: '1', path: '1', name: '1' } as Resource
const resourceTwo = { id: '2', path: '1', name: '1' } as Resource
const { conflicts } = await collectConflicts(space, [resourceOne, resourceTwo])

expect(conflicts).toContain(resourceTwo)
}
})
})

it.skip('should add files without conflict to resolved resources', () => {
const { wrapper } = getWrapper({
setup: async () => {
const resource = { id: '1', path: '1', name: '1' }
const { resolvedResources } = await wrapper.vm.$_restore_collectConflicts([resource])
it('should add files without conflict to resolved resources', () => {
getWrapper({
setup: async ({ collectConflicts }, { space }) => {
const resource = { id: '1', path: '1', name: '1' } as Resource
const { resolvedResources } = await collectConflicts(space, [resource])

expect(resolvedResources).toContain(resource)
}
Expand All @@ -165,6 +166,7 @@ function getWrapper({
}: {
space: SpaceResource
router: ReturnType<typeof defaultComponentMocks>['$router']
clientService: ReturnType<typeof defaultComponentMocks>['$clientService']
}
) => void
}) {
Expand Down Expand Up @@ -196,7 +198,11 @@ function getWrapper({
wrapper: getComposableWrapper(
() => {
const instance = useFileActionsRestore()
setup(instance, { space: mocks.space, router: mocks.$router })
setup(instance, {
space: mocks.space,
router: mocks.$router,
clientService: mocks.$clientService
})
},
{
mocks,
Expand Down

0 comments on commit bac1e48

Please sign in to comment.