-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[full-ci] Public-link open default action on single file share (#9046)
- Loading branch information
Jan
authored
May 30, 2023
1 parent
13b1f8c
commit 11218b3
Showing
32 changed files
with
307 additions
and
29 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
changelog/unreleased/enhancement-single-file-link-open-with-default-app
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,7 @@ | ||
Enhancement: Single file link open with default app | ||
|
||
We've added a configurable functionality, that a single shared file via link will be opened in default app, | ||
for example text-editor. | ||
|
||
https://github.com/owncloud/web/pull/9046 | ||
https://github.com/owncloud/web/issues/9045 |
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
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
90 changes: 90 additions & 0 deletions
90
packages/web-app-files/tests/unit/components/FilesList/ResourceDetails.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,90 @@ | ||
import { | ||
createStore, | ||
defaultComponentMocks, | ||
defaultPlugins, | ||
defaultStoreMockOptions, | ||
mount, | ||
RouteLocation | ||
} from 'web-test-helpers' | ||
import ResourceDetails from '../../../../src/components/FilesList/ResourceDetails.vue' | ||
import { mock } from 'jest-mock-extended' | ||
import { useFileActions } from 'web-app-files/src/composables/actions/files/useFileActions' | ||
import { SpaceResource } from 'web-client' | ||
import { useRouteQuery } from 'web-pkg' | ||
import { ref } from 'vue' | ||
|
||
jest.mock('web-app-files/src/composables/actions/files/useFileActions') | ||
jest.mock('web-pkg/src/composables/router', () => ({ | ||
...jest.requireActual('web-pkg/src/composables/router'), | ||
useRouteQuery: jest.fn() | ||
})) | ||
|
||
describe('ResourceDetails component', () => { | ||
jest.mocked(useFileActions).mockImplementation(() => | ||
mock<ReturnType<typeof useFileActions>>({ | ||
getDefaultEditorAction: () => ({ handler: jest.fn() } as any) | ||
}) | ||
) | ||
|
||
it('renders resource details correctly', () => { | ||
const { wrapper } = getWrapper() | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
|
||
describe('open with default actions', () => { | ||
it("doesn't open default action if query param 'openWithDefaultApp' isn't set true", () => { | ||
const { wrapper } = getWrapper() | ||
expect(wrapper.vm.defaultEditorAction.handler).not.toHaveBeenCalled() | ||
}) | ||
it("opens default action if query param 'openWithDefaultApp' is set true", () => { | ||
jest.mocked(useRouteQuery).mockImplementationOnce(() => ref('true')) | ||
const { wrapper } = getWrapper() | ||
expect(wrapper.vm.defaultEditorAction.handler).toHaveBeenCalled() | ||
}) | ||
}) | ||
|
||
function getWrapper() { | ||
const mocks = { | ||
...defaultComponentMocks({ | ||
currentRoute: mock<RouteLocation>({ | ||
name: 'files-public-link', | ||
query: { openWithDefaultAppQuery: 'true' } | ||
}) | ||
}) | ||
} | ||
const storeOptions = { ...defaultStoreMockOptions } | ||
const store = createStore(storeOptions) | ||
|
||
const file = { | ||
id: 0, | ||
name: 'image.jpg', | ||
size: 24064, | ||
mdate: 'Wed, 21 Oct 2015 07:28:00 GMT', | ||
mimeType: 'image/jpg', | ||
owner: [ | ||
{ | ||
username: 'admin' | ||
} | ||
] | ||
} | ||
const space = mock<SpaceResource>() | ||
|
||
return { | ||
mocks, | ||
wrapper: mount(ResourceDetails, { | ||
props: { | ||
space, | ||
singleResource: file | ||
}, | ||
global: { | ||
mocks, | ||
plugins: [...defaultPlugins(), store], | ||
provide: { | ||
space, | ||
resource: file | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
}) |
57 changes: 57 additions & 0 deletions
57
.../web-app-files/tests/unit/components/FilesList/__snapshots__/ResourceDetails.spec.ts.snap
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,57 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ResourceDetails component renders resource details correctly 1`] = ` | ||
<div class="resource-details oc-flex oc-flex-column oc-flex-middle"> | ||
<div class="oc-width-1-3@l oc-width-1-2@m oc-width-3-4"> | ||
<div class="file_info oc-flex oc-flex-between oc-p-s"> | ||
<div class="oc-flex oc-flex-middle"> | ||
<span class="oc-icon oc-icon-l oc-icon-passive oc-resource-icon oc-resource-icon-file file_info__icon oc-mr-s"> | ||
<!----> | ||
</span> | ||
<div class="file_info__body oc-text-overflow"> | ||
<h3 class="oc-font-semibold"> | ||
<span class="oc-resource-name oc-display-inline-block" data-test-resource-name="image.jpg" title="image.jpg"> | ||
<span class="oc-resource-basename oc-text-break">image.jpg</span> | ||
<!--v-if--> | ||
</span> | ||
</h3> | ||
</div> | ||
</div> | ||
<!--v-if--> | ||
</div> | ||
<div class="oc-mb" id="oc-file-details-sidebar"> | ||
<div> | ||
<div class="details-icon-wrapper oc-width-1-1 oc-flex oc-flex-middle oc-flex-center oc-mb"> | ||
<span class="oc-icon oc-icon-xxxl oc-icon-passive oc-resource-icon oc-resource-icon-file details-icon"> | ||
<!----> | ||
</span> | ||
</div> | ||
<!--v-if--> | ||
<table aria-label="Overview of the information about the selected file" class="details-table"> | ||
<tbody> | ||
<tr> | ||
<th class="oc-pr-s oc-font-semibold" scope="col">Last modified</th> | ||
<td> | ||
<span>Oct 21, 2015, 7:28 AM</span> | ||
</td> | ||
</tr> | ||
<!--v-if--> | ||
<!--v-if--> | ||
<!--v-if--> | ||
<tr> | ||
<th class="oc-pr-s oc-font-semibold" scope="col">Size</th> | ||
<td>24 kB</td> | ||
</tr> | ||
<!--v-if--> | ||
<!--v-if--> | ||
<!--v-if--> | ||
<!--v-if--> | ||
<!--v-if--> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<ul class="oc-list oc-my-rm oc-mx-rm oc-mt-s" id="oc-files-actions-sidebar"></ul> | ||
</div> | ||
</div> | ||
`; |
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
Oops, something went wrong.