Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] setup-e2e-framework #265

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
27c8b35
setup-e2e-framework
SwikritiT Nov 3, 2022
448734d
page objects
SwikritiT Nov 4, 2022
9154481
remove unwanted files
SwikritiT Nov 4, 2022
1768ef7
seperate step defs
SwikritiT Nov 8, 2022
6ab0e28
seperate step defs
SwikritiT Nov 8, 2022
9ccc795
refactor code
SwikritiT Nov 9, 2022
531727f
stash
SwikritiT Nov 15, 2022
150dbc5
refactor code
SwikritiT Nov 16, 2022
5de769c
try e2e test
SwikritiT Nov 16, 2022
40f3ac0
trun off the headed mode
SwikritiT Nov 16, 2022
6799682
repalce selector
SwikritiT Nov 16, 2022
7fe87fb
enable admin creatin step
SwikritiT Nov 16, 2022
feea792
add more steps
SwikritiT Nov 17, 2022
66f8570
test
SwikritiT Nov 17, 2022
a8cfeba
test with php 7.4 omly
SwikritiT Nov 21, 2022
70d4112
add selector to skip install rec apps
SwikritiT Nov 21, 2022
0ad46b0
try only on master
SwikritiT Nov 22, 2022
bfeb7fb
try with more timeout
SwikritiT Nov 22, 2022
89975a1
make app
SwikritiT Nov 22, 2022
187e8e3
add wait for selector
SwikritiT Nov 23, 2022
ca6bdf5
wait for another selector
SwikritiT Nov 23, 2022
47232cd
add timeout
SwikritiT Nov 23, 2022
b5b63bd
add wait before clicking the menu
SwikritiT Nov 23, 2022
7ee951e
make app
SwikritiT Nov 23, 2022
76b1057
fix style
SwikritiT Nov 23, 2022
e494ff8
increase time out
SwikritiT Nov 23, 2022
4751b56
restore nextcloud versions
SwikritiT Nov 23, 2022
349a6a3
test
SwikritiT Nov 23, 2022
2d4d4a0
test
SwikritiT Nov 23, 2022
1de5c7d
test
SwikritiT Nov 23, 2022
8013d66
test
SwikritiT Nov 23, 2022
2092c48
wait for navigation
SwikritiT Nov 23, 2022
05f2119
test
SwikritiT Nov 24, 2022
03b3672
enable screenshot
SwikritiT Nov 24, 2022
5286841
navigate directly
SwikritiT Nov 24, 2022
b4e57f9
navigate to personal
SwikritiT Nov 24, 2022
ddb7f1b
test with another page
SwikritiT Nov 24, 2022
27e95b7
test with another page
SwikritiT Nov 24, 2022
e0f951f
trying
SwikritiT Nov 24, 2022
6439dc4
Try with different npm version
SwikritiT Nov 24, 2022
d3953dd
list js folder
SwikritiT Nov 24, 2022
4a0c0a6
--no-edit
SwikritiT Nov 24, 2022
7fd233d
ls directory
SwikritiT Nov 25, 2022
9e5aa0b
resolve dconflict
SwikritiT Nov 25, 2022
2242cd3
make app inside server
SwikritiT Nov 25, 2022
e753561
give correct path to the atrifact upload
SwikritiT Nov 25, 2022
34df4bd
try
SwikritiT Nov 28, 2022
9594fc7
switch steps
SwikritiT Nov 28, 2022
4c26367
tests
SwikritiT Nov 28, 2022
8937b1b
curl capabilities
SwikritiT Nov 29, 2022
6bcabe2
disable csrf check
SwikritiT Nov 29, 2022
4573546
test with container
SwikritiT Nov 29, 2022
20f9e22
use runner job
SwikritiT Nov 30, 2022
e14a4f7
use runner job
SwikritiT Nov 30, 2022
ecd358d
use runner job
SwikritiT Nov 30, 2022
afb803c
use runner job
SwikritiT Nov 30, 2022
010f71b
container
SwikritiT Nov 30, 2022
f7a335b
omit composer install
SwikritiT Nov 30, 2022
964892e
run command as sudo
SwikritiT Nov 30, 2022
c41e2fb
try to run locally
SwikritiT Nov 30, 2022
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
110 changes: 93 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
name: CI
strategy:
matrix:
nextcloudVersion: [ stable22, stable23, stable24, stable25, master ]
phpVersion: [ 7.4, 8.0, 8.1 ]
nextcloudVersion: [ master ]
phpVersion: [ 7.4 ]
exclude:
- nextcloudVersion: stable22
phpVersion: 8.1
Expand All @@ -21,6 +21,27 @@ jobs:
- nextcloudVersion: stable24
phpVersion: 8.1
runs-on: ubuntu-latest
# container: ubuntu:latest
# services:
# openproject:
# image: openproject/community:12
# env:
# OPENPROJECT_SECRET_KEY_BASE: secret
## OPENPROJECT_HOST__NAME: localhost:8081
# OPENPROJECT_HTTPS: false
# OPENPROJECT_PASSWORD__MIN__LENGTH: 0
# OPENPROJECT_ONBOARDING__ENABLED: false
# OPENPROJECT_AUTHENTICATION_GLOBAL__BASIC__AUTH_USER: apiadmin
# OPENPROJECT_AUTHENTICATION_GLOBAL__BASIC__AUTH_PASSWORD: apiadmin
services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: openproject-dev-password
POSTGRES_USER: openproject
POSTGRES_DB: openproject_dev
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.9.1
Expand All @@ -31,6 +52,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- run: mkdir -p artifacts

