Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,16 @@ Currently this app requires the master branch of the [Viewer app](https://github
### 🧙 Advanced development stuff
To build the Javascript whenever you make changes, instead of the full `make` you can also run `npm run build`. Or run `npm run watch` to rebuild on every file save.

#### 🐞 Testing the app
Currently this app uses three different kinds of tests:

For testing the backend (PHP) [Psalm](https://psalm.dev/) and [PHPUnit](https://phpunit.de/) are used,
you can run the testcases (placed in `tests/`) using the composer scripts `psalm` and `test:unit`.

For testing the frontend [jest](https://jestjs.io/) is used for unittests, whereas [cypress](https://www.cypress.io/) is used for end2end testing.
The unittests are also placed in `tests/`, the cypress tests are placed in `cypress/`.
You can run the tests using the package scripts `npm run test` (jest), and respective `npm run test:cypress` (cypress).

Please note the cypress tests require a nextcloud server running, the if no running server is detected a docker container will be started,
this requires the current user to be in the `docker` group.
Or you might set the `CYPRESS_baseUrl` environment variable for a custom nextcloud server.
17 changes: 17 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
projectId: 'hx9gqy',
viewportWidth: 1280,
viewportHeight: 900,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
baseUrl: 'http://localhost:8081/index.php/',
experimentalSessionAndOrigin: true,
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
},
})
7 changes: 0 additions & 7 deletions cypress.json

This file was deleted.

48 changes: 41 additions & 7 deletions cypress/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,46 @@
FROM nextcloudci/server:server-17
FROM nextcloud:latest as source

RUN mkdir /var/www/html/data
RUN chown -R www-data:www-data /var/www/html/data
WORKDIR /tmp

ENTRYPOINT /usr/local/bin/initAndRun.sh
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends git;

# FROM nextcloud:18-rc-apache
RUN set -ex; \
git clone --depth 1 https://github.com/nextcloud/server.git ; \
git clone --depth 1 https://github.com/nextcloud/viewer server/apps/viewer;

RUN set -ex; \
cd server; \
git submodule update --init;

#ENTRYPOINT []
#CMD ["apache2-foreground"]
RUN cp -r -v /usr/src/nextcloud/config /tmp/server

FROM nextcloud:latest

RUN set -ex; \
rm -rf /usr/src/nextcloud;

COPY --from=source --chown=www-data:www-data /tmp/server /usr/src/nextcloud
COPY --chown=www-data:www-data ./server.sh /tmp/server.sh

RUN set -ex; \
cd /usr/src/nextcloud; \
mkdir data; \
mkdir custom_apps; \
chown -R www-data:www-data config data apps custom_apps;

ENV NEXTCLOUD_ADMIN_PASSWORD=admin
ENV NEXTCLOUD_ADMIN_USER=admin
ENV SQLITE_DATABASE=sqlite_db

RUN set -ex; \
cd /var/www/html; \
NEXTCLOUD_UPDATE=1 bash -x /entrypoint.sh pwd; \
chown -R www-data:www-data config data apps custom_apps; \
bash -x /tmp/server.sh; \
rm -rf /var/www/html/apps/text

RUN set -ex; \
cd /var/www/html; \
ls -lah
15 changes: 11 additions & 4 deletions cypress/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
version: '3'

services:
nextcloud:
nextcloud_cypress:
build:
context: .
network: host
restart: always
ports:
- 8081:80
environment:
CYPRESS_baseUrl:
APP_SOURCE:
- NEXTCLOUD_ADMIN_PASSWORD=admin
- NEXTCLOUD_ADMIN_USER=admin
- SQLITE_DATABASE=sqlite_db
- CYPRESS_baseUrl
- APP_SOURCE
volumes:
- ${APP_SOURCE}:/var/www/html/apps/text
- type: bind
read_only: true
source: ${APP_SOURCE}
target: /var/www/html/custom_apps/text
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 16 additions & 14 deletions cypress/runLocal.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
#!/bin/bash

