Skip to content

Commit

Permalink
Rebased and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Sep 1, 2021
1 parent 6e49416 commit 4e5af2a
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 24 deletions.
12 changes: 9 additions & 3 deletions packages/web-app-files/tests/unit/views/PublicFiles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ describe('PublicFiles', () => {

describe('when length of active files is greater than zero', () => {
const activeFiles = [createFile({ id: '1234' }), createFile({ id: '5896' })]
const store = createStore({ activeFiles: activeFiles, currentFolder: createFolder() })
const store = createStore({
activeFiles: activeFiles,
currentFolder: createFolder(),
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })

it('should load files table with correct props', () => {
Expand Down Expand Up @@ -204,7 +208,8 @@ describe('PublicFiles', () => {
currentFolder: createFolder(),
activeFiles: activeFiles,
pages: 2,
currentPage: 1
currentPage: 1,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })
await wrapper.vm.$nextTick()
Expand All @@ -223,7 +228,8 @@ describe('PublicFiles', () => {
currentFolder: createFolder(),
activeFiles: activeFiles,
pages: 1,
currentPage: 1
currentPage: 1,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })
await wrapper.vm.$nextTick()
Expand Down
19 changes: 16 additions & 3 deletions packages/web-app-files/tests/unit/views/SharedViaLink.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ describe('SharedViaLink', () => {
})
describe('when length of active files is greater than zero', () => {
const activeFiles = [createFile({ id: '1234' }), createFile({ id: '5896' })]
const store = createStore({ activeFiles: activeFiles })
const store = createStore({
activeFiles: activeFiles,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })

it('should not show the no content message component', () => {
Expand Down Expand Up @@ -101,7 +104,12 @@ describe('SharedViaLink', () => {
stubs['oc-table-files'] = false
stubs.pagination = false
stubs.RouterLink = RouterLinkStub
const store = getStore({ activeFiles: activeFiles, pages: 2, currentPage: 1 })
const store = getStore({
activeFiles: activeFiles,
pages: 2,
currentPage: 1,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })

const pagination = wrapper.find(selectors.pagination)
Expand All @@ -114,7 +122,12 @@ describe('SharedViaLink', () => {
stubs['oc-table-files'] = false
stubs.pagination = false
stubs.RouterLink = RouterLinkStub
const store = getStore({ activeFiles: activeFiles, pages: 1, currentPage: 1 })
const store = getStore({
activeFiles: activeFiles,
pages: 1,
currentPage: 1,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })

const pagination = wrapper.find(selectors.pagination)
Expand Down
37 changes: 28 additions & 9 deletions packages/web-app-files/tests/unit/views/SharedWithMe.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ describe('SharedWithMe', () => {
])('should show file share status text', input => {
stubs['oc-table-files'] = false
const store = getStore({
activeFiles: [createShare({ status: input.status })]
activeFiles: [createShare({ status: input.status })],
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store })

Expand All @@ -110,7 +111,8 @@ describe('SharedWithMe', () => {
it('should display context actions', () => {
stubs['context-actions'] = true
const store = getStore({
activeFiles: [createShare()]
activeFiles: [createShare()],
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store })

Expand All @@ -124,7 +126,8 @@ describe('SharedWithMe', () => {
it('should be visible if active files length is greater than zero', () => {
stubs['list-info'] = true
const store = getStore({
activeFiles: [createShare()]
activeFiles: [createShare()],
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store })

Expand Down Expand Up @@ -155,7 +158,10 @@ describe('SharedWithMe', () => {
it.each([shareStatus.pending, shareStatus.declined])(
'should be visible if the file share status is declined or pending',
input => {
const store = getStore({ activeFiles: [createShare({ id: '1234', status: input })] })
const store = getStore({
activeFiles: [createShare({ id: '1234', status: input })],
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store })

const acceptShareButton = wrapper.find(selectors.acceptShareButton)
Expand All @@ -166,7 +172,8 @@ describe('SharedWithMe', () => {
)
it('should not exist if the file share status is not declined or pending', () => {
const store = getStore({
activeFiles: [createShare({ id: '1234', status: shareStatus.accepted })]
activeFiles: [createShare({ id: '1234', status: shareStatus.accepted })],
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store })
const acceptShareButton = wrapper.find(selectors.acceptShareButton)
Expand All @@ -179,7 +186,10 @@ describe('SharedWithMe', () => {
SharedWithMe.mixins[1].methods,
'$_acceptShare_trigger'
)
const store = getStore({ activeFiles: [acceptedShare] })
const store = getStore({
activeFiles: [acceptedShare],
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store })

const acceptShareButton = wrapper.find(selectors.acceptShareButton)
Expand All @@ -197,7 +207,10 @@ describe('SharedWithMe', () => {
it.each([shareStatus.accepted, shareStatus.pending])(
'should be visible if the file share status is pending or accepted',
inputStatus => {
const store = getStore({ activeFiles: [createShare({ status: inputStatus })] })
const store = getStore({
activeFiles: [createShare({ status: inputStatus })],
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store })

const declineShareButton = wrapper.find(selectors.declineShareButton)
Expand All @@ -206,7 +219,10 @@ describe('SharedWithMe', () => {
}
)
it('should not be visible if the file share status is not pending or accepted', () => {
const store = getStore({ activeFiles: [createShare({ status: shareStatus.declined })] })
const store = getStore({
activeFiles: [createShare({ status: shareStatus.declined })],
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store })

const declineShareButton = wrapper.find(selectors.declineShareButton)
Expand All @@ -219,7 +235,10 @@ describe('SharedWithMe', () => {
SharedWithMe.mixins[2].methods,
'$_declineShare_trigger'
)
const store = getStore({ activeFiles: [declinedShare] })
const store = getStore({
activeFiles: [declinedShare],
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store })

expect(spyDeclineShareTrigger).toHaveBeenCalledTimes(0)
Expand Down
19 changes: 16 additions & 3 deletions packages/web-app-files/tests/unit/views/SharedWithOthers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ describe('SharedWithOthers', () => {
})
describe('when length of active files is greater than zero', () => {
const activeFiles = [createFile({ id: '1234' }), createFile({ id: '5896' })]
const store = createStore({ activeFiles: activeFiles })
const store = createStore({
activeFiles: activeFiles,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })

it('should not show the no content message component', () => {
Expand Down Expand Up @@ -101,7 +104,12 @@ describe('SharedWithOthers', () => {
stubs['oc-table-files'] = false
stubs.pagination = false
stubs.RouterLink = RouterLinkStub
const store = getStore({ activeFiles: activeFiles, pages: 2, currentPage: 1 })
const store = getStore({
activeFiles: activeFiles,
pages: 2,
currentPage: 1,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })

const pagination = wrapper.find(selectors.pagination)
Expand All @@ -114,7 +122,12 @@ describe('SharedWithOthers', () => {
stubs['oc-table-files'] = false
stubs.pagination = false
stubs.RouterLink = RouterLinkStub
const store = getStore({ activeFiles: activeFiles, pages: 1, currentPage: 1 })
const store = getStore({
activeFiles: activeFiles,
pages: 1,
currentPage: 1,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })

const pagination = wrapper.find(selectors.pagination)
Expand Down
31 changes: 25 additions & 6 deletions packages/web-app-files/tests/unit/views/Trashbin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ const selectors = {
}

describe('Trashbin', () => {
it('should show list loader when loading is set as true', () => {
it('should show list loader when the view is still loading', () => {
const wrapper = getMountedWrapper({ loading: true })

expect(wrapper.find(listLoaderStub).exists()).toBeTruthy()
expect(wrapper.find(noContentStub).exists()).toBeFalsy()
expect(wrapper.find(filesTableStub).exists()).toBeFalsy()
})
describe('when loading is set as false', () => {

describe('when the view is not loading anymore', () => {
it('should show the no content message component if active files length is less than one', () => {
const store = createStore({ activeFiles: [] })
const wrapper = getMountedWrapper({ store, loading: false })
Expand All @@ -31,9 +32,13 @@ describe('Trashbin', () => {
expect(wrapper.find(noContentStub).exists()).toBeTruthy()
expect(wrapper.find(noContentStub)).toMatchSnapshot()
})

describe('when length of active files is greater than zero', () => {
const activeFiles = [createFile({ id: '1234' }), createFile({ id: '5896' })]
const store = createStore({ activeFiles: activeFiles })
const store = createStore({
activeFiles: activeFiles,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })

it('should not show the no content message component', () => {
Expand All @@ -57,6 +62,7 @@ describe('Trashbin', () => {
targetRoute: null
})
})

it('should show context menu for each resource', () => {
stubs['oc-table-files'] = false
stubs['context-actions'] = true
Expand All @@ -70,6 +76,7 @@ describe('Trashbin', () => {
})
})
})

it('should show list info component for oc files table', () => {
stubs['oc-table-files'] = false
stubs['list-info'] = true
Expand Down Expand Up @@ -98,18 +105,29 @@ describe('Trashbin', () => {
stubs['oc-table-files'] = false
stubs.pagination = false
stubs.RouterLink = RouterLinkStub
const store = getStore({ activeFiles: activeFiles, pages: 2, currentPage: 1 })
const store = getStore({
activeFiles: activeFiles,
pages: 2,
currentPage: 1,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })

const pagination = wrapper.find(selectors.pagination)

expect(pagination.exists()).toBeTruthy()
})

it('should not be visible if pages is less than one', () => {
stubs['oc-table-files'] = false
stubs.pagination = false
stubs.RouterLink = RouterLinkStub
const store = getStore({ activeFiles: activeFiles, pages: 1, currentPage: 1 })
const store = getStore({
activeFiles: activeFiles,
pages: 1,
currentPage: 1,
totalFilesCount: { files: 1, folders: 1 }
})
const wrapper = getMountedWrapper({ store, loading: false })

const pagination = wrapper.find(selectors.pagination)
Expand All @@ -119,11 +137,12 @@ describe('Trashbin', () => {
})

it('should call "$_filesListPagination_updateCurrentPage" method if "showDetails" event is emitted from oc files table component', () => {
stubs['oc-table-files'] = true
const spyMountSideBarShowDefaultPanel = jest.spyOn(
MixinMountSideBar.methods,
'$_mountSideBar_showDefaultPanel'
)
const wrapper = getMountedWrapper({ store })
const wrapper = getMountedWrapper({ store, loading: false })
const filesTable = wrapper.find(filesTableStub)
expect(spyMountSideBarShowDefaultPanel).toHaveBeenCalledTimes(0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Trashbin when loading is set as false should show the no content message component if active files length is less than one 1`] = `<no-content-message-stub icon="delete" id="files-trashbin-empty" class="files-empty"></no-content-message-stub>`;

exports[`Trashbin when the view is not loading anymore should show the no content message component if active files length is less than one 1`] = `<no-content-message-stub icon="delete" id="files-trashbin-empty" class="files-empty"></no-content-message-stub>`;

0 comments on commit 4e5af2a

Please sign in to comment.