kopia lustrzana https://github.com/nextcloud/social
rodzic
078f67c442
commit
bea293487e
|
@ -22,7 +22,8 @@
|
|||
<author mail="maxence@artificial-owl.com" homepage="https://artificial-owl.com/">Maxence Lange</author>
|
||||
<author mail="jus@bitgrid.net">Julius Härtl</author>
|
||||
<author mail="jonas@violoncello.ch" homepage="https://violoncello.ch">Jonas Sulzer</author>
|
||||
<author mail="hey@jancborchardt.net" homepage="https://jancborchardt.net">Jan-Christoph Borchardt</author>
|
||||
<author mail="hey@jancborchardt.net" homepage="https://jancborchardt.net">Jan-Christoph
|
||||
Borchardt</author>
|
||||
<author mail="cyrpub@bollu.be">Cyrille Bollu</author>
|
||||
<namespace>Social</namespace>
|
||||
<category>social</category>
|
||||
|
@ -34,7 +35,7 @@
|
|||
<database>pgsql</database>
|
||||
<database>sqlite</database>
|
||||
<database>mysql</database>
|
||||
<nextcloud min-version="26" max-version="28"/>
|
||||
<nextcloud min-version="26" max-version="28" />
|
||||
</dependencies>
|
||||
|
||||
<background-jobs>
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
const { defineConfig } = require('cypress')
|
||||
const browserify = require('@cypress/browserify-preprocessor')
|
||||
|
||||
module.exports = defineConfig({
|
||||
projectId: '7mqhfh',
|
||||
|
||||
viewportWidth: 1280,
|
||||
viewportHeight: 720,
|
||||
defaultCommandTimeout: 6000,
|
||||
retries: 1,
|
||||
|
||||
env: {
|
||||
failSilently: false,
|
||||
type: 'actual',
|
||||
},
|
||||
|
||||
screenshotsFolder: 'cypress/snapshots/actual',
|
||||
trashAssetsBeforeRuns: true,
|
||||
|
||||
e2e: {
|
||||
baseUrl: 'http://localhost:8082/index.php',
|
||||
|
||||
setupNodeEvents(on, config) {
|
||||
// Fix browserslist extend https://github.com/cypress-io/cypress/issues/2983#issuecomment-570616682
|
||||
on('file:preprocessor', browserify())
|
||||
},
|
||||
},
|
||||
})
|
|
@ -0,0 +1,89 @@
|
|||
|
||||
import {
|
||||
configureNextcloud,
|
||||
startNextcloud,
|
||||
stopNextcloud,
|
||||
waitOnNextcloud,
|
||||
} from './cypress/dockerNode'
|
||||
import { defineConfig } from 'cypress'
|
||||
|
||||
import browserify from '@cypress/browserify-preprocessor'
|
||||
import getCompareSnapshotsPlugin from 'cypress-visual-regression/dist/plugin'
|
||||
|
||||
export default defineConfig({
|
||||
projectId: '7mqhfh',
|
||||
|
||||
// 16/9 screen ratio
|
||||
viewportWidth: 1280,
|
||||
viewportHeight: 720,
|
||||
|
||||
// Tries again 2 more times on failure
|
||||
retries: {
|
||||
runMode: 2,
|
||||
// do not retry in `cypress open`
|
||||
openMode: 0,
|
||||
},
|
||||
|
||||
// Needed to trigger `after:run` events with cypress open
|
||||
experimentalInteractiveRunEvents: true,
|
||||
|
||||
// faster video processing
|
||||
videoCompression: false,
|
||||
|
||||
// Visual regression testing
|
||||
env: {
|
||||
failSilently: false,
|
||||
type: 'actual',
|
||||
},
|
||||
screenshotsFolder: 'cypress/snapshots/actual',
|
||||
trashAssetsBeforeRuns: true,
|
||||
|
||||
e2e: {
|
||||
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) {
|
||||
// Fix browserslist extend https://github.com/cypress-io/cypress/issues/2983#issuecomment-570616682
|
||||
on('file:preprocessor', browserify({ typescript: require.resolve('typescript') }))
|
||||
getCompareSnapshotsPlugin(on, config)
|
||||
|
||||
// Disable spell checking to prevent rendering differences
|
||||
on('before:browser:launch', (browser, launchOptions) => {
|
||||
if (browser.family === 'chromium' && browser.name !== 'electron') {
|
||||
launchOptions.preferences.default['browser.enable_spellchecking'] = false
|
||||
return launchOptions
|
||||
}
|
||||
|
||||
if (browser.family === 'firefox') {
|
||||
launchOptions.preferences['layout.spellcheckDefault'] = 0
|
||||
return launchOptions
|
||||
}
|
||||
|
||||
if (browser.name === 'electron') {
|
||||
launchOptions.preferences.spellcheck = false
|
||||
return launchOptions
|
||||
}
|
||||
})
|
||||
|
||||
// Remove container after run
|
||||
on('after:run', () => {
|
||||
stopNextcloud()
|
||||
})
|
||||
|
||||
// Before the browser launches
|
||||
// starting Nextcloud testing container
|
||||
return startNextcloud(process.env.BRANCH)
|
||||
.then((ip) => {
|
||||
// Setting container's IP as base Url
|
||||
config.baseUrl = `http://${ip}/index.php`
|
||||
return ip
|
||||
})
|
||||
.then(waitOnNextcloud)
|
||||
.then(() => configureNextcloud(process.env.BRANCH))
|
||||
.then(() => {
|
||||
return config
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
|
@ -0,0 +1,11 @@
|
|||
module.exports = {
|
||||
env: {
|
||||
'cypress/globals': true,
|
||||
},
|
||||
plugins: [
|
||||
'cypress',
|
||||
],
|
||||
extends: [
|
||||
'plugin:cypress/recommended',
|
||||
],
|
||||
};
|
|
@ -15,4 +15,3 @@ services:
|
|||
# Using fallback to make sure this script doesn't mess
|
||||
# with the mounting if APP_NAME is not provided.
|
||||
- ../:/var/www/html/apps/${APP_NAME:-social}
|
||||
- ./initserver.sh:/initserver.sh
|
||||
|
|
|
@ -0,0 +1,225 @@
|
|||
/**
|
||||
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable no-console */
|
||||
/* eslint-disable n/no-unpublished-import */
|
||||
/* eslint-disable n/no-extraneous-import */
|
||||
|
||||
import Docker from 'dockerode'
|
||||
import path from 'path'
|
||||
import waitOn from 'wait-on'
|
||||
|
||||
import pkg from '../package.json'
|
||||
|
||||
export const docker = new Docker()
|
||||
|
||||
const APP_PATH = path.resolve(__dirname, '../')
|
||||
const APP_NAME = pkg.name
|
||||
|
||||
const CONTAINER_NAME = 'nextcloud-cypress-tests-' + APP_NAME
|
||||
const SERVER_IMAGE = 'ghcr.io/nextcloud/continuous-integration-shallow-server'
|
||||
|
||||
/**
|
||||
* Start the testing container
|
||||
*/
|
||||
export const startNextcloud = async function(branch: string = 'master'): Promise<any> {
|
||||
|
||||
try {
|
||||
// Pulling images
|
||||
console.log('\nPulling images... ⏳')
|
||||
await new Promise((resolve, reject): any => docker.pull(SERVER_IMAGE, (err, stream) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
}
|
||||
// https://github.com/apocas/dockerode/issues/357
|
||||
docker.modem.followProgress(stream, onFinished)
|
||||
|
||||
/**
|
||||
*
|
||||
* @param err
|
||||
*/
|
||||
function onFinished(err) {
|
||||
if (!err) {
|
||||
resolve(true)
|
||||
return
|
||||
}
|
||||
reject(err)
|
||||
}
|
||||
}))
|
||||
console.log('└─ Done')
|
||||
|
||||
// Remove old container if exists
|
||||
console.log('\nChecking running containers... 🔍')
|
||||
try {
|
||||
const oldContainer = docker.getContainer(CONTAINER_NAME)
|
||||
const oldContainerData = await oldContainer.inspect()
|
||||
if (oldContainerData) {
|
||||
console.log('├─ Existing running container found')
|
||||
console.log('├─ Removing... ⏳')
|
||||
// Forcing any remnants to be removed just in case
|
||||
await oldContainer.remove({ force: true })
|
||||
console.log('└─ Done')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('└─ None found!')
|
||||
}
|
||||
|
||||
// Starting container
|
||||
console.log('\nStarting Nextcloud container... 🚀')
|
||||
console.log(`├─ Using branch '${branch}'`)
|
||||
console.log(`├─ And binding app '${APP_NAME}' from '${APP_PATH}'`)
|
||||
const container = await docker.createContainer({
|
||||
Image: SERVER_IMAGE,
|
||||
name: CONTAINER_NAME,
|
||||
HostConfig: {
|
||||
Binds: [
|
||||
// TODO: improve local app directory detection
|
||||
`${APP_PATH}/:/var/www/html/apps/${APP_NAME}`,
|
||||
],
|
||||
},
|
||||
Env: [
|
||||
`BRANCH=${branch}`,
|
||||
],
|
||||
})
|
||||
await container.start()
|
||||
|
||||
// Get container's IP
|
||||
const ip = await getContainerIP(container)
|
||||
|
||||
console.log(`├─ Nextcloud container's IP is ${ip} 🌏`)
|
||||
return ip
|
||||
} catch (err) {
|
||||
console.log('└─ Unable to start the container 🛑')
|
||||
console.log(err)
|
||||
stopNextcloud()
|
||||
throw new Error('Unable to start the container')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure Nextcloud
|
||||
*/
|
||||
export const configureNextcloud = async function(branch: string = 'master') {
|
||||
console.log('\nConfiguring nextcloud...')
|
||||
const container = docker.getContainer(CONTAINER_NAME)
|
||||
await runExec(container, ['php', 'occ', '--version'], true)
|
||||
|
||||
// Clone the viewer app
|
||||
await runExec(container, ['git', 'clone', '--depth', '1', '--branch', branch, 'https://github.com/nextcloud/viewer.git', '/var/www/html/apps/viewer'], true)
|
||||
await runExec(container, ['php', 'occ', 'app:enable', 'social'], true)
|
||||
|
||||
// Be consistent for screenshots
|
||||
await runExec(container, ['php', 'occ', 'config:system:set', 'default_language', '--value', 'en'], true)
|
||||
await runExec(container, ['php', 'occ', 'config:system:set', 'force_language', '--value', 'en'], true)
|
||||
await runExec(container, ['php', 'occ', 'config:system:set', 'default_locale', '--value', 'en_US'], true)
|
||||
await runExec(container, ['php', 'occ', 'config:system:set', 'force_locale', '--value', 'en_US'], true)
|
||||
await runExec(container, ['php', 'occ', 'config:system:set', 'enforce_theme', '--value', 'light'], true)
|
||||
|
||||
console.log('└─ Nextcloud is now ready to use 🎉')
|
||||
}
|
||||
|
||||
/**
|
||||
* Force stop the testing container
|
||||
*/
|
||||
export const stopNextcloud = async function() {
|
||||
try {
|
||||
const container = docker.getContainer(CONTAINER_NAME)
|
||||
console.log('Stopping Nextcloud container...')
|
||||
container.remove({ force: true })
|
||||
console.log('└─ Nextcloud container removed 🥀')
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the testing container's IP
|
||||
*/
|
||||
export const getContainerIP = async function(
|
||||
container: Docker.Container = docker.getContainer(CONTAINER_NAME)
|
||||
): Promise<string> {
|
||||
let ip = ''
|
||||
let tries = 0
|
||||
while (ip === '' && tries < 10) {
|
||||
tries++
|
||||
|
||||
await container.inspect(function(err, data) {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
ip = data?.NetworkSettings?.IPAddress || ''
|
||||
})
|
||||
|
||||
if (ip !== '') {
|
||||
break
|
||||
}
|
||||
|
||||
await sleep(1000 * tries)
|
||||
}
|
||||
|
||||
return ip
|
||||
}
|
||||
|
||||
// Would be simpler to start the container from cypress.config.ts,
|
||||
// but when checking out different branches, it can take a few seconds
|
||||
// Until we can properly configure the baseUrl retry intervals,
|
||||
// We need to make sure the server is already running before cypress
|
||||
// https://github.com/cypress-io/cypress/issues/22676
|
||||
export const waitOnNextcloud = async function(ip: string) {
|
||||
console.log('├─ Waiting for Nextcloud to be ready... ⏳')
|
||||
await waitOn({ resources: [`http://${ip}/index.php`] })
|
||||
console.log('└─ Done')
|
||||
}
|
||||
|
||||
const runExec = async function(
|
||||
container: Docker.Container,
|
||||
command: string[],
|
||||
verbose = false,
|
||||
user = 'www-data'
|
||||
) {
|
||||
const exec = await container.exec({
|
||||
Cmd: command,
|
||||
AttachStdout: true,
|
||||
AttachStderr: true,
|
||||
User: user,
|
||||
})
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
exec.start({}, (err, stream) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
}
|
||||
if (stream) {
|
||||
stream.setEncoding('utf-8')
|
||||
stream.on('data', str => {
|
||||
if (verbose && str.trim() !== '') {
|
||||
console.log(`├─ ${str.trim().replace(/\n/gi, '\n├─ ')}`)
|
||||
}
|
||||
})
|
||||
stream.on('end', resolve)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const sleep = function(milliseconds: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, milliseconds))
|
||||
}
|
|
@ -1,28 +1,30 @@
|
|||
const userId = 'janedoe' + Date.now()
|
||||
|
||||
describe('Social app setup', function() {
|
||||
before(function() {
|
||||
cy.nextcloudCreateUser(userId, 'p4ssw0rd')
|
||||
cy.login(userId, 'p4ssw0rd')
|
||||
describe('Social app setup', function () {
|
||||
before(function () {
|
||||
cy.createRandomUser()
|
||||
.then((user) => {
|
||||
cy.login(user)
|
||||
cy.visit('/apps/social')
|
||||
})
|
||||
})
|
||||
|
||||
it('See the welcome message', function() {
|
||||
cy.visit('/apps/social/')
|
||||
it('See the welcome message', function () {
|
||||
cy.get('.social__welcome').should('contain', 'Nextcloud becomes part of the federated social networks!')
|
||||
cy.get('.social__welcome').find('.icon-close').click()
|
||||
cy.get('.social__welcome').should('not.exist')
|
||||
})
|
||||
|
||||
it('See the home section in the sidebar', function() {
|
||||
it('See the home section in the sidebar', function () {
|
||||
cy.get('.app-navigation').contains('Home').click()
|
||||
cy.get('.emptycontent').should('be.visible')
|
||||
cy.get('.app-social .empty-content').should('be.visible')
|
||||
})
|
||||
|
||||
it('See the empty content illustration', function() {
|
||||
it('See the empty content illustration', function () {
|
||||
cy.reload()
|
||||
cy.get('.app-navigation').contains('Direct messages').click()
|
||||
cy.get('.emptycontent').should('be.visible').contains('No direct messages found')
|
||||
cy.get('.app-social .empty-content').should('be.visible').contains('No direct messages found')
|
||||
cy.get('.app-navigation').contains('Profile').click()
|
||||
cy.get('.emptycontent').should('be.visible').contains('You have not tooted yet')
|
||||
cy.get('.app-social .empty-content').should('be.visible').contains('You have not tooted yet')
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
|
@ -22,31 +22,29 @@
|
|||
|
||||
const userId = 'janedoe' + Date.now()
|
||||
|
||||
describe('Create posts', function() {
|
||||
describe('Create posts', function () {
|
||||
|
||||
before(function() {
|
||||
before(function () {
|
||||
// ensure that the admin account is initialized for social
|
||||
cy.login('admin', 'admin', '/apps/social/')
|
||||
// cy.login('admin', 'admin', '/apps/social/')
|
||||
|
||||
cy.nextcloudCreateUser(userId, 'p4ssw0rd')
|
||||
cy.logout()
|
||||
|
||||
cy.login(userId, 'p4ssw0rd', '/apps/social/')
|
||||
cy.createRandomUser()
|
||||
.then((user) => {
|
||||
cy.login(user)
|
||||
cy.visit('/apps/social')
|
||||
cy.get('.app-content').should('be.visible')
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
cy.screenshot()
|
||||
})
|
||||
|
||||
it('See the empty content illustration', function() {
|
||||
cy.get('.emptycontent').should('be.visible').contains('No posts found')
|
||||
it('See the empty content illustration', function () {
|
||||
cy.get('.social__welcome').find('.icon-close').click()
|
||||
cy.get('.app-social .empty-content').should('be.visible').contains('No posts found')
|
||||
cy.reload()
|
||||
})
|
||||
|
||||
it('Write a post to followers', function() {
|
||||
it('Write a post to followers', function () {
|
||||
cy.visit('/apps/social/')
|
||||
cy.server()
|
||||
cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage')
|
||||
cy.intercept('POST', '/index.php/apps/social/api/v1/statuses').as('postMessage')
|
||||
cy.get('.new-post button[type=submit]')
|
||||
.should('be.disabled')
|
||||
cy.get('.new-post').find('[contenteditable]').type('Hello world')
|
||||
|
@ -58,24 +56,20 @@ describe('Create posts', function() {
|
|||
cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'Hello world')
|
||||
})
|
||||
|
||||
it('No longer see the empty content illustration', function() {
|
||||
cy.get('.emptycontent').should('not.exist')
|
||||
it('No longer see the empty content illustration', function () {
|
||||
cy.get('.app-social .empty-content').should('not.exist')
|
||||
})
|
||||
|
||||
it('Write a post to followers with shift enter', function() {
|
||||
cy.visit('/apps/social/')
|
||||
cy.server()
|
||||
cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage')
|
||||
it('Write a post to followers with shift enter', function () {
|
||||
cy.intercept('POST', '/index.php/apps/social/api/v1/statuses').as('postMessage')
|
||||
cy.get('.new-post').find('[contenteditable]').type('Hello world 2{shift}{enter}')
|
||||
cy.wait('@postMessage')
|
||||
cy.get('.social__timeline div.timeline-entry:first-child').should('contain', 'Hello world 2')
|
||||
})
|
||||
|
||||
it('Write a post to @admin', function() {
|
||||
cy.visit('/apps/social/')
|
||||
cy.server()
|
||||
cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage')
|
||||
cy.route('GET', '/index.php/apps/social/api/v1/global/accounts/search')
|
||||
it('Write a post to @admin', function () {
|
||||
cy.intercept('POST', '/index.php/apps/social/api/v1/statuses').as('postMessage')
|
||||
cy.intercept('GET', '/index.php/apps/social/api/v1/global/accounts/search')
|
||||
cy.get('.new-post').find('[contenteditable]').type('@adm', { delay: 500 })
|
||||
cy.get('.tribute-container').should('be.visible')
|
||||
cy.get('.tribute-container ul li:first').contains('admin')
|
||||
|
@ -86,11 +80,9 @@ describe('Create posts', function() {
|
|||
cy.get('.social__timeline div.timeline-entry:first-child').should('contain', '@admin')
|
||||
})
|
||||
|
||||
it('Opens the menu and shows that followers is selected by default', function() {
|
||||
cy.visit('/apps/social/')
|
||||
cy.server()
|
||||
cy.route('POST', '/index.php/apps/social/api/v1/post').as('postMessage')
|
||||
cy.route('GET', '/index.php/apps/social/api/v1/global/accounts/search')
|
||||
it('Opens the menu and shows that followers is selected by default', function () {
|
||||
cy.intercept('POST', '/index.php/apps/social/api/v1/statuses').as('postMessage')
|
||||
cy.intercept('GET', '/index.php/apps/social/api/v1/global/accounts/search')
|
||||
cy.get('.new-post').find('[contenteditable]').click({ force: true }).type('@adm{enter} Hello world', { delay: 500, force: true })
|
||||
cy.wait(500)
|
||||
cy.get('.new-post button[type=submit]').should('not.be.disabled')
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo "APP_NAME: $APP_NAME"
|
||||
echo "BRANCH: $BRANCH"
|
||||
|
||||
chown -R www-data:www-data /var/www/html/data
|
||||
|
||||
su www-data -c "
|
||||
php occ config:system:set force_language --value en
|
||||
php occ app:enable $APP_NAME
|
||||
php occ app:list
|
||||
"
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# RUN THIS SCRIPT FROM THE ROOT FOLDER OF YOUR APP
|
||||
APP_NAME=${PWD##*/}
|
||||
CYPRESS_baseUrl=http://127.0.0.1:8082/index.php
|
||||
|
||||
if [[ $APP_NAME == "cypress" ]]
|
||||
then
|
||||
echo "Please run this app from your app root folder."
|
||||
else
|
||||
echo "Launching docker server for the $APP_NAME app"
|
||||
cd cypress
|
||||
docker-compose pull
|
||||
docker-compose up -d --force-recreate
|
||||
npm run wait-on $CYPRESS_baseUrl
|
||||
echo "Nextcloud successfully installed"
|
||||
docker-compose exec --env APP_NAME=$APP_NAME -T nextcloud bash /initserver.sh
|
||||
docker-compose exec -u www-data -T nextcloud php ./occ social:reset -n
|
||||
echo "Nextcloud successfully configured"
|
||||
fi
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# RUN THIS SCRIPT FROM THE ROOT FOLDER OF YOUR APP
|
||||
appname=${PWD##*/}
|
||||
|
||||
if [[ $appname == "cypress" ]]
|
||||
then
|
||||
echo "Please run this app from your app root folder."
|
||||
else
|
||||
echo "Killing server for the $appname app"
|
||||
cd cypress
|
||||
docker-compose down
|
||||
fi
|
|
@ -21,62 +21,16 @@
|
|||
*/
|
||||
|
||||
import axios from '@nextcloud/axios'
|
||||
import { addCommands, User } from '@nextcloud/cypress'
|
||||
import { basename } from 'path'
|
||||
|
||||
// Add custom commands
|
||||
import 'cypress-wait-until'
|
||||
addCommands()
|
||||
|
||||
const url = Cypress.config('baseUrl').replace(/\/index.php\/?$/g, '')
|
||||
Cypress.env('baseUrl', url)
|
||||
|
||||
Cypress.Commands.add('login', (user, password, route = '/apps/files') => {
|
||||
Cypress.Cookies.defaults({
|
||||
preserve: /^(oc|nc)/,
|
||||
})
|
||||
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)
|
||||
})
|
||||
|
||||
Cypress.Commands.add('logout', () => {
|
||||
cy.getCookies()
|
||||
.then(cookies => {
|
||||
if (cookies.length === 0) {
|
||||
cy.log('Not logged, skipping logout...')
|
||||
return
|
||||
}
|
||||
|
||||
return cy.get('body')
|
||||
.then($body => {
|
||||
const $settingsButton = $body.find('#settings #expand')
|
||||
if ($settingsButton.length === 0) {
|
||||
cy.log('Not logged in.')
|
||||
return
|
||||
}
|
||||
|
||||
$settingsButton.click()
|
||||
cy.contains('Log out').click()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('nextcloudCreateUser', (user, password) => {
|
||||
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: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'OCS-ApiRequest': 'true',
|
||||
Authorization: `Basic ${Buffer.from('admin:admin').toString('base64')}`,
|
||||
},
|
||||
})
|
||||
cy.clearCookies()
|
||||
})
|
||||
|
||||
Cypress.Commands.add('uploadFile', (fileName, mimeType, path = '') => {
|
||||
// get fixture
|
||||
return cy.fixture(fileName, 'base64').then(file => {
|
|
@ -14,4 +14,4 @@
|
|||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands.js'
|
||||
import './commands.ts'
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["./**/*.ts"],
|
||||
}
|
|
@ -105,9 +105,9 @@ class CurlService {
|
|||
$account = $this->withoutBeginAt($account);
|
||||
|
||||
// we consider an account is like an email
|
||||
if (!filter_var($account, FILTER_VALIDATE_EMAIL)) {
|
||||
throw new InvalidResourceException('account format is not valid');
|
||||
}
|
||||
// if (!filter_var($account, FILTER_VALIDATE_EMAIL)) {
|
||||
// throw new InvalidResourceException('account format is not valid');
|
||||
// }
|
||||
|
||||
$exploded = explode('@', $account);
|
||||
|
||||
|
|
Plik diff jest za duży
Load Diff
13
package.json
13
package.json
|
@ -27,9 +27,11 @@
|
|||
"stylelint:fix": "stylelint src --fix",
|
||||
"test": "jest",
|
||||
"test:coverage": "jest --coverage",
|
||||
"cypress": "./cypress/start.sh; cypress run; ./cypress/stop.sh",
|
||||
"cypress:gui": "./cypress/start.sh; cypress open; ./cypress/stop.sh",
|
||||
"wait-on": "wait-on -i 500 -t 300000"
|
||||
"cypress": "npm run cypress:component && npm run cypress:e2e",
|
||||
"cypress:component": "cypress run --component",
|
||||
"cypress:e2e": "cypress run --e2e",
|
||||
"cypress:gui": "cypress open",
|
||||
"precypress:update-snapshots": "TESTING=true npm run dev"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nextcloud/auth": "^2.0.0",
|
||||
|
@ -82,7 +84,10 @@
|
|||
"@nextcloud/stylelint-config": "^2.3.0",
|
||||
"@nextcloud/webpack-vue-config": "^5.5.1",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"cypress": "^12.14.0",
|
||||
"@nextcloud/cypress": "^1.0.0-beta.2",
|
||||
"cypress-visual-regression": "^2.1.1",
|
||||
"cypress-wait-until": "^1.7.2",
|
||||
"dockerode": "^3.3.5",
|
||||
"jest": "^29.5.0",
|
||||
"jest-serializer-vue": "^3.1.0",
|
||||
"vue-template-compiler": "^2.7.14",
|
||||
|
|
Ładowanie…
Reference in New Issue