-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove action for copying quick links
Removes the action in favour of the new action for copying permanent links.
- Loading branch information
Jannik Stehle
committed
Sep 11, 2024
1 parent
2e7f8a6
commit 2b076b5
Showing
12 changed files
with
81 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 0 additions & 101 deletions
101
packages/web-pkg/src/composables/actions/files/useFileActionsCopyQuicklink.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...ages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyPermanentLink.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { unref } from 'vue' | ||
import { useFileActionsCopyPermanentLink } from '../../../../../src/composables/actions/files' | ||
import { defaultComponentMocks, getComposableWrapper } from 'web-test-helpers' | ||
import { mock } from 'vitest-mock-extended' | ||
import { Resource, SpaceResource } from '@ownclouders/web-client' | ||
import { useClipboard } from '../../../../../src/composables/clipboard' | ||
|
||
vi.mock('../../../../../src/composables/clipboard', () => ({ | ||
useClipboard: vi.fn() | ||
})) | ||
|
||
describe('useFileActionsCopyPermanentLink', () => { | ||
describe('isVisible property', () => { | ||
it('should return false if no resource selected', () => { | ||
getWrapper({ | ||
setup: ({ actions }) => { | ||
expect(unref(actions)[0].isVisible({ space: null, resources: [] })).toBeFalsy() | ||
} | ||
}) | ||
}) | ||
it('should return true if one resource selected', () => { | ||
getWrapper({ | ||
setup: ({ actions }) => { | ||
expect( | ||
unref(actions)[0].isVisible({ resources: [mock<Resource>()], space: undefined }) | ||
).toBeTruthy() | ||
} | ||
}) | ||
}) | ||
}) | ||
describe('handler', () => { | ||
it('calls the copyToClipboard method with the private link of the resource', () => { | ||
getWrapper({ | ||
setup: async ({ actions }, { mocks }) => { | ||
const privateLink = 'https://example.com' | ||
await unref(actions)[0].handler({ | ||
resources: [mock<Resource>({ privateLink })], | ||
space: mock<SpaceResource>() | ||
}) | ||
expect(mocks.copyToClipboardMock).toHaveBeenCalledWith(privateLink) | ||
} | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
function getWrapper({ | ||
setup | ||
}: { | ||
setup: ( | ||
instance: ReturnType<typeof useFileActionsCopyPermanentLink>, | ||
mocks: Record<string, any> | ||
) => void | ||
}) { | ||
const copyToClipboardMock = vi.fn() | ||
vi.mocked(useClipboard).mockReturnValue({ copyToClipboard: copyToClipboardMock }) | ||
const mocks = { ...defaultComponentMocks(), copyToClipboardMock } | ||
|
||
return { | ||
wrapper: getComposableWrapper( | ||
() => { | ||
const instance = useFileActionsCopyPermanentLink() | ||
setup(instance, { mocks }) | ||
}, | ||
{ | ||
mocks, | ||
provide: mocks | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.