Skip to content

Commit c84941a

Browse files
authored
Merge pull request #1452 from nextcloud/dependaskjnldsv/1437/stable25
[stable25] Fallback to direct image if preview load failed (+ cypress fixes)
2 parents a1c4f28 + 535df57 commit c84941a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1849
-1183
lines changed

.github/workflows/cypress.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
uses: skjnldsv/read-package-engines-version-actions@v1.1
2626
id: versions
2727
with:
28-
fallbackNode: '^12'
29-
fallbackNpm: '^6'
28+
fallbackNode: "^12"
29+
fallbackNpm: "^6"
3030

3131
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
3232
uses: actions/setup-node@v3
@@ -66,20 +66,10 @@ jobs:
6666
key: cypress-context-${{ github.run_id }}
6767
path: /home/runner/work/viewer
6868

69-
- name: Setup server
70-
run: |
71-
cd cypress
72-
docker-compose up -d
73-
74-
- name: Wait for server
75-
run: npm run wait-on $CYPRESS_baseUrl
76-
77-
- name: Enable app & configure server
78-
run: |
79-
cd cypress
80-
docker-compose exec --env APP_NAME=${{ env.APP_NAME }} --env BRANCH=${{ env.BRANCH }} -T nextcloud bash /initserver.sh
69+
- name: Pull server image
70+
run: docker pull ghcr.io/nextcloud/continuous-integration-shallow-server
8171

82-
- name: Cypress run
72+
- name: Run E2E cypress tests
8373
uses: cypress-io/github-action@v4
8474
with:
8575
record: true
@@ -88,10 +78,14 @@ jobs:
8878
ci-build-id: ${{ github.sha }}-${{ github.run_number }}
8979
tag: ${{ github.event_name }}
9080
env:
91-
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
81+
# Needs to be prefixed with CYPRESS_
82+
CYPRESS_BRANCH: ${{ env.BRANCH }}
9283
# https://github.com/cypress-io/github-action/issues/124
93-
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
84+
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
85+
# Needed for some specific code workarounds
9486
TESTING: true
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
9589

9690
- name: Upload snapshots
9791
uses: actions/upload-artifact@v3

cypress.config.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

cypress.config.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
import { configureNextcloud, startNextcloud, stopNextcloud, waitOnNextcloud } from './cypress/dockerNode'
3+
import { defineConfig } from 'cypress'
4+
5+
import browserify from '@cypress/browserify-preprocessor'
6+
import getCompareSnapshotsPlugin from 'cypress-visual-regression/dist/plugin'
7+
8+
export default defineConfig({
9+
projectId: 'xysa6x',
10+
11+
// 16/9 screen ratio
12+
viewportWidth: 1280,
13+
viewportHeight: 720,
14+
15+
// Tries again 2 more times on failure
16+
retries: {
17+
runMode: 2,
18+
// do not retry in `cypress open`
19+
openMode: 0,
20+
},
21+
22+
// Needed to trigger `after:run` events with cypress open
23+
experimentalInteractiveRunEvents: true,
24+
25+
// faster video processing
26+
videoCompression: false,
27+
28+
// Visual regression testing
29+
env: {
30+
failSilently: false,
31+
type: 'actual',
32+
},
33+
screenshotsFolder: 'cypress/snapshots/actual',
34+
trashAssetsBeforeRuns: true,
35+
36+
e2e: {
37+
// We've imported your old cypress plugins here.
38+
// You may want to clean this up later by importing these.
39+
async setupNodeEvents(on, config) {
40+
// Fix browserslist extend https://github.com/cypress-io/cypress/issues/2983#issuecomment-570616682
41+
on('file:preprocessor', browserify())
42+
// on('file:preprocessor', webpackPreprocessor({ webpackOptions }))
43+
getCompareSnapshotsPlugin(on, config)
44+
45+
// Disable spell checking to prevent rendering differences
46+
on('before:browser:launch', (browser, launchOptions) => {
47+
if (browser.family === 'chromium' && browser.name !== 'electron') {
48+
launchOptions.preferences.default['browser.enable_spellchecking'] = false
49+
return launchOptions
50+
}
51+
52+
if (browser.family === 'firefox') {
53+
launchOptions.preferences['layout.spellcheckDefault'] = 0
54+
return launchOptions
55+
}
56+
57+
if (browser.name === 'electron') {
58+
launchOptions.preferences.spellcheck = false
59+
return launchOptions
60+
}
61+
})
62+
63+
// Remove container after run
64+
on('after:run', () => {
65+
stopNextcloud()
66+
})
67+
68+
// Before the browser launches
69+
// starting Nextcloud testing container
70+
return startNextcloud(process.env.BRANCH)
71+
.then((ip) => {
72+
// Setting container's IP as base Url
73+
config.baseUrl = `http://${ip}/index.php`
74+
return ip
75+
})
76+
.then(waitOnNextcloud)
77+
.then(configureNextcloud)
78+
.then(() => {
79+
return config
80+
})
81+
},
82+
},
83+
})

cypress/docker-compose.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)