Skip to content

Commit 75e423f

Browse files
authored
Merge pull request #1289 from nextcloud-libraries/feat/data-cy-attrs
2 parents b8aa8e9 + c89279a commit 75e423f

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

cypress/components/UploadPicker.cy.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,10 @@ describe('NewFileMenu handling', () => {
306306
.should('exist')
307307

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

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

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

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

339339
cy.get('@component').then((component) => {
340340
component.setDestination(new Folder({
@@ -350,8 +350,8 @@ describe('NewFileMenu handling', () => {
350350
cy.get('[data-cy-upload-picker] .action-item__menutoggle')
351351
.as('menuButton')
352352
.should('not.exist')
353-
cy.get('[data-cy-upload-picker-add]').should('have.length', 1)
354-
cy.get('.upload-picker__menu-entry').should('not.exist')
353+
cy.get('[data-cy-upload-picker-menu-entry="upload-file"]').should('have.length', 1)
354+
cy.get('[data-cy-upload-picker-menu-entry="empty-file"]').should('not.exist')
355355
})
356356
})
357357

lib/components/UploadPicker.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<NcButton v-if="newFileMenuEntries && newFileMenuEntries.length === 0"
1313
:disabled="disabled"
1414
data-cy-upload-picker-add
15+
data-cy-upload-picker-menu-entry="upload-file"
1516
type="secondary"
1617
@click="onTriggerPick()">
1718
<template #icon>
@@ -29,7 +30,10 @@
2930

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

32-
<NcActionButton data-cy-upload-picker-add :close-after-click="true" @click="onTriggerPick()">
33+
<NcActionButton data-cy-upload-picker-add
34+
data-cy-upload-picker-menu-entry="upload-file"
35+
:close-after-click="true"
36+
@click="onTriggerPick()">
3337
<template #icon>
3438
<IconUpload :size="20" />
3539
</template>
@@ -38,6 +42,7 @@
3842
<NcActionButton v-if="canUploadFolders"
3943
close-after-click
4044
data-cy-upload-picker-add-folders
45+
data-cy-upload-picker-menu-entry="upload-folder"
4146
@click="onTriggerPick(true)">
4247
<template #icon>
4348
<IconFolderUpload style="color: var(--color-primary-element)" :size="20" />
@@ -50,6 +55,7 @@
5055
:key="entry.id"
5156
:icon="entry.iconClass"
5257
:close-after-click="true"
58+
:data-cy-upload-picker-menu-entry="entry.id"
5359
class="upload-picker__menu-entry"
5460
@click="entry.handler(destination, currentContent)">
5561
<template v-if="entry.iconSvgInline" #icon>
@@ -66,6 +72,7 @@
6672
:key="entry.id"
6773
:icon="entry.iconClass"
6874
:close-after-click="true"
75+
:data-cy-upload-picker-menu-entry="entry.id"
6976
class="upload-picker__menu-entry"
7077
@click="entry.handler(destination, currentContent)">
7178
<template v-if="entry.iconSvgInline" #icon>
@@ -82,6 +89,7 @@
8289
:key="entry.id"
8390
:icon="entry.iconClass"
8491
:close-after-click="true"
92+
:data-cy-upload-picker-menu-entry="entry.id"
8593
class="upload-picker__menu-entry"
8694
@click="entry.handler(destination, currentContent)">
8795
<template v-if="entry.iconSvgInline" #icon>

0 commit comments

Comments
 (0)