test(cypress): Move to @nextcloud/cypress
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -11,7 +11,6 @@ module.exports = defineConfig({
|
||||
return require('./cypress/plugins/index.js')(on, config)
|
||||
},
|
||||
baseUrl: 'http://nextcloud.local/index.php',
|
||||
experimentalSessionAndOrigin: true,
|
||||
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { randHash } from '../utils/index.js'
|
||||
const randUser = randHash()
|
||||
import { randUser } from '../utils/index.js'
|
||||
const user = randUser()
|
||||
|
||||
describe('Board', function() {
|
||||
const password = 'pass123'
|
||||
|
||||
before(function() {
|
||||
cy.nextcloudCreateUser(randUser, password)
|
||||
cy.createUser(user)
|
||||
})
|
||||
|
||||
beforeEach(function() {
|
||||
cy.login(randUser, password)
|
||||
cy.login(user)
|
||||
cy.visit('/apps/deck')
|
||||
})
|
||||
|
||||
it('Can create a board', function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { randHash } from '../utils/index.js'
|
||||
const randUser = randHash()
|
||||
import { randUser } from '../utils/index.js'
|
||||
const user = randUser()
|
||||
|
||||
const testBoardData = {
|
||||
title: 'MyBoardTest',
|
||||
@@ -18,16 +18,18 @@ const testBoardData = {
|
||||
|
||||
describe('Card', function() {
|
||||
before(function() {
|
||||
cy.nextcloudCreateUser(randUser, randUser)
|
||||
cy.createUser(user)
|
||||
cy.login(user)
|
||||
cy.createExampleBoard({
|
||||
user: randUser,
|
||||
password: randUser,
|
||||
user: user.userId,
|
||||
password: user.password,
|
||||
board: testBoardData,
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(function() {
|
||||
cy.login(randUser, randUser)
|
||||
cy.login(user)
|
||||
cy.visit('/apps/deck')
|
||||
})
|
||||
|
||||
it('Can show card details modal', function() {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { randHash } from '../utils/index.js'
|
||||
const randUser = randHash()
|
||||
import { randUser } from '../utils/index.js'
|
||||
const user = randUser()
|
||||
|
||||
describe('Deck dashboard', function() {
|
||||
const password = 'pass123'
|
||||
|
||||
before(function() {
|
||||
cy.nextcloudCreateUser(randUser, password)
|
||||
cy.createUser(user)
|
||||
})
|
||||
|
||||
beforeEach(function() {
|
||||
cy.login(randUser, password)
|
||||
cy.login(user)
|
||||
cy.visit('/apps/deck')
|
||||
})
|
||||
|
||||
it('Can show the right title on the dashboard', function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { randHash } from '../utils/index.js'
|
||||
const randUser = randHash()
|
||||
import { randUser } from '../utils/index.js'
|
||||
const user = randUser()
|
||||
|
||||
const boardTitle = 'TestBoard'
|
||||
const testBoardData = {
|
||||
@@ -11,20 +11,20 @@ const testBoardData = {
|
||||
}
|
||||
|
||||
describe('Stack', function() {
|
||||
const password = 'pass123'
|
||||
|
||||
before(function() {
|
||||
cy.nextcloudCreateUser(randUser, password)
|
||||
cy.createUser(user)
|
||||
cy.login(user)
|
||||
cy.createExampleBoard({
|
||||
user: randUser,
|
||||
password,
|
||||
user: user.userId,
|
||||
password: user.password,
|
||||
board: testBoardData,
|
||||
})
|
||||
})
|
||||
|
||||
beforeEach(function() {
|
||||
cy.logout()
|
||||
cy.login(randUser, password)
|
||||
cy.login(user)
|
||||
cy.visit('/apps/deck')
|
||||
|
||||
cy.openLeftSidebar()
|
||||
cy.getNavigationEntry(boardTitle)
|
||||
@@ -40,13 +40,13 @@ describe('Stack', function() {
|
||||
})
|
||||
|
||||
it('Can edit a stack title', function() {
|
||||
cy.contains('Existing Stack1')
|
||||
cy.get('[data-cy-stack="Existing Stack1"]').within(() => {
|
||||
cy.contains('Existing Stack1').click()
|
||||
cy.focused().type(' with a new title')
|
||||
cy.focused().type(' renamed')
|
||||
cy.get('[data-cy="editStackTitleForm"] input[type="submit"]').click()
|
||||
|
||||
cy.contains('Existing Stack1 with a new title').should('be.visible')
|
||||
})
|
||||
cy.contains('Existing Stack1 renamed').should('be.visible')
|
||||
})
|
||||
|
||||
it('Can abort a stack title edit via esc', function() {
|
||||
|
||||
@@ -20,61 +20,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
import { addCommands } from '@nextcloud/cypress'
|
||||
|
||||
addCommands()
|
||||
|
||||
const url = Cypress.config('baseUrl').replace(/\/index.php\/?$/g, '')
|
||||
Cypress.env('baseUrl', url)
|
||||
|
||||
Cypress.Commands.add('login', (user, password, route = '/apps/deck/') => {
|
||||
const session = `${user}-${Date.now()}`
|
||||
cy.session(session, function() {
|
||||
cy.visit(route)
|
||||
cy.get('input[name=user]').type(user)
|
||||
cy.get('input[name=password]').type(password)
|
||||
cy.get('form[name=login] [type=submit]').click()
|
||||
cy.url().should('include', route)
|
||||
})
|
||||
cy.visit(route)
|
||||
})
|
||||
|
||||
Cypress.Commands.add('logout', (route = '/') => {
|
||||
cy.session('_guest', function() {})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('nextcloudCreateUser', (user, password) => {
|
||||
cy.clearCookies()
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `${Cypress.env('baseUrl')}/ocs/v1.php/cloud/users?format=json`,
|
||||
form: true,
|
||||
body: {
|
||||
userid: user,
|
||||
password,
|
||||
},
|
||||
auth: { user: 'admin', pass: 'admin' },
|
||||
headers: {
|
||||
'OCS-ApiRequest': 'true',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
}).then((response) => {
|
||||
cy.log(`Created user ${user}`, response.status)
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('nextcloudUpdateUser', (user, password, key, value) => {
|
||||
cy.request({
|
||||
method: 'PUT',
|
||||
url: `${Cypress.env('baseUrl')}/ocs/v2.php/cloud/users/${user}`,
|
||||
form: true,
|
||||
body: { key, value },
|
||||
auth: { user, pass: password },
|
||||
headers: {
|
||||
'OCS-ApiRequest': 'true',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
}).then((response) => {
|
||||
cy.log(`Updated user ${user} ${key} to ${value}`, response.status)
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('openLeftSidebar', () => {
|
||||
cy.get('.app-navigation button.app-navigation-toggle').click()
|
||||
})
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
import { User } from '@nextcloud/cypress'
|
||||
|
||||
export const randHash = () => Math.random().toString(36).replace(/[^a-z]+/g, '').slice(0, 10)
|
||||
export const randUser = () => new User(randHash(), randHash())
|
||||
|
||||
21
package-lock.json
generated
21
package-lock.json
generated
@@ -47,6 +47,7 @@
|
||||
"devDependencies": {
|
||||
"@nextcloud/babel-config": "^1.0.0",
|
||||
"@nextcloud/browserslist-config": "^2.3.0",
|
||||
"@nextcloud/cypress": "^1.0.0-beta.2",
|
||||
"@nextcloud/eslint-config": "^8.1.4",
|
||||
"@nextcloud/stylelint-config": "^2.3.0",
|
||||
"@nextcloud/webpack-vue-config": "^5.4.0",
|
||||
@@ -3018,6 +3019,19 @@
|
||||
"url": "https://opencollective.com/core-js"
|
||||
}
|
||||
},
|
||||
"node_modules/@nextcloud/cypress": {
|
||||
"version": "1.0.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@nextcloud/cypress/-/cypress-1.0.0-beta.2.tgz",
|
||||
"integrity": "sha512-IWxs0/S2SQA+lSG4Hla8kF/LEMO7lTBC3cY5bsY6V+MDhtUoHmq6SI3OVurirFwfYx4BoC+XSZzybKjzaZDb1w==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^16.0.0",
|
||||
"npm": "^7.0.0 || ^8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"cypress": "^12.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@nextcloud/dialogs": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@nextcloud/dialogs/-/dialogs-3.2.0.tgz",
|
||||
@@ -20770,6 +20784,13 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@nextcloud/cypress": {
|
||||
"version": "1.0.0-beta.2",
|
||||
"resolved": "https://registry.npmjs.org/@nextcloud/cypress/-/cypress-1.0.0-beta.2.tgz",
|
||||
"integrity": "sha512-IWxs0/S2SQA+lSG4Hla8kF/LEMO7lTBC3cY5bsY6V+MDhtUoHmq6SI3OVurirFwfYx4BoC+XSZzybKjzaZDb1w==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"@nextcloud/dialogs": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@nextcloud/dialogs/-/dialogs-3.2.0.tgz",
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"watch": "NODE_ENV=development webpack --progress --watch --config webpack.js",
|
||||
"lint": "eslint --ext .js,.vue src",
|
||||
"lint:fix": "eslint --ext .js,.vue src --fix",
|
||||
"lint:cypress": "eslint --ext .js cypress",
|
||||
"lint:cypress": "eslint --ext .js cypress",
|
||||
"stylelint": "stylelint src",
|
||||
"stylelint:fix": "stylelint src --fix",
|
||||
"test": "jest",
|
||||
@@ -74,6 +74,7 @@
|
||||
"devDependencies": {
|
||||
"@nextcloud/babel-config": "^1.0.0",
|
||||
"@nextcloud/browserslist-config": "^2.3.0",
|
||||
"@nextcloud/cypress": "^1.0.0-beta.2",
|
||||
"@nextcloud/eslint-config": "^8.1.4",
|
||||
"@nextcloud/stylelint-config": "^2.3.0",
|
||||
"@nextcloud/webpack-vue-config": "^5.4.0",
|
||||
|
||||
Reference in New Issue
Block a user