diff --git a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue index 794ad4992d4..d840c77fe40 100644 --- a/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue +++ b/packages/web-app-files/src/components/AppBar/CreateAndUpload.vue @@ -90,10 +90,10 @@ >
  • - +
  • - +
  • @@ -112,17 +112,14 @@ import { useAppDefaults } from 'web-pkg/src/composables' import { DavProperties, DavProperty } from 'web-pkg/src/constants' -// TODO: Simplify to one UploadButton component and fill from here -import FileUpload from './Upload/FileUpload.vue' -import FolderUpload from './Upload/FolderUpload.vue' +import ResourceUpload from './Upload/ResourceUpload.vue' import { defineComponent, getCurrentInstance, onMounted, onUnmounted } from '@vue/composition-api' import { UppyResource, useUpload } from 'web-runtime/src/composables/upload' import { useUploadHelpers } from '../../composables/upload' export default defineComponent({ components: { - FileUpload, - FolderUpload + ResourceUpload }, mixins: [MixinFileActions], setup() { diff --git a/packages/web-app-files/src/components/AppBar/Upload/FileUpload.vue b/packages/web-app-files/src/components/AppBar/Upload/FileUpload.vue deleted file mode 100644 index 1a22d1217a0..00000000000 --- a/packages/web-app-files/src/components/AppBar/Upload/FileUpload.vue +++ /dev/null @@ -1,55 +0,0 @@ - - - - - diff --git a/packages/web-app-files/src/components/AppBar/Upload/FolderUpload.vue b/packages/web-app-files/src/components/AppBar/Upload/FolderUpload.vue deleted file mode 100644 index e28b78f1f2c..00000000000 --- a/packages/web-app-files/src/components/AppBar/Upload/FolderUpload.vue +++ /dev/null @@ -1,43 +0,0 @@ - - - - - diff --git a/packages/web-app-files/src/components/AppBar/Upload/ResourceUpload.vue b/packages/web-app-files/src/components/AppBar/Upload/ResourceUpload.vue new file mode 100644 index 00000000000..7390d19c991 --- /dev/null +++ b/packages/web-app-files/src/components/AppBar/Upload/ResourceUpload.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/packages/web-app-files/src/views/FilesDrop.vue b/packages/web-app-files/src/views/FilesDrop.vue index b47abc8fbf4..1c50a334e45 100644 --- a/packages/web-app-files/src/views/FilesDrop.vue +++ b/packages/web-app-files/src/views/FilesDrop.vue @@ -11,7 +11,7 @@

    - li', - fileUpload: 'file-upload-stub', - folderUpload: 'folder-upload-stub', + fileUpload: 'resource-upload-stub', + folderUpload: 'resource-upload-stub', newFolderBtn: '#new-folder-btn', newTextFileBtn: '.new-file-btn-txt', newMdFileBtn: '.new-file-btn-md', @@ -196,8 +196,7 @@ function getWrapper(route = {}, store = {}) { stubs: { ...stubs, 'oc-button': false, - 'file-upload': true, - 'folder-upload': true + 'resource-upload': true }, store }) diff --git a/packages/web-app-files/tests/unit/components/AppBar/Upload/FolderUpload.spec.js b/packages/web-app-files/tests/unit/components/AppBar/Upload/FolderUpload.spec.js deleted file mode 100644 index 940d0f15427..00000000000 --- a/packages/web-app-files/tests/unit/components/AppBar/Upload/FolderUpload.spec.js +++ /dev/null @@ -1,44 +0,0 @@ -import { mount, createLocalVue } from '@vue/test-utils' -import FolderUpload from '@files/src/components/AppBar/Upload/FolderUpload.vue' -import DesignSystem from 'owncloud-design-system' - -const localVue = createLocalVue() -localVue.use(DesignSystem) - -const selector = { - uploadInput: '#folderUploadInput', - uploadButton: 'button' -} - -describe('FolderUpload Component', () => { - const mountOptions = { - propsData: { - rootPath: '/', - path: '/' - }, - localVue, - directives: { translate: jest.fn() }, - mocks: { - $uppyService: { - registerUploadInput: jest.fn(), - removeUploadInput: jest.fn() - } - } - } - - describe('when upload folder button is clicked', () => { - it('should call "triggerUpload"', async () => { - const spyTriggerUpload = jest.spyOn(FolderUpload.methods, 'triggerUpload') - const wrapper = mount(FolderUpload, mountOptions) - - const uploadButton = wrapper.find(selector.uploadButton) - const folderUploadInput = wrapper.find(selector.uploadInput) - const spyClickUploadInput = jest.spyOn(folderUploadInput.element, 'click') - - await uploadButton.trigger('click') - - expect(spyTriggerUpload).toHaveBeenCalledTimes(1) - expect(spyClickUploadInput).toHaveBeenCalledTimes(1) - }) - }) -}) diff --git a/packages/web-app-files/tests/unit/components/AppBar/Upload/FileUpload.spec.js b/packages/web-app-files/tests/unit/components/AppBar/Upload/ResourceUpload.spec.js similarity index 56% rename from packages/web-app-files/tests/unit/components/AppBar/Upload/FileUpload.spec.js rename to packages/web-app-files/tests/unit/components/AppBar/Upload/ResourceUpload.spec.js index 5000efd3932..0fd21d7d091 100644 --- a/packages/web-app-files/tests/unit/components/AppBar/Upload/FileUpload.spec.js +++ b/packages/web-app-files/tests/unit/components/AppBar/Upload/ResourceUpload.spec.js @@ -1,19 +1,29 @@ import { mount, createLocalVue } from '@vue/test-utils' -import FileUpload from '../../../../../src/components/AppBar/Upload/FileUpload.vue' +import ResourceUpload from '../../../../../src/components/AppBar/Upload/ResourceUpload.vue' import DesignSystem from 'owncloud-design-system' const Translate = jest.fn() -describe('File Upload Component', () => { - it('should render component', () => { - const wrapper = mount(FileUpload, getOptions()) +describe('Resource Upload Component', () => { + describe('file upload', () => { + it('should render component', () => { + const wrapper = mount(ResourceUpload, getOptions()) + expect(wrapper.exists()).toBeTruthy() + expect(wrapper).toMatchSnapshot() + }) + }) - expect(wrapper.exists()).toBeTruthy() + describe('folder upload', () => { + it('should render component', () => { + const wrapper = mount(ResourceUpload, getOptions({ isFolder: true })) + expect(wrapper.exists()).toBeTruthy() + expect(wrapper).toMatchSnapshot() + }) }) describe('when upload file button is clicked', () => { it('should call "triggerUpload"', async () => { - const wrapper = mount(FileUpload, { + const wrapper = mount(ResourceUpload, { ...getOptions(), stubs: { 'oc-icon': true, @@ -23,7 +33,7 @@ describe('File Upload Component', () => { const spyTriggerUpload = jest.spyOn(wrapper.vm, 'triggerUpload') const uploadButton = wrapper.find('button') - const fileUploadInput = wrapper.find('#fileUploadInput') + const fileUploadInput = wrapper.find('#files-file-upload-input') fileUploadInput.element.click = jest.fn() await wrapper.vm.$forceUpdate() @@ -35,13 +45,11 @@ describe('File Upload Component', () => { }) }) -function getOptions() { +function getOptions(propsData = {}) { const localVue = createLocalVue() localVue.use(DesignSystem) return { - propsData: { - path: '' - }, + propsData, localVue, directives: { Translate }, mocks: { diff --git a/packages/web-app-files/tests/unit/components/AppBar/Upload/__snapshots__/ResourceUpload.spec.js.snap b/packages/web-app-files/tests/unit/components/AppBar/Upload/__snapshots__/ResourceUpload.spec.js.snap new file mode 100644 index 00000000000..2f04bb6f3fb --- /dev/null +++ b/packages/web-app-files/tests/unit/components/AppBar/Upload/__snapshots__/ResourceUpload.spec.js.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Resource Upload Component file upload should render component 1`] = `
    `; + +exports[`Resource Upload Component folder upload should render component 1`] = `
    `; diff --git a/packages/web-app-files/tests/unit/views/__snapshots__/FilesDrop.spec.js.snap b/packages/web-app-files/tests/unit/views/__snapshots__/FilesDrop.spec.js.snap index 69b0ef58120..3dc2986e677 100644 --- a/packages/web-app-files/tests/unit/views/__snapshots__/FilesDrop.spec.js.snap +++ b/packages/web-app-files/tests/unit/views/__snapshots__/FilesDrop.spec.js.snap @@ -7,7 +7,7 @@ exports[`FilesDrop should show page title and configuration theme general slogan

    admin shared this folder with you for uploading

    - +
    @@ -43,7 +43,7 @@ exports[`FilesDrop when "loading" is set to false should show error message if o

    admin shared this folder with you for uploading

    - +
    @@ -67,7 +67,7 @@ exports[`FilesDrop when "loading" is set to false should show share information

    admin shared this folder with you for uploading

    - +
    diff --git a/tests/acceptance/pageObjects/personalPage.js b/tests/acceptance/pageObjects/personalPage.js index 480dd78611c..a08eb6e86c5 100644 --- a/tests/acceptance/pageObjects/personalPage.js +++ b/tests/acceptance/pageObjects/personalPage.js @@ -406,10 +406,10 @@ module.exports = { selector: '#files-file-upload-button' }, fileUploadInput: { - selector: '#fileUploadInput' + selector: '#files-file-upload-input' }, folderUploadInput: { - selector: '#folderUploadInput' + selector: '#files-folder-upload-input' }, fileUploadProgress: { selector: '#files-upload-progress' diff --git a/tests/e2e/support/objects/app-files/page/public.ts b/tests/e2e/support/objects/app-files/page/public.ts index 0bf0e9f7b87..efb4e315f2b 100644 --- a/tests/e2e/support/objects/app-files/page/public.ts +++ b/tests/e2e/support/objects/app-files/page/public.ts @@ -27,7 +27,7 @@ export class Public { const startUrl = this.#page.url() const resourceSelector = `[data-test-resource-name="%s"]` await this.#page - .locator('//input[@id="fileUploadInput"]') + .locator('//input[@id="files-file-upload-input"]') .setInputFiles(resources.map((file) => file.path)) const names = resources.map((file) => path.basename(file.name)) await Promise.all( diff --git a/tests/e2e/support/objects/app-files/resource/actions.ts b/tests/e2e/support/objects/app-files/resource/actions.ts index 80b16c213df..3d16c1ad9e8 100644 --- a/tests/e2e/support/objects/app-files/resource/actions.ts +++ b/tests/e2e/support/objects/app-files/resource/actions.ts @@ -77,7 +77,7 @@ export const uploadResource = async (args: uploadResourceArgs): Promise => } await page.locator('#upload-menu-btn').click() - await page.locator('#fileUploadInput').setInputFiles(resources.map((file) => file.path)) + await page.locator('#files-file-upload-input').setInputFiles(resources.map((file) => file.path)) if (createVersion) { await page.locator('.oc-modal-body-actions-confirm').click()