Files
ocis/web/packages/web-app-password-protected-folders/tests/unit/components/FolderViewModal.spec.ts
Matteo ebda376ae1 fix(web): [OCISDEV-136] sync .psec pointer file on password-protected folder rename (#12684)
Renaming a password-protected folder did not update its `.psec` pointer
file, so the main file listing kept showing the old name. This happened
both when renaming via the hidden `.PasswordProtectedFolders` location
and when renaming from inside the folder-view modal, where an unsynced
rename left the pointer permanently stale.

Renaming the real folder now also renames its `.psec` counterpart. Inside
the folder-view modal, the framed public-link session notifies the parent
window at the moment of rename, so the pointer stays in sync even without
clicking Close.
2026-07-31 07:01:39 +02:00

58 lines
1.7 KiB
TypeScript

import { defaultComponentMocks, defaultPlugins, shallowMount } from '@ownclouders/web-test-helpers'
import FolderViewModal from '../../../src/components/FolderViewModal.vue'
import { Modal } from '@ownclouders/web-pkg'
import { mock } from 'vitest-mock-extended'
const SERVER_URL = 'https://example.org/'
const SELECTORS = Object.freeze({
iframe: '#iframe-folder-view'
})
describe('FolderViewModal', () => {
it('should set iframe src', () => {
const { wrapper } = getWrapper()
const iframe = wrapper.find(SELECTORS.iframe)
expect(iframe.attributes('src')).toEqual(
'https://example.org/public-link?hide-logo=true&hide-app-switcher=true&hide-account-menu=true&hide-navigation=true&lang=en&password-protected-folder-view=true'
)
})
it.each(['javascript:alert(1)', 'data:text/html,<script>alert(1)</script>', 'blob:fake'])(
'should throw when publicLink has a non-http(s) scheme: %s',
(invalidUrl) => {
expect(() => getWrapper({ publicLink: invalidUrl })).toThrow('Invalid URL scheme for iframe')
}
)
it('should throw when publicLink points to a different server', () => {
expect(() => getWrapper({ publicLink: 'https://other.example.com/public-link' })).toThrow(
'URL does not belong to this server'
)
})
})
function getWrapper({
publicLink = 'https://example.org/public-link',
serverUrl = SERVER_URL
} = {}) {
const mocks = defaultComponentMocks()
return {
mocks,
wrapper: shallowMount(FolderViewModal, {
props: {
modal: mock<Modal>(),
publicLink,
serverUrl
},
global: {
plugins: defaultPlugins(),
mocks,
provide: mocks
}
})
}
}