Skip to content

Commit

Permalink
Merge pull request #1361 from nextcloud/fix/cypress
Browse files Browse the repository at this point in the history
fix(cypress): Make sure cypress tests work with upcoming Nextcloud 28
  • Loading branch information
susnux authored Oct 12, 2023
2 parents 585cd6b + ab9c080 commit 73348f6
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 17 deletions.
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default defineConfig({
async setupNodeEvents(on, config) {
// Fix browserslist extend https://github.com/cypress-io/cypress/issues/2983#issuecomment-570616682
on('file:preprocessor', browserify({ typescript: require.resolve('typescript') }))

// Enable the snapshot compare plugin
getCompareSnapshotsPlugin(on, config)

// Disable spell checking to prevent rendering differences
Expand Down
2 changes: 1 addition & 1 deletion cypress/dockerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const startNextcloud = async function(branch: string = 'master'): Promise
HostConfig: {
Binds: [
// TODO: improve local app directory detection
`${APP_PATH}/:/var/www/html/apps/${APP_NAME}`,
`${APP_PATH}/:/var/www/html/apps/${APP_NAME}:ro`,
],
},
Env: [
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/filesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ export function moveFile (fileName: string, dirName: string) {

export function toggleMenuAction(fileName: string) {
cy.get(`[data-cy-files-list] [data-cy-files-list-row-name="${fileName}"] [data-cy-files-list-row-actions] .action-item__menutoggle`).click()
cy.get('[data-cy-files-list-row-action]').should('be.visible')
}
17 changes: 9 additions & 8 deletions cypress/e2e/settings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,28 @@ describe('Check that user\'s settings survive a reload', () => {
it('Activity summary survive a reload', () => {
cy.intercept({ method: 'POST', url: '**/activity/settings' }).as('apiCall')

cy.get('#app-content')
.contains('Send daily activity summary in the morning')
cy.contains('[data-cy-checkbox]', 'Send daily activity summary in the morning')
.find('input')
.check({ force: true })
cy.get('#app-content')
.contains('Send daily activity summary in the morning')
cy.contains('[data-cy-checkbox]', 'Send daily activity summary in the morning')
.find('input')
.should('be.checked')
cy.wait('@apiCall')
.reload()

cy.get('#app-content')
.contains('Send daily activity summary in the morning')
cy.contains('[data-cy-checkbox]', 'Send daily activity summary in the morning')
.scrollIntoView()
.find('input')
.should('be.checked')

cy.contains('[data-cy-checkbox]', 'Send daily activity summary in the morning')
.find('input')
.uncheck({ force: true })
cy.wait('@apiCall')
.reload()

cy.get('#app-content')
.contains('Send daily activity summary in the morning')
cy.contains('[data-cy-checkbox]', 'Send daily activity summary in the morning')
.scrollIntoView()
.find('input')
.should('not.be.checked')
})
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/sidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { toggleMenuAction } from "./filesUtils"
function showSidebarForFile(fileName: string) {
closeSidebar()
toggleMenuAction(fileName)
cy.contains('Open details').click()
cy.get('[data-cy-files-list-row-action="details"]').click()
cy.get('#app-sidebar-vue').contains('Activity').click()
}

Expand All @@ -45,13 +45,13 @@ export function showActivityTab(fileName: string) {

export function addToFavorites(fileName: string) {
toggleMenuAction(fileName)
cy.contains('Add to favorites').click()
cy.get('[data-cy-files-list-row-action="favorite"]').should('contain', 'Add to favorites').click()
cy.get('.toast-close').click()
}

export function removeFromFavorites(fileName: string) {
toggleMenuAction(fileName)
cy.contains('Remove from favorites').click()
cy.get('[data-cy-files-list-row-action="favorite"]').should('contain', 'Remove from favorites').click()
cy.get('.toast-close').click()
}

Expand Down
1 change: 0 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ import { addCommands } from '@nextcloud/cypress'
// Add custom commands
import 'cypress-wait-until'
addCommands()

3 changes: 3 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
*
*/
import './commands'

// Ignore resize observer errors of Chrome, they are unrelated and save to ignore
Cypress.on('uncaught:exception', err => !err.message.includes('ResizeObserver'))
4 changes: 2 additions & 2 deletions js/activity-personalSettings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/activity-personalSettings.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/views/DailySummary.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template>
<NcSettingsSection :title="t('activity', 'Daily activity summary')">
<NcCheckboxRadioSwitch :checked="activityDigestEnabled" @update:checked="toggleActivityDigestEnabled({activityDigestEnabled: $event})">
<NcCheckboxRadioSwitch data-cy-checkbox
:checked="activityDigestEnabled"
@update:checked="toggleActivityDigestEnabled({activityDigestEnabled: $event})">
{{ t('activity', 'Send daily activity summary in the morning') }}
</NcCheckboxRadioSwitch>
</NcSettingsSection>
Expand Down

0 comments on commit 73348f6

Please sign in to comment.