Skip to content

Commit b0db670

Browse files
committed
Cypress test
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
1 parent ea0dab0 commit b0db670

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

.eslintrc.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
module.exports = {
22
globals: {
3-
appVersion: true
3+
appVersion: true,
4+
isTesting: true,
45
},
56
extends: [
6-
'@nextcloud'
7-
]
7+
'@nextcloud',
8+
],
89
};

.github/workflows/cypress.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
working-directory: apps/${{ env.APP_NAME }}
5252
run: |
5353
npm ci
54-
npm run build --if-present
54+
TESTING=true npm run build --if-present
5555
5656
- name: Set up php ${{ matrix.php-versions }}
5757
uses: shivammathur/setup-php@v1

src/views/Viewer.vue

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@
2626
v-if="initiated || currentFile.modal"
2727
id="viewer-content"
2828
:class="{'icon-loading': !currentFile.loaded && !currentFile.failed}"
29+
:clear-view-delay="isTesting ? -1 : 5000 /* prevent cypress timeouts */"
2930
:dark="true"
30-
:view="currentFile.modal"
3131
:enable-slideshow="hasPrevious || hasNext"
32-
:spread-navigation="true"
33-
:has-previous="hasPrevious"
34-
:has-next="hasNext"
35-
:title="currentFile.basename"
3632
:enable-swipe="canSwipe"
33+
:has-next="hasNext"
34+
:has-previous="hasPrevious"
3735
:size="isMobile ? 'full' : 'large'"
36+
:spread-navigation="true"
3837
:style="{width: isSidebarShown ? `calc(100% - ${sidebarWidth}px)` : null}"
38+
:title="currentFile.basename"
39+
:view="currentFile.modal"
3940
@close="close"
4041
@previous="previous"
4142
@next="next">
@@ -129,35 +130,37 @@ export default {
129130
mixins: [isMobile, isFullscreen],
130131
131132
data: () => ({
132-
// reactivity bindings
133+
// Reactivity bindings
133134
Viewer: OCA.Viewer.state,
134135
Sidebar: null,
135136
handlers: OCA.Viewer.availableHandlers,
136137
138+
// Viewer variables
137139
components: {},
138140
mimeGroups: {},
139141
registeredHandlers: [],
140142
143+
// Files variables
141144
currentIndex: 0,
142145
previousFile: {},
143146
currentFile: {},
144147
nextFile: {},
145-
146148
fileList: [],
147149
150+
// States
148151
isLoaded: false,
149152
initiated: false,
150153
151154
// cancellable requests
152155
cancelRequestFile: () => {},
153156
cancelRequestFolder: () => {},
154157
155-
isSidebarShown: false,
158+
// Flags
156159
sidebarWidth: 0,
157-
160+
isSidebarShown: false,
158161
canSwipe: true,
159-
160-
standalone: !(OCA && OCA.Files && 'fileActions' in OCA.Files),
162+
isStandalone: !(OCA && OCA.Files && 'fileActions' in OCA.Files),
163+
isTesting,
161164
162165
root: getRootPath(),
163166
}),
@@ -284,7 +287,7 @@ export default {
284287
285288
window.addEventListener('resize', this.onResize)
286289
287-
if (this.standalone) {
290+
if (this.isStandalone) {
288291
console.debug('No OCA.Files app found, viewer is now in standalone mode')
289292
}
290293
},
@@ -545,7 +548,7 @@ export default {
545548
},
546549
547550
registerAction({ mime, group }) {
548-
if (!this.standalone) {
551+
if (!this.isStandalone) {
549552
// unregistered handler, let's go!
550553
OCA.Files.fileActions.registerAction({
551554
name: 'view',

webpack.common.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const StyleLintPlugin = require('stylelint-webpack-plugin')
55

66
const appName = process.env.npm_package_name
77
const appVersion = JSON.stringify(process.env.npm_package_version)
8+
const isTesting = !!process.env.TESTING
89

910
module.exports = {
1011
entry: path.join(__dirname, 'src', 'main.js'),
@@ -50,7 +51,7 @@ module.exports = {
5051
plugins: [
5152
new VueLoaderPlugin(),
5253
new StyleLintPlugin(),
53-
new webpack.DefinePlugin({ appVersion }),
54+
new webpack.DefinePlugin({ appVersion, isTesting }),
5455
],
5556
resolve: {
5657
alias: {
@@ -61,6 +62,6 @@ module.exports = {
6162
Services: path.resolve(__dirname, 'src/services/'),
6263
Views: path.resolve(__dirname, 'src/views/'),
6364
},
64-
extensions: ['*', '.js', '.vue', '.json'],
65+
extensions: ['*', '.js', '.vue'],
6566
},
6667
}

0 commit comments

Comments
 (0)