-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48725 from nextcloud/chore/remove-old-test
- Loading branch information
Showing
35 changed files
with
639 additions
and
471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
* SPDX-License-Identifier: CC0-1.0 | ||
*/ | ||
import '@testing-library/jest-dom/vitest' | ||
import 'core-js/stable/index.js' |
123 changes: 123 additions & 0 deletions
123
apps/federatedfilesharing/src/components/RemoteShareDialog.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import RemoteShareDialog from './RemoteShareDialog.vue' | ||
|
||
describe('RemoteShareDialog', () => { | ||
it('can be mounted', () => { | ||
cy.mount(RemoteShareDialog, { | ||
propsData: { | ||
owner: 'user123', | ||
name: 'my-photos', | ||
remote: 'nextcloud.local', | ||
passwordRequired: false, | ||
}, | ||
}) | ||
|
||
cy.findByRole('dialog') | ||
.should('be.visible') | ||
.and('contain.text', 'user123@nextcloud.local') | ||
.and('contain.text', 'my-photos') | ||
cy.findByRole('button', { name: 'Cancel' }) | ||
.should('be.visible') | ||
cy.findByRole('button', { name: /add remote share/i }) | ||
.should('be.visible') | ||
}) | ||
|
||
it('does not show password input if not enabled', () => { | ||
cy.mount(RemoteShareDialog, { | ||
propsData: { | ||
owner: 'user123', | ||
name: 'my-photos', | ||
remote: 'nextcloud.local', | ||
passwordRequired: false, | ||
}, | ||
}) | ||
|
||
cy.findByRole('dialog') | ||
.should('be.visible') | ||
.find('input[type="password"]') | ||
.should('not.exist') | ||
}) | ||
|
||
it('emits true when accepted', () => { | ||
const onClose = cy.spy().as('onClose') | ||
|
||
cy.mount(RemoteShareDialog, { | ||
listeners: { | ||
close: onClose, | ||
}, | ||
propsData: { | ||
owner: 'user123', | ||
name: 'my-photos', | ||
remote: 'nextcloud.local', | ||
passwordRequired: false, | ||
}, | ||
}) | ||
|
||
cy.findByRole('button', { name: 'Cancel' }).click() | ||
cy.get('@onClose') | ||
.should('have.been.calledWith', false) | ||
}) | ||
|
||
it('show password input if needed', () => { | ||
cy.mount(RemoteShareDialog, { | ||
propsData: { | ||
owner: 'admin', | ||
name: 'secret-data', | ||
remote: 'nextcloud.local', | ||
passwordRequired: true, | ||
}, | ||
}) | ||
|
||
cy.findByRole('dialog') | ||
.should('be.visible') | ||
.find('input[type="password"]') | ||
.should('be.visible') | ||
}) | ||
|
||
it('emits the submitted password', () => { | ||
const onClose = cy.spy().as('onClose') | ||
|
||
cy.mount(RemoteShareDialog, { | ||
listeners: { | ||
close: onClose, | ||
}, | ||
propsData: { | ||
owner: 'admin', | ||
name: 'secret-data', | ||
remote: 'nextcloud.local', | ||
passwordRequired: true, | ||
}, | ||
}) | ||
|
||
cy.get('input[type="password"]') | ||
.type('my password{enter}') | ||
cy.get('@onClose') | ||
.should('have.been.calledWith', true, 'my password') | ||
}) | ||
|
||
it('emits no password if cancelled', () => { | ||
const onClose = cy.spy().as('onClose') | ||
|
||
cy.mount(RemoteShareDialog, { | ||
listeners: { | ||
close: onClose, | ||
}, | ||
propsData: { | ||
owner: 'admin', | ||
name: 'secret-data', | ||
remote: 'nextcloud.local', | ||
passwordRequired: true, | ||
}, | ||
}) | ||
|
||
cy.get('input[type="password"]') | ||
.type('my password') | ||
cy.findByRole('button', { name: 'Cancel' }).click() | ||
cy.get('@onClose') | ||
.should('have.been.calledWith', false) | ||
}) | ||
}) |
67 changes: 67 additions & 0 deletions
67
apps/federatedfilesharing/src/components/RemoteShareDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!-- | ||
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
- SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
<script setup lang="ts"> | ||
import { t } from '@nextcloud/l10n' | ||
import { computed, ref } from 'vue' | ||
import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js' | ||
import NcPasswordField from '@nextcloud/vue/dist/Components/NcPasswordField.js' | ||
|
||
const props = defineProps<{ | ||
/** Name of the share */ | ||
name: string | ||
/** Display name of the owner */ | ||
owner: string | ||
/** The remote instance name */ | ||
remote: string | ||
/** True if the user should enter a password */ | ||
passwordRequired: boolean | ||
}>() | ||
|
||
const emit = defineEmits<{ | ||
(e: 'close', state: boolean, password?: string): void | ||
}>() | ||
|
||
const password = ref('') | ||
|
||
/** | ||
* The dialog buttons | ||
*/ | ||
const buttons = computed(() => [ | ||
{ | ||
label: t('federatedfilesharing', 'Cancel'), | ||
callback: () => emit('close', false), | ||
}, | ||
{ | ||
label: t('federatedfilesharing', 'Add remote share'), | ||
nativeType: props.passwordRequired ? 'submit' : undefined, | ||
type: 'primary', | ||
callback: () => emit('close', true, password.value), | ||
}, | ||
]) | ||
</script> | ||
|
||
<template> | ||
<NcDialog :buttons="buttons" | ||
:is-form="passwordRequired" | ||
:name="t('federatedfilesharing', 'Remote share')" | ||
@submit="emit('close', true, password)"> | ||
<p> | ||
{{ t('federatedfilesharing', 'Do you want to add the remote share {name} from {owner}@{remote}?', { name, owner, remote }) }} | ||
</p> | ||
<NcPasswordField v-if="passwordRequired" | ||
class="remote-share-dialog__password" | ||
:label="t('federatedfilesharing', 'Remote share password')" | ||
:value.sync="password" /> | ||
</NcDialog> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.remote-share-dialog { | ||
|
||
&__password { | ||
margin-block: 1em .5em; | ||
} | ||
} | ||
</style> |
Oops, something went wrong.