- name: Setup PHP ${{ matrix.phpVersion }}
uses: shivammathur/setup-php@v2
with:
Expand Down Expand Up @@ -65,33 +88,52 @@ jobs:
- name: Setup NPM ${{ steps.versions.outputs.npmVersion }}
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1.2'
bundler-cache: true
- run: |
ruby --version

- name: Install PHP Dependencies
run: |
sudo apt-get install git
composer install --no-progress --prefer-dist --optimize-autoloader
git clone --depth 1 https://github.com/nextcloud/server.git -b ${{ matrix.nextcloudVersion }}
cd server && git submodule update --init
./occ maintenance:install --admin-pass=admin
./occ config:system:set allow_local_remote_servers --value 1
git clone --depth 1 https://github.com/nextcloud/notifications.git -b ${{ matrix.nextcloudVersion }} apps/notifications
pwd

- name: PHP stan
run: make phpstan
- name: setup openproject
run: |
mkdir ~/dev
cd ~/dev
pwd
# git clone https://github.com/opf/openproject.git
# cd openproject

- name: PHP code style
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
# - name: PHP stan
# run: make phpstan

# - name: PHP code style
# run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )

- name: Install NPM Dependencies
run: npm install

- name: JS Lint
run: npm run lint

- name: Style Lint
run: npm run stylelint

- name: PHP & Vue Unit Tests
run: |
make phpunit
make jsunit
# - name: JS Lint
# run: npm run lint
#
# - name: Style Lint
# run: npm run stylelint
#
# - name: PHP & Vue Unit Tests
# run: |
# make phpunit
# make jsunit

- name: API Tests
env:
Expand All @@ -105,7 +147,41 @@ jobs:
./occ a:e integration_openproject
php -S localhost:8080 2> /dev/null &
cd apps/integration_openproject
make api-test
# make api-test

# - name: wait on OpenProject
# uses: iFaxity/wait-on-action@v1
# with:
# resource: http-get://localhost/api/v3/
# timeout: 240000
# - name: try OpenProject
# run: curl http://localhost/api/v3/users -u apiadmin:apiadmin

- name: try Nextcloud
run: |
curl http://localhost:8080/status.php
curl --silent 'http://localhost:8080/ocs/v2.php/cloud/capabilities?format=json'-H "OCS-APIREQUEST: 1" | json_pp

- name: e2e test
id: e2e
run: |
cd server
./occ config:system:set allow_local_remote_servers --value 1
./occ config:system:get allow_local_remote_servers
./occ config:system:set csrf.disabled --value true
./occ config:system:set overwrite.cli.url --value 'http://localhost:8080'
cat config/config.php
cd apps/integration_openproject
make
npm run test:e2e tests/e2e/features/webUI
continue-on-error: true

- name: Upload tracing artifacts
if: steps.e2e.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: e2e-tracing
path: server/apps/integration_openproject/tests/e2e/report/

- name: JS Code Coverage Summary Report
if: ${{ github.event_name == 'pull_request' && matrix.nextcloudVersion == 'master' && matrix.phpVersion == '7.4' }}
Expand Down
46 changes: 46 additions & 0 deletions cucumber.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const { Before, BeforeAll, AfterAll, After, setDefaultTimeout } = require("@cucumber/cucumber")
const { chromium } = require("playwright")
const {config} = require("./tests/e2e/config")
const apiHelper = require('./tests/e2e/helpers/apiHelper')
const { OpenprojectAdminPage } = require("./tests/e2e/pageObjects/OpenprojectAdminPage")
const opAdminPageObject = new OpenprojectAdminPage()

setDefaultTimeout(120000)

BeforeAll(async function () {
await apiHelper.createAdmin()
global.browserNC = await chromium.launch({
headless: true,
});
global.browserOP = await chromium.launch({
headless: true,
});
});

AfterAll(async function () {
await global.browserNC.close()
await global.browserOP.close()
});

Before(async function () {
global.contextNC = await global.browserNC.newContext()
await contextNC.grantPermissions(['clipboard-read','clipboard-write']);
await contextNC.tracing.start({ screenshots: true, snapshots: true });
global.pageNC = await global.contextNC.newPage()
global.contextOP = await global.browserOP.newContext()
await contextOP.grantPermissions(['clipboard-read','clipboard-write']);
await contextOP.tracing.start({ screenshots: true, snapshots: true });
global.pageOP = await global.contextOP.newPage()
});

