Skip to content

Commit

Permalink
Merge pull request #2187 from nextcloud/fix/cypress
Browse files Browse the repository at this point in the history
fix: cypress
  • Loading branch information
skjnldsv authored Mar 7, 2024
2 parents 4392412 + 3b5e864 commit eb5068f
Show file tree
Hide file tree
Showing 8 changed files with 1,172 additions and 74 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
fallbackNpm: "^10"

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

Expand All @@ -74,8 +74,11 @@ jobs:
fail-fast: false
matrix:
# Run multiple copies of the current job in parallel
# Please increase the number or runners as your tests suite grows
containers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Please increase the number or runners as your tests suite grows (0 based index for e2e tests)
containers: [0, 1, 2, 3, 4, 5, 6, 7]
# Hack as strategy.job-total includes the component and GitHub does not allow math expressions
# Always aling this number with the total of e2e runners (max. index + 1)
total-containers: [8]

name: runner ${{ matrix.containers }}

Expand All @@ -88,7 +91,7 @@ jobs:
path: ./

- name: Set up node ${{ needs.init.outputs.nodeVersion }}
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ needs.init.outputs.nodeVersion }}

Expand All @@ -98,14 +101,11 @@ jobs:
- name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
uses: cypress-io/github-action@1b70233146622b69e789ccdd4f9452adc638d25a # v6.6.1
with:
record: true
parallel: true
# cypress run type
component: ${{ matrix.containers == 'component' }}
group: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }}
group: ${{ matrix.use-cypress-cloud && matrix.containers == 'component' && 'Run component' || matrix.use-cypress-cloud && 'Run E2E' || '' }}
# cypress env
ci-build-id: ${{ github.sha }}-${{ github.run_number }}
tag: ${{ github.event_name }}
ci-build-id: ${{ matrix.use-cypress-cloud && format('{0}-{1}', github.sha, github.run_number) || '' }}
tag: ${{ matrix.use-cypress-cloud && github.event_name || '' }}
env:
# Needs to be prefixed with CYPRESS_
CYPRESS_BRANCH: ${{ env.BRANCH }}
Expand All @@ -115,9 +115,11 @@ jobs:
TESTING: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
SPLIT: ${{ matrix.total-containers }}
SPLIT_INDEX: ${{ matrix.containers == 'component' && 0 || matrix.containers }}

- name: Upload snapshots
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: always()
with:
name: snapshots_${{ matrix.containers }}
Expand All @@ -128,14 +130,14 @@ jobs:
run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log

- name: Upload NC logs
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: failure() && matrix.containers != 'component'
with:
name: nc_logs_${{ matrix.containers }}
path: nextcloud.log

summary:
runs-on: ubuntu-latest
runs-on: ubuntu-latest-low
needs: [init, cypress]

if: always()
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ jobs:
npm run build --if-present
npm run stats --if-present
- name: Send bundle stats to RelativeCI
uses: relative-ci/agent-action@6a11b7d7fdd6670554fba1e1a40750daa33032d7 # v2
with:
webpackStatsFile: ./webpack-stats.json
key: ${{ secrets.RELATIVE_CI_KEY }}
token: ${{ secrets.GITHUB_TOKEN }}
# Disabled, vite doesn't support statistics yet
# - name: Send bundle stats to RelativeCI
# uses: relative-ci/agent-action@6a11b7d7fdd6670554fba1e1a40750daa33032d7 # v2
# with:
# webpackStatsFile: ./webpack-stats.json
# key: ${{ secrets.RELATIVE_CI_KEY }}
# token: ${{ secrets.GITHUB_TOKEN }}

- name: Check webpack build changes
run: |
Expand Down
4 changes: 2 additions & 2 deletions css/viewer-main.css

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { configureNextcloud, startNextcloud, stopNextcloud, waitOnNextcloud } from '@nextcloud/cypress/docker'
import { defineConfig } from 'cypress'
import cypressSplit from 'cypress-split'

import getCompareSnapshotsPlugin from 'cypress-visual-regression/dist/plugin'

Expand All @@ -20,8 +21,8 @@ export default defineConfig({
// Needed to trigger `after:run` events with cypress open
experimentalInteractiveRunEvents: true,

// Faster processing, video is broken on GH actions anyway
video: false,
// faster video processing
videoCompression: false,

// Visual regression testing
env: {
Expand All @@ -32,12 +33,14 @@ export default defineConfig({
trashAssetsBeforeRuns: true,

e2e: {
// Disable isolation
// Disable session isolation
testIsolation: false,

// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
async setupNodeEvents(on, config) {
cypressSplit(on, config)

getCompareSnapshotsPlugin(on, config)

// Disable spell checking to prevent rendering differences
Expand Down
21 changes: 13 additions & 8 deletions cypress/e2e/sharing/download-share-disabled.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe(`Download ${fileName} in viewer`, function() {
.should('contain', 'image2 .jpg')
})

it('Share the Photos folder with a share link and access the share link', function() {
it('Share the Photos folder with a share link, disable download and access the share link', function() {
cy.on('uncaught:exception', (err) => {
// This can happen because of blink engine handling animation, its not a bug just engine related.
if (err.message.includes('ResizeObserver loop limit exceeded')) {
Expand All @@ -63,17 +63,22 @@ describe(`Download ${fileName} in viewer`, function() {
})

cy.createLinkShare('/Photos').then(token => {
// Open the sidebar
cy.visit('/apps/files')
cy.getFile('Photos').clickAction('details')
cy.intercept('GET', '**/apps/files_sharing/api/v1/shares*').as('sharingAPI')

// Open the sidebar from the breadcrumbs
cy.get('[data-cy-files-content-breadcrumbs] .files-list__header-share-button').click()
cy.get('aside.app-sidebar').should('be.visible')
cy.get('[role="tablist"]').contains('[role="tab"]', 'Sharing').click()

// Wait for the sidebar to be done loading
cy.wait('@sharingAPI', { timeout: 10000 })

// Open the share menu
cy.get('.sharing-link-list > .sharing-entry [aria-label*=\'Actions for "Share link"\']').click()
cy.get('.sharing-link-list > .sharing-entry button[aria-label*="Actions for "]').click()
cy.get('.action-button:contains(\'Customize link\')').click()
cy.get('label:contains(\'Hide download\')').as('hideDownloadBtn').click()
cy.get('@hideDownloadBtn').prev('input[type=checkbox]').should('be.checked')
cy.get('.checkbox-radio-switch-checkbox').contains('Hide download').as('hideDownloadBtn')
// click the label
cy.get('@hideDownloadBtn').get('span').contains('Hide download').click()
cy.get('@hideDownloadBtn').get('input[type=checkbox]').should('be.checked')

// Log out and access link share
cy.logout()
Expand Down
4 changes: 4 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ Cypress.Commands.add('deleteFile', fileName => {
cy.getFile(fileName).clickAction('delete')
})

Cypress.Commands.add('reloadCurrentFilesList', () => {
cy.get('[data-cy-files-content-breadcrumbs] a[title="Reload current directory"]').click()
})

Cypress.Commands.add(
'clickAction',
{ prevSubject: 'element' },
Expand Down
Loading

0 comments on commit eb5068f

Please sign in to comment.