Skip to content

Commit

Permalink
fix: Adjust tests - we need either a real webroot or mock _oc_webroot
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Apr 2, 2024
1 parent 733eb0e commit b2ba4a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions __tests__/utils/upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Initialize chunks upload temporary workspace', () => {

// mock the current location for our assert on the URL
Object.defineProperty(window, 'location', {
value: new URL('https://cloud.domain.com'),
value: new URL('https://cloud.domain.com/index.php/apps/test'),
configurable: true,
})

Expand All @@ -71,7 +71,7 @@ describe('Initialize chunks upload temporary workspace', () => {

const url = await initChunkWorkspace()

expect(url.startsWith('https://cloud.domain.com/remote.php/dav/uploads/test/web-file-upload-')).toBe(true)
expect(url).toMatch('https://cloud.domain.com/remote.php/dav/uploads/test/web-file-upload-')
expect(url.length).toEqual('https://cloud.domain.com/remote.php/dav/uploads/test/web-file-upload-123456789abcdefg'.length)

expect(axiosMock.request).toHaveBeenCalledTimes(1)
Expand All @@ -86,7 +86,7 @@ describe('Initialize chunks upload temporary workspace', () => {

// mock the current location for our assert on the URL
Object.defineProperty(window, 'location', {
value: new URL('https://cloud.domain.com'),
value: new URL('https://cloud.domain.com/index.php/apps/test'),
configurable: true,
})

Expand All @@ -95,7 +95,7 @@ describe('Initialize chunks upload temporary workspace', () => {

const url = await initChunkWorkspace('https://cloud.domain.com/remote.php/dav/files/test/image.jpg')

expect(url.startsWith('https://cloud.domain.com/remote.php/dav/uploads/test/web-file-upload-')).toBe(true)
expect(url).toMatch('https://cloud.domain.com/remote.php/dav/uploads/test/web-file-upload-')
expect(url.length).toEqual('https://cloud.domain.com/remote.php/dav/uploads/test/web-file-upload-123456789abcdefg'.length)

expect(axiosMock.request).toHaveBeenCalledTimes(1)
Expand Down
3 changes: 3 additions & 0 deletions cypress/support/component-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<!-- Nextcloud customizations -->
<link href="https://nextcloud.github.io/server/apps/theming/css/default.css" rel="stylesheet" />
<script type="text/javascript">
// mocking the webroot for @nextcloud/router
window._oc_webroot = ''

window.OC = {
webroot: '',
config: {},
Expand Down

0 comments on commit b2ba4a7

Please sign in to comment.