summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2023-04-05 08:41:56 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-04-06 15:31:51 +0200
commitd432e0c7b26287f9b34068241591bcf673b33fc5 (patch)
treefad5dae3ce0bdee6d7eda7778720ec8622023649 /apps/files
parentf060e5a72fa152ce48dd5a32ef14c1f270aefa38 (diff)
downloadnextcloud-server-d432e0c7b26287f9b34068241591bcf673b33fc5.tar.gz
nextcloud-server-d432e0c7b26287f9b34068241591bcf673b33fc5.zip
fix(cypress): component testing with pinia
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/src/views/Navigation.cy.ts66
1 files changed, 53 insertions, 13 deletions
diff --git a/apps/files/src/views/Navigation.cy.ts b/apps/files/src/views/Navigation.cy.ts
index d2fe2b31feb..3d5307e6800 100644
--- a/apps/files/src/views/Navigation.cy.ts
+++ b/apps/files/src/views/Navigation.cy.ts
@@ -2,21 +2,21 @@ import * as InitialState from '@nextcloud/initial-state'
import * as L10n from '@nextcloud/l10n'
import FolderSvg from '@mdi/svg/svg/folder.svg'
import ShareSvg from '@mdi/svg/svg/share-variant.svg'
+import { createTestingPinia } from '@pinia/testing'
import NavigationService from '../services/Navigation.ts'
import NavigationView from './Navigation.vue'
import router from '../router/router.js'
describe('Navigation renders', () => {
- const Navigation = new NavigationService()
+ const Navigation = new NavigationService() as NavigationService
before(() => {
cy.stub(InitialState, 'loadState')
.returns({
- used: 1024 * 1024 * 1024,
+ used: 1000 * 1000 * 1000,
quota: -1,
})
-
})
it('renders', () => {
@@ -24,6 +24,11 @@ describe('Navigation renders', () => {
propsData: {
Navigation,
},
+ global: {
+ plugins: [createTestingPinia({
+ createSpy: cy.spy,
+ })],
+ },
})
cy.get('[data-cy-files-navigation]').should('be.visible')
@@ -33,13 +38,13 @@ describe('Navigation renders', () => {
})
describe('Navigation API', () => {
- const Navigation = new NavigationService()
+ const Navigation = new NavigationService() as NavigationService
it('Check API entries rendering', () => {
Navigation.register({
id: 'files',
name: 'Files',
- getFiles: () => [],
+ getContents: () => Promise.resolve(),
icon: FolderSvg,
order: 1,
})
@@ -48,6 +53,11 @@ describe('Navigation API', () => {
propsData: {
Navigation,
},
+ global: {
+ plugins: [createTestingPinia({
+ createSpy: cy.spy,
+ })],
+ },
router,
})
@@ -61,7 +71,7 @@ describe('Navigation API', () => {
Navigation.register({
id: 'sharing',
name: 'Sharing',
- getFiles: () => [],
+ getContents: () => Promise.resolve(),
icon: ShareSvg,
order: 2,
})
@@ -70,6 +80,11 @@ describe('Navigation API', () => {
propsData: {
Navigation,
},
+ global: {
+ plugins: [createTestingPinia({
+ createSpy: cy.spy,
+ })],
+ },
router,
})
@@ -83,7 +98,7 @@ describe('Navigation API', () => {
Navigation.register({
id: 'sharingin',
name: 'Shared with me',
- getFiles: () => [],
+ getContents: () => Promise.resolve(),
parent: 'sharing',
icon: ShareSvg,
order: 1,
@@ -93,6 +108,11 @@ describe('Navigation API', () => {
propsData: {
Navigation,
},
+ global: {
+ plugins: [createTestingPinia({
+ createSpy: cy.spy,
+ })],
+ },
router,
})
@@ -120,7 +140,7 @@ describe('Navigation API', () => {
Navigation.register({
id: 'files',
name: 'Files',
- getFiles: () => [],
+ getContents: () => Promise.resolve(),
icon: FolderSvg,
order: 1,
})
@@ -151,6 +171,11 @@ describe('Quota rendering', () => {
propsData: {
Navigation,
},
+ global: {
+ plugins: [createTestingPinia({
+ createSpy: cy.spy,
+ })],
+ },
})
cy.get('[data-cy-files-navigation-settings-quota]').should('not.exist')
@@ -160,7 +185,7 @@ describe('Quota rendering', () => {
cy.stub(InitialState, 'loadState')
.as('loadStateStats')
.returns({
- used: 1024 * 1024 * 1024,
+ used: 1000 * 1000 * 1000,
quota: -1,
})
@@ -168,6 +193,11 @@ describe('Quota rendering', () => {
propsData: {
Navigation,
},
+ global: {
+ plugins: [createTestingPinia({
+ createSpy: cy.spy,
+ })],
+ },
})
cy.get('[data-cy-files-navigation-settings-quota]').should('be.visible')
@@ -179,8 +209,8 @@ describe('Quota rendering', () => {
cy.stub(InitialState, 'loadState')
.as('loadStateStats')
.returns({
- used: 1024 * 1024 * 1024,
- quota: 5 * 1024 * 1024 * 1024,
+ used: 1000 * 1000 * 1000,
+ quota: 5 * 1000 * 1000 * 1000,
relative: 20, // percent
})
@@ -188,6 +218,11 @@ describe('Quota rendering', () => {
propsData: {
Navigation,
},
+ global: {
+ plugins: [createTestingPinia({
+ createSpy: cy.spy,
+ })],
+ },
})
cy.get('[data-cy-files-navigation-settings-quota]').should('be.visible')
@@ -200,8 +235,8 @@ describe('Quota rendering', () => {
cy.stub(InitialState, 'loadState')
.as('loadStateStats')
.returns({
- used: 5 * 1024 * 1024 * 1024,
- quota: 1024 * 1024 * 1024,
+ used: 5 * 1000 * 1000 * 1000,
+ quota: 1000 * 1000 * 1000,
relative: 500, // percent
})
@@ -209,6 +244,11 @@ describe('Quota rendering', () => {
propsData: {
Navigation,
},
+ global: {
+ plugins: [createTestingPinia({
+ createSpy: cy.spy,
+ })],
+ },
})
cy.get('[data-cy-files-navigation-settings-quota]').should('be.visible')