Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ jobs:
matrix:
# Run multiple copies of the current job in parallel
# Please increase the number or runners as your tests suite grows (0 based index for e2e tests)
containers: ['component', 'setup', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
# Hack as strategy.job-total includes the component and GitHub does not allow math expressions
containers: ['setup', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
# Hack as strategy.job-total includes the "setup" and GitHub does not allow math expressions
# Always align this number with the total of e2e runners (max. index + 1)
total-containers: [10]

Expand Down
1 change: 1 addition & 0 deletions __tests__/setup-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: CC0-1.0
*/

export function setup() {
process.env.TZ = 'UTC'
}
1 change: 1 addition & 0 deletions __tests__/setup-testing-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: CC0-1.0
*/

import '@testing-library/jest-dom/vitest'
import 'core-js/stable/index.js'
123 changes: 0 additions & 123 deletions apps/federatedfilesharing/src/components/RemoteShareDialog.cy.ts

This file was deleted.

115 changes: 115 additions & 0 deletions apps/federatedfilesharing/src/components/RemoteShareDialog.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { cleanup, fireEvent, render } from '@testing-library/vue'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import RemoteShareDialog from './RemoteShareDialog.vue'

describe('RemoteShareDialog', () => {
beforeEach(cleanup)

it('can be mounted', async () => {
const component = render(RemoteShareDialog, {
props: {
owner: 'user123',
name: 'my-photos',
remote: 'nextcloud.local',
passwordRequired: false,
},
})

await expect(component.findByRole('dialog', { name: 'Remote share' })).resolves.not.toThrow()
expect(component.getByRole('dialog').innerText).toContain(/my-photos from [email protected]/)
await expect(component.findByRole('button', { name: 'Cancel' })).resolves.not.toThrow()
await expect(component.findByRole('button', { name: /Add remote share/ })).resolves.not.toThrow()
})

it('does not show password input if not enabled', async () => {
const component = render(RemoteShareDialog, {
props: {
owner: 'user123',
name: 'my-photos',
remote: 'nextcloud.local',
passwordRequired: false,
},
})

await expect(component.findByLabelText('Remote share password')).rejects.toThrow()
})

it('emits true when accepted', () => {
const onClose = vi.fn()

const component = render(RemoteShareDialog, {
listeners: {
close: onClose,
},
props: {
owner: 'user123',
name: 'my-photos',
remote: 'nextcloud.local',
passwordRequired: false,
},
})

component.getByRole('button', { name: 'Cancel' }).click()
expect(onClose).toHaveBeenCalledWith(false)
})

it('show password input if needed', async () => {
const component = render(RemoteShareDialog, {
props: {
owner: 'admin',
name: 'secret-data',
remote: 'nextcloud.local',
passwordRequired: true,
},
})

await expect(component.findByLabelText('Remote share password')).resolves.not.toThrow()
})

it('emits the submitted password', async () => {
const onClose = vi.fn()

const component = render(RemoteShareDialog, {
listeners: {
close: onClose,
},
props: {
owner: 'admin',
name: 'secret-data',
remote: 'nextcloud.local',
passwordRequired: true,
},
})

const input = component.getByLabelText('Remote share password')
await fireEvent.update(input, 'my password')
component.getByRole('button', { name: 'Add remote share' }).click()
expect(onClose).toHaveBeenCalledWith(true, 'my password')
})

it('emits no password if cancelled', async () => {
const onClose = vi.fn()

const component = render(RemoteShareDialog, {
listeners: {
close: onClose,
},
props: {
owner: 'admin',
name: 'secret-data',
remote: 'nextcloud.local',
passwordRequired: true,
},
})

const input = component.getByLabelText('Remote share password')
await fireEvent.update(input, 'my password')
component.getByRole('button', { name: 'Cancel' }).click()
expect(onClose).toHaveBeenCalledWith(false)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const buttons = computed(() => [
},
{
label: t('federatedfilesharing', 'Add remote share'),
nativeType: props.passwordRequired ? 'submit' : undefined,
type: 'primary',
type: props.passwordRequired ? 'submit' : undefined,
variant: 'primary',
callback: () => emit('close', true, password.value),
},
])
Expand Down
55 changes: 0 additions & 55 deletions apps/files/src/composables/useFileListWidth.cy.ts

This file was deleted.

Loading
Loading