Skip to content

Commit b6e1994

Browse files
committed
fix(cypress): adjust selectors
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
1 parent 062876a commit b6e1994

File tree

13 files changed

+55
-24
lines changed

13 files changed

+55
-24
lines changed

apps/files/src/components/FileEntry.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
<template>
2424
<tr :class="{'files-list__row--visible': visible, 'files-list__row--active': isActive}"
25+
data-cy-files-list-row
26+
:data-cy-files-list-row-fileid="fileid"
27+
:data-cy-files-list-row-name="source.basename"
2528
class="list__row"
2629
@contextmenu="onRightClick">
2730
<!-- Failed indicator -->
@@ -38,7 +41,7 @@
3841
</td>
3942

4043
<!-- Link to file -->
41-
<td class="files-list__row-name">
44+
<td class="files-list__row-name" data-cy-files-list-row-name>
4245
<!-- Icon or preview -->
4346
<span class="files-list__row-icon" @click="execDefaultAction">
4447
<FolderIcon v-if="source.type === 'folder'" />
@@ -81,6 +84,7 @@
8184
ref="basename"
8285
:aria-hidden="isRenaming"
8386
class="files-list__row-name-link"
87+
data-cy-files-list-row-name-link
8488
v-bind="linkTo"
8589
@click="execDefaultAction">
8690
<!-- File name -->
@@ -93,7 +97,10 @@
9397
</td>
9498

9599
<!-- Actions -->
96-
<td v-show="!isRenamingSmallScreen" :class="`files-list__row-actions-${uniqueId}`" class="files-list__row-actions">
100+
<td v-show="!isRenamingSmallScreen"
101+
:class="`files-list__row-actions-${uniqueId}`"
102+
class="files-list__row-actions"
103+
data-cy-files-list-row-actions>
97104
<!-- Render actions -->
98105
<CustomElementRender v-for="action in enabledRenderActions"
99106
:key="action.id"
@@ -115,6 +122,7 @@
115122
:key="action.id"
116123
:class="'files-list__row-action-' + action.id"
117124
:close-after-click="true"
125+
:data-cy-files-list-row-action="action.id"
118126
@click="onActionClick(action)">
119127
<template #icon>
120128
<NcLoadingIcon v-if="loading === action.id" :size="18" />
@@ -129,13 +137,15 @@
129137
<td v-if="isSizeAvailable"
130138
:style="{ opacity: sizeOpacity }"
131139
class="files-list__row-size"
140+
data-cy-files-list-row-size
132141
@click="openDetailsIfAvailable">
133142
<span>{{ size }}</span>
134143
</td>
135144

136145
<!-- Mtime -->
137146
<td v-if="isMtimeAvailable"
138147
class="files-list__row-mtime"
148+
data-cy-files-list-row-mtime
139149
@click="openDetailsIfAvailable">
140150
<span>{{ mtime }}</span>
141151
</td>
@@ -145,6 +155,7 @@
145155
:key="column.id"
146156
:class="`files-list__row-${currentView?.id}-${column.id}`"
147157
class="files-list__row-column-custom"
158+
:data-cy-files-list-row-column-custom="column.id"
148159
@click="openDetailsIfAvailable">
149160
<CustomElementRender v-if="visible"
150161
:current-view="currentView"

apps/files/src/components/VirtualList.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<template>
2-
<table class="files-list">
2+
<table class="files-list" data-cy-files-list>
33
<!-- Header -->
44
<div ref="before" class="files-list__before">
55
<slot name="before" />
66
</div>
77

88
<!-- Header -->
9-
<thead ref="thead" class="files-list__thead">
9+
<thead ref="thead" class="files-list__thead" data-cy-files-list-thead>
1010
<slot name="header" />
1111
</thead>
1212

1313
<!-- Body -->
14-
<tbody :style="tbodyStyle" class="files-list__tbody">
14+
<tbody :style="tbodyStyle" class="files-list__tbody" data-cy-files-list-tbody>
1515
<component :is="dataComponent"
1616
v-for="(item, i) in renderedItems"
1717
:key="i"
@@ -22,7 +22,10 @@
2222
</tbody>
2323

2424
<!-- Footer -->
25-
<tfoot v-show="isReady" ref="tfoot" class="files-list__tfoot">
25+
<tfoot v-show="isReady"
26+
ref="tfoot"
27+
class="files-list__tfoot"
28+
data-cy-files-list-tfoot>
2629
<slot name="footer" />
2730
</tfoot>
2831
</table>

apps/files/src/router/router.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@
2121
*/
2222
import { generateUrl } from '@nextcloud/router'
2323
import queryString from 'query-string'
24-
import Router from 'vue-router'
24+
import Router, { RawLocation, Route } from 'vue-router'
2525
import Vue from 'vue'
26+
import { ErrorHandler } from 'vue-router/types/router'
2627

2728
Vue.use(Router)
2829

30+
// Prevent router from throwing errors when we're already on the page we're trying to go to
31+
const originalPush = Router.prototype.push as (to, onComplete?, onAbort?) => Promise<Route>
32+
Router.prototype.push = function push(to: RawLocation, onComplete?: ((route: Route) => void) | undefined, onAbort?: ErrorHandler | undefined): Promise<Route> {
33+
if (onComplete || onAbort) return originalPush.call(this, to, onComplete, onAbort)
34+
return originalPush.call(this, to).catch(err => err)
35+
}
36+
2937
const router = new Router({
3038
mode: 'history',
3139

apps/files/src/views/Sidebar.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,13 @@ export default {
374374
*/
375375
setActiveTab(id) {
376376
OCA.Files.Sidebar.setActiveTab(id)
377-
this.tabs.forEach(tab => tab.setIsActive(id === tab.id))
377+
this.tabs.forEach(tab => {
378+
try {
379+
tab.setIsActive(id === tab.id)
380+
} catch (error) {
381+
logger.error('Error while setting tab active state', { error, id: tab.id, tab })
382+
}
383+
})
378384
},
379385
380386
/**

apps/files_versions/src/files_versions_tab.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ window.addEventListener('DOMContentLoaded', function() {
6060
TabInstance.update(fileInfo)
6161
},
6262
setIsActive(isActive) {
63+
if (!TabInstance) {
64+
return
65+
}
6366
TabInstance.setIsActive(isActive)
6467
},
6568
destroy() {

cypress/e2e/files.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ describe('Login with a new user and open the files app', function() {
3232

3333
it('See the default file welcome.txt in the files list', function() {
3434
cy.visit('/apps/files')
35-
cy.get('.files-fileList tr').should('contain', 'welcome.txt')
35+
cy.get('[data-cy-files-list] [data-cy-files-list-row-name="welcome.txt"]').should('be.visible')
3636
})
3737
})

cypress/e2e/files_versions/filesVersionsUtils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ export function uploadThreeVersions(user: User, fileName: string) {
3636
}
3737

3838
export function openVersionsPanel(fileName: string) {
39-
cy.get(`[data-file="${fileName}"]`).within(() => {
40-
cy.get('[data-action="menu"]')
41-
.click()
42-
43-
cy.get('.fileActionsMenu')
44-
.get('.action-details')
39+
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${fileName}"]`).within(() => {
40+
cy.get('[data-cy-files-list-row-actions] .action-item__menutoggle')
4541
.click()
4642
})
4743

44+
cy.get('.action-item__popper')
45+
.get('[data-cy-files-list-row-action="details"]')
46+
.click()
47+
4848
cy.get('#app-sidebar-vue')
4949
.get('[aria-controls="tab-version_vue"]')
5050
.click()

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-sidebar.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)