Skip to content

Commit

Permalink
Merge pull request #1289 from nextcloud-libraries/feat/data-cy-attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Jul 25, 2024
2 parents b8aa8e9 + c89279a commit 75e423f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
18 changes: 9 additions & 9 deletions cypress/components/UploadPicker.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ describe('NewFileMenu handling', () => {
.should('exist')

cy.get('@menuButton').click()
cy.get('[data-cy-upload-picker-add]').should('have.length', 1)
cy.get('.upload-picker__menu-entry').should('have.length', 1)
cy.get('[data-cy-upload-picker-menu-entry="upload-file"]').should('have.length', 1)
cy.get('[data-cy-upload-picker-menu-entry="empty-file"]').should('have.length', 1)

cy.get('.upload-picker__menu-entry')
cy.get('[data-cy-upload-picker-menu-entry="empty-file"]')
.click()
.then(() => {
expect(entry.handler).to.be.called
Expand All @@ -328,13 +328,13 @@ describe('NewFileMenu handling', () => {
.should('exist')

cy.get('@menuButton').click()
cy.get('[data-cy-upload-picker-add]').should('have.length', 1)
cy.get('.upload-picker__menu-entry').should('have.length', 1)
cy.get('[data-cy-upload-picker-menu-entry="upload-file"]').should('have.length', 1)
cy.get('[data-cy-upload-picker-menu-entry="empty-file"]').should('have.length', 1)

// Close menu
cy.get('body').click()
cy.get('[data-cy-upload-picker-add]').should('not.be.visible')
cy.get('.upload-picker__menu-entry').should('not.be.visible')
cy.get('[data-cy-upload-picker-menu-entry="upload-file"]').should('not.be.visible')
cy.get('[data-cy-upload-picker-menu-entry="empty-file"]').should('not.be.visible')

cy.get('@component').then((component) => {
component.setDestination(new Folder({
Expand All @@ -350,8 +350,8 @@ describe('NewFileMenu handling', () => {
cy.get('[data-cy-upload-picker] .action-item__menutoggle')
.as('menuButton')
.should('not.exist')
cy.get('[data-cy-upload-picker-add]').should('have.length', 1)
cy.get('.upload-picker__menu-entry').should('not.exist')
cy.get('[data-cy-upload-picker-menu-entry="upload-file"]').should('have.length', 1)
cy.get('[data-cy-upload-picker-menu-entry="empty-file"]').should('not.exist')
})
})

Expand Down
10 changes: 9 additions & 1 deletion lib/components/UploadPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<NcButton v-if="newFileMenuEntries && newFileMenuEntries.length === 0"
:disabled="disabled"
data-cy-upload-picker-add
data-cy-upload-picker-menu-entry="upload-file"
type="secondary"
@click="onTriggerPick()">
<template #icon>
Expand All @@ -29,7 +30,10 @@

<NcActionCaption :name="t('Upload from device')" />

<NcActionButton data-cy-upload-picker-add :close-after-click="true" @click="onTriggerPick()">
<NcActionButton data-cy-upload-picker-add
data-cy-upload-picker-menu-entry="upload-file"
:close-after-click="true"
@click="onTriggerPick()">
<template #icon>
<IconUpload :size="20" />
</template>
Expand All @@ -38,6 +42,7 @@
<NcActionButton v-if="canUploadFolders"
close-after-click
data-cy-upload-picker-add-folders
data-cy-upload-picker-menu-entry="upload-folder"
@click="onTriggerPick(true)">
<template #icon>
<IconFolderUpload style="color: var(--color-primary-element)" :size="20" />
Expand All @@ -50,6 +55,7 @@
:key="entry.id"
:icon="entry.iconClass"
:close-after-click="true"
:data-cy-upload-picker-menu-entry="entry.id"
class="upload-picker__menu-entry"
@click="entry.handler(destination, currentContent)">
<template v-if="entry.iconSvgInline" #icon>
Expand All @@ -66,6 +72,7 @@
:key="entry.id"
:icon="entry.iconClass"
:close-after-click="true"
:data-cy-upload-picker-menu-entry="entry.id"
class="upload-picker__menu-entry"
@click="entry.handler(destination, currentContent)">
<template v-if="entry.iconSvgInline" #icon>
Expand All @@ -82,6 +89,7 @@
:key="entry.id"
:icon="entry.iconClass"
:close-after-click="true"
:data-cy-upload-picker-menu-entry="entry.id"
class="upload-picker__menu-entry"
@click="entry.handler(destination, currentContent)">
<template v-if="entry.iconSvgInline" #icon>
Expand Down

0 comments on commit 75e423f

Please sign in to comment.