Skip to content

Commit

Permalink
fix(cypress): adjust selectors
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Aug 16, 2023
1 parent 062876a commit b6e1994
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 24 deletions.
15 changes: 13 additions & 2 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

<template>
<tr :class="{'files-list__row--visible': visible, 'files-list__row--active': isActive}"
data-cy-files-list-row
:data-cy-files-list-row-fileid="fileid"
:data-cy-files-list-row-name="source.basename"
class="list__row"
@contextmenu="onRightClick">
<!-- Failed indicator -->
Expand All @@ -38,7 +41,7 @@
</td>

<!-- Link to file -->
<td class="files-list__row-name">
<td class="files-list__row-name" data-cy-files-list-row-name>
<!-- Icon or preview -->
<span class="files-list__row-icon" @click="execDefaultAction">
<FolderIcon v-if="source.type === 'folder'" />
Expand Down Expand Up @@ -81,6 +84,7 @@
ref="basename"
:aria-hidden="isRenaming"
class="files-list__row-name-link"
data-cy-files-list-row-name-link
v-bind="linkTo"
@click="execDefaultAction">
<!-- File name -->
Expand All @@ -93,7 +97,10 @@
</td>

<!-- Actions -->
<td v-show="!isRenamingSmallScreen" :class="`files-list__row-actions-${uniqueId}`" class="files-list__row-actions">
<td v-show="!isRenamingSmallScreen"
:class="`files-list__row-actions-${uniqueId}`"
class="files-list__row-actions"
data-cy-files-list-row-actions>
<!-- Render actions -->
<CustomElementRender v-for="action in enabledRenderActions"
:key="action.id"
Expand All @@ -115,6 +122,7 @@
:key="action.id"
:class="'files-list__row-action-' + action.id"
:close-after-click="true"
:data-cy-files-list-row-action="action.id"
@click="onActionClick(action)">
<template #icon>
<NcLoadingIcon v-if="loading === action.id" :size="18" />
Expand All @@ -129,13 +137,15 @@
<td v-if="isSizeAvailable"
:style="{ opacity: sizeOpacity }"
class="files-list__row-size"
data-cy-files-list-row-size
@click="openDetailsIfAvailable">
<span>{{ size }}</span>
</td>

<!-- Mtime -->
<td v-if="isMtimeAvailable"
class="files-list__row-mtime"
data-cy-files-list-row-mtime
@click="openDetailsIfAvailable">
<span>{{ mtime }}</span>
</td>
Expand All @@ -145,6 +155,7 @@
:key="column.id"
:class="`files-list__row-${currentView?.id}-${column.id}`"
class="files-list__row-column-custom"
:data-cy-files-list-row-column-custom="column.id"
@click="openDetailsIfAvailable">
<CustomElementRender v-if="visible"
:current-view="currentView"
Expand Down
11 changes: 7 additions & 4 deletions apps/files/src/components/VirtualList.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<template>
<table class="files-list">
<table class="files-list" data-cy-files-list>
<!-- Header -->
<div ref="before" class="files-list__before">
<slot name="before" />
</div>

<!-- Header -->
<thead ref="thead" class="files-list__thead">
<thead ref="thead" class="files-list__thead" data-cy-files-list-thead>
<slot name="header" />
</thead>

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

<!-- Footer -->
<tfoot v-show="isReady" ref="tfoot" class="files-list__tfoot">
<tfoot v-show="isReady"
ref="tfoot"
class="files-list__tfoot"
data-cy-files-list-tfoot>
<slot name="footer" />
</tfoot>
</table>
Expand Down
10 changes: 9 additions & 1 deletion apps/files/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@
*/
import { generateUrl } from '@nextcloud/router'
import queryString from 'query-string'
import Router from 'vue-router'
import Router, { RawLocation, Route } from 'vue-router'
import Vue from 'vue'
import { ErrorHandler } from 'vue-router/types/router'

Vue.use(Router)

// Prevent router from throwing errors when we're already on the page we're trying to go to
const originalPush = Router.prototype.push as (to, onComplete?, onAbort?) => Promise<Route>
Router.prototype.push = function push(to: RawLocation, onComplete?: ((route: Route) => void) | undefined, onAbort?: ErrorHandler | undefined): Promise<Route> {
if (onComplete || onAbort) return originalPush.call(this, to, onComplete, onAbort)
return originalPush.call(this, to).catch(err => err)
}

const router = new Router({
mode: 'history',

Expand Down
8 changes: 7 additions & 1 deletion apps/files/src/views/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,13 @@ export default {
*/
setActiveTab(id) {
OCA.Files.Sidebar.setActiveTab(id)
this.tabs.forEach(tab => tab.setIsActive(id === tab.id))
this.tabs.forEach(tab => {
try {
tab.setIsActive(id === tab.id)
} catch (error) {
logger.error('Error while setting tab active state', { error, id: tab.id, tab })
}
})
},

/**
Expand Down
3 changes: 3 additions & 0 deletions apps/files_versions/src/files_versions_tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ window.addEventListener('DOMContentLoaded', function() {
TabInstance.update(fileInfo)
},
setIsActive(isActive) {
if (!TabInstance) {
return
}
TabInstance.setIsActive(isActive)
},
destroy() {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/files.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ describe('Login with a new user and open the files app', function() {

it('See the default file welcome.txt in the files list', function() {
cy.visit('/apps/files')
cy.get('.files-fileList tr').should('contain', 'welcome.txt')
cy.get('[data-cy-files-list] [data-cy-files-list-row-name="welcome.txt"]').should('be.visible')
})
})
12 changes: 6 additions & 6 deletions cypress/e2e/files_versions/filesVersionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ export function uploadThreeVersions(user: User, fileName: string) {
}

export function openVersionsPanel(fileName: string) {
cy.get(`[data-file="${fileName}"]`).within(() => {
cy.get('[data-action="menu"]')
.click()

cy.get('.fileActionsMenu')
.get('.action-details')
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${fileName}"]`).within(() => {
cy.get('[data-cy-files-list-row-actions] .action-item__menutoggle')
.click()
})

cy.get('.action-item__popper')
.get('[data-cy-files-list-row-action="details"]')
.click()

cy.get('#app-sidebar-vue')
.get('[aria-controls="tab-version_vue"]')
.click()
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-sidebar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-sidebar.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_versions-files_versions.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_versions-files_versions.js.map

Large diffs are not rendered by default.

0 comments on commit b6e1994

Please sign in to comment.