export CYPRESS_DIR=$(dirname -- "$(readlink -f "${BASH_SOURCE}")")
export CYPRESS_baseUrl=${CYPRESS_baseUrl:-http://localhost:8081/index.php}
export APP_SOURCE=$CYPRESS_DIR/..
CYPRESS_DIR=$(dirname -- "$(readlink -f "${BASH_SOURCE}")")
CYPRESS_baseUrl=${CYPRESS_baseUrl:-http://localhost:8081/index.php}
APP_SOURCE=$CYPRESS_DIR/..

export CYPRESS_DIR
export CYPRESS_baseUrl
export APP_SOURCE

function finish {
docker-compose down
}
trap finish EXIT

cd $CYPRESS_DIR
if [ ! -f $(npm bin)/wait-on ]
cd "$CYPRESS_DIR" || exit
if [ ! -f "$(npm bin)/wait-on" ]
then
npm install --no-save wait-on
fi

# start server if it's not running yet
if $(npm bin)/wait-on -i 500 -t 1000 $CYPRESS_baseUrl 2> /dev/null
if "$(npm bin)/wait-on" -i 500 -t 1000 "$CYPRESS_baseUrl" 2> /dev/null
then
echo Server is up at $CYPRESS_baseUrl
echo Server is up at "$CYPRESS_baseUrl"
else
echo No server reached at $CYPRESS_baseUrl - starting containers.
echo No server reached at "$CYPRESS_baseUrl" - starting containers.
docker-compose up -d
if $(npm bin)/wait-on -i 500 -t 240000 $CYPRESS_baseUrl 2> /dev/null
if "$(npm bin)/wait-on" -i 500 -t 240000 "$CYPRESS_baseUrl" 2> /dev/null
then
docker-compose exec -T nextcloud bash /var/www/html/apps/text/cypress/server.sh
docker-compose exec -T nextcloud_cypress bash /var/www/html/custom_apps/text/cypress/server.sh
else
echo Waiting for $CYPRESS_baseUrl timed out.
echo Waiting for "$CYPRESS_baseUrl" timed out.
echo Container logs:
docker-compose logs
exit 1
fi
fi

(cd .. && $(npm bin)/cypress $@)


(cd .. && "$(npm bin)/cypress" "$@")
7 changes: 5 additions & 2 deletions cypress/server.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash
git clone https://github.com/nextcloud/viewer /var/www/html/apps/viewer
su www-data -c "
su -s /bin/bash www-data -c "
php /var/www/html/occ config:system:set debug --value='true' --type=boolean
export OC_PASS=1234561
php /var/www/html/occ user:add --password-from-env user1
php /var/www/html/occ user:add --password-from-env user2
php /var/www/html/occ app:enable viewer
php /var/www/html/occ app:enable text
php /var/www/html/occ app:list
Expand Down
File renamed without changes.
49 changes: 14 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"stylelint": "stylelint src/**/*.vue src/**/*.scss src/**/*.css",
"stylelint:fix": "stylelint src/**/*.vue src/**/*.scss src/**/*.css --fix",
"test": "NODE_ENV=test jest",
"test:cypress": "cd cypress && ./runLocal.sh run",
"test:coverage": "NODE_ENV=test jest --coverage"
},
"browserslist": [
Expand Down Expand Up @@ -98,7 +99,7 @@
"devDependencies": {
"@babel/eslint-parser": "^7.18.2",
"@cypress/browserify-preprocessor": "^3.0.2",
"@cypress/webpack-preprocessor": "^5.11.1",
"@cypress/webpack-preprocessor": "^5.12.0",
"@nextcloud/babel-config": "^1.0.0",
"@nextcloud/browserslist-config": "^2.2.0",
"@nextcloud/eslint-config": "^8.0.0",
Expand All @@ -107,7 +108,7 @@
"@nextcloud/webpack-vue-config": "^5.1.0",
"@vue/test-utils": "^1.3.0",
"@vue/vue2-jest": "^27.0.0",
"cypress": "^9.7.0",
"cypress": "^10.0.2",
"cypress-file-upload": "^5.0.8",
"eslint": "^8.17.0",
"eslint-config-standard": "^17.0.0",
Expand Down