After(async function () {
await apiHelper.resetNextcloudOauthSettings()
// await opAdminPageObject.deleteFileStorage()
await global.pageNC.close();
await contextNC.tracing.stop({ path: 'tests/e2e/report/traceNC.zip' });
await global.contextNC.close();
await global.pageOP.close();
await contextOP.tracing.stop({ path: 'tests/e2e/report/traceOP.zip' });
await global.contextOP.close();

});
1 change: 1 addition & 0 deletions lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function setConfig(array $values): DataResponse {

/**
* set admin config values
* @NoCSRFRequired
*
* @param array<string, string|null> $values
*
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"stylelint": "stylelint css src",
"stylelint:fix": "stylelint css src --fix",
"test:unit": "jest --silent",
"test:unit:watch": "jest --watch --no-coverage"
"test:unit:watch": "jest --watch --no-coverage",
"test:e2e": "cucumber-js --require cucumber.conf.js --require tests/e2e/stepDefinitions/**/*.js --format @cucumber/pretty-formatter"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -52,15 +53,20 @@
"vue-material-design-icons": "^5.0.0"
},
"devDependencies": {
"@cucumber/cucumber": "^8.7.0",
"@cucumber/pretty-formatter": "^1.0.0",
"@nextcloud/babel-config": "^1.0.0",
"@nextcloud/browserslist-config": "^2.2.0",
"@nextcloud/eslint-config": "^8.0.0",
"@nextcloud/stylelint-config": "^2.1.2",
"@nextcloud/webpack-vue-config": "^5.0.0",
"@playwright/test": "^1.27.1",
"@vue/cli-plugin-unit-jest": "~5.0.0",
"@vue/test-utils": "^1.3.0",
"@vue/vue2-jest": "^27.0.0",
"eslint-webpack-plugin": "^3.1.1",
"node-fetch": "^2.6.7",
"playwright": "^1.27.1",
"stylelint-webpack-plugin": "^3.3.0"
}
}
Binary file added report/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions tests/e2e/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

exports.config = {
baseUrlNC: process.env.NEXTCLOUD_HOST || 'http://localhost:8080',
baseUrlOP: process.env.OPENPROJECT_HOST || 'http://localhost:8081',
openprojectBasicAuthUser: process.env.OPENPROJECT_AUTHENTICATION_GLOBAL__BASIC__AUTH_USER || 'apiadmin',
openprojectBasicAuthPass: process.env.OPENPROJECT_AUTHENTICATION_GLOBAL__BASIC__AUTH_PASSWORD || 'apiadmin',
headless: process.env.HEADLESS === 'true',

}
21 changes: 21 additions & 0 deletions tests/e2e/features/webUI/OauthFlow.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Feature:
As an admin
I want to setup oauth between nextcloud and openproject
So that the apps can communicate with each other


Scenario: user logs in
Given openproject administrator has logged in openproject using the webUI
And nextcloud administrator has logged in using the webUI
And the administrator has navigated to the openproject tab in administrator settings
And nextcloud administrator adds the openproject host
When openproject administrator adds the nextcloud host with name "nextcloud" in file storage
And openproject administrator copies the openproject oauth credentials
And nextcloud administrator pastes the openproject oauth credentials
And nextcloud administrator copies the nextcloud oauth credentials
And openproject administrator pastes the nextcloud oauth credentials
Then file storage "nextcloud" should be listed on the webUI of openproject
And the oauth setting from should be completed on the webUI of nextcloud
When administator connects to the openproject through the personal settings
And the user authorizes in open project with username "admin2" and password "admin2"
Then the button with "Disconnect from OpenProject" text should be displayed in the webUI
61 changes: 61 additions & 0 deletions tests/e2e/helpers/apiHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const fetch = require('node-fetch')
const { config } = require('../config')
const { throwError } = require('@vue/vue2-jest/lib/utils')

const createAdmin = function() {
const url = config.baseUrlOP + '/api/v3/users'
const data = {
login: 'admin2',
password: 'admin2',
firstName: 'Second',
lastName: 'Admin',
email: 'admin@mail.com',
admin: true,
status: 'active',
language: 'en',
}
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: {
Authorization: 'Basic ' + Buffer.from(config.openprojectBasicAuthUser + ':' + config.openprojectBasicAuthPass).toString('base64'),
'Content-Type': 'application/json',
},
}).then(function(response) {
if (response.status !== 201) {
throwError('Cannot create the admin user')
}
}).catch(function(error) {
throwError('Cannot create the admin user' + error)
})
}

const resetNextcloudOauthSettings = function() {
const url = config.baseUrlNC + '/index.php/apps/integration_openproject/admin-config'
const data = {
values:
{
client_id: null,
client_secret: null,
default_enable_navigation: false,
default_enable_notifications: false,
default_enable_unified_search: false,
oauth_instance_url: null,
},
}
fetch(url, {
method: 'PUT',
body: JSON.stringify(data),
headers: {
Authorization: 'Basic ' + Buffer.from('admin' + ':' + 'admin').toString('base64'),
'Content-Type': 'application/json; charset=utf-8',
},
}).then(function(response) {
if (response.status !== 200) {
throwError('Error while resetting nextcloud oauth setup')
}
}).catch(function(error) {
throwError('Cannot reset the nextcloud settings' + error)
})
}
module.exports = { createAdmin, resetNextcloudOauthSettings }
Loading