Skip to content

Commit

Permalink
Fix CE tests for travis
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
  • Loading branch information
alexandrebodin committed Jul 27, 2020
1 parent 8c40d21 commit 08b357b
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 3 deletions.
57 changes: 56 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ cache:

# end to end testing template
e2e_tests: &e2e_tests
stage: 'End to End tests'
stage: 'End to End tests CE'
script:
- yarn run -s test:generate-app -- $DB_STRING
- yarn run -s test:start-app & wait-on http://localhost:1337
- STRAPI_DISABLE_EE=true yarn run -s test:e2e

# end to end testing template
e2e_tests_ee: &e2e_tests_ee
stage: 'End to End tests EE'
script:
- yarn run -s test:generate-app -- $DB_STRING
- yarn run -s test:start-app & wait-on http://localhost:1337
- yarn run -s test:e2e
if: fork = false

before_script:
- yarn build
Expand Down Expand Up @@ -99,3 +108,49 @@ jobs:
- ./mongodb-linux-x86_64-3.6.6/bin/mongod --fork --dbpath ./data/db/27017 --syslog --port 27017
env:
- DB_STRING='--dbclient=mongo --dbhost=localhost --dbport=27017 --dbname=strapi_test --dbusername= --dbpassword='

- <<: *e2e_tests_ee
name: 'E2E Postgresql'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- sudo apt-get update
- sudo apt-get --yes remove postgresql-*
- sudo apt-get install -y postgresql-11 postgresql-client-11
- sudo cp /etc/postgresql/{9.6,11}/main/pg_hba.conf
- sudo service postgresql restart 11
- psql -c 'create database strapi_test;' -U postgres
env:
- DB_STRING='--dbclient=postgres --dbhost=localhost --dbport=5433 --dbname=strapi_test --dbusername=postgres --dbpassword='

- <<: *e2e_tests_ee
name: 'E2E Mysql'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- sudo cp $TRAVIS_BUILD_DIR/_travis/mysql.cnf /etc/mysql/conf.d/
- sudo service mysql restart
- mysql -e 'CREATE DATABASE strapi_test;'
env:
- DB_STRING='--dbclient=mysql --dbhost=localhost --dbport=3306 --dbname=strapi_test --dbusername=travis --dbpassword='

- <<: *e2e_tests_ee
name: 'E2E Sqlite'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
env:
- DB_STRING='--dbclient=sqlite --dbfile=./tmp/data.db'

- <<: *e2e_tests_ee
name: 'E2E MongoDB'
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.6.tgz
- tar -zxvf mongodb-linux-x86_64-3.6.6.tgz
- mkdir -p ./data/db/27017
- mkdir -p ./data/db/27000
- ./mongodb-linux-x86_64-3.6.6/bin/mongod --fork --dbpath ./data/db/27017 --syslog --port 27017
env:
- DB_STRING='--dbclient=mongo --dbhost=localhost --dbport=27017 --dbname=strapi_test --dbusername= --dbpassword='
14 changes: 13 additions & 1 deletion packages/strapi-admin/test/admin-auth.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
const { registerAndLogin } = require('../../../test/helpers/auth');
const { createAuthRequest } = require('../../../test/helpers/request');

const edition = process.env.STRAPI_DISABLE_EE === 'true' ? 'CE' : 'EE';

let rq;

const createAuthRole = async () => {
Expand Down Expand Up @@ -42,7 +44,17 @@ describe('Admin Auth End to End', () => {
beforeAll(async () => {
const token = await registerAndLogin();
rq = createAuthRequest(token);
internals.role = await createAuthRole();

if (edition === 'EE') {
internals.role = await createAuthRole();
} else {
internals.role = (
await rq({
url: '/admin/roles',
method: 'GET',
})
).body.data[0];
}
}, 60000);

afterAll(async () => {
Expand Down
15 changes: 14 additions & 1 deletion packages/strapi-admin/test/admin-user.test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const { login, registerAndLogin, getUser } = require('../../../test/helpers/auth
const { createAuthRequest } = require('../../../test/helpers/request');
const { SUPER_ADMIN_CODE } = require('../services/constants');

const edition = process.env.STRAPI_DISABLE_EE === 'true' ? 'CE' : 'EE';

const omitTimestamps = obj => _.omit(obj, ['updatedAt', 'createdAt', 'updated_at', 'created_at']);

const getAuthToken = async () => {
Expand Down Expand Up @@ -85,7 +87,18 @@ describe('Admin User CRUD (e2e)', () => {
beforeAll(async () => {
const token = await getAuthToken();
rq = createAuthRequest(token);
testData.role = await createUserRole();

if (edition === 'EE') {
testData.role = await createUserRole();
} else {
testData.role = (
await rq({
url: '/admin/roles',
method: 'GET',
})
).body.data[0];
}

testData.firstSuperAdminUser = await getUser();
testData.superAdminRole = await getSuperAdminRole();
});
Expand Down

0 comments on commit 08b357b

Please sign in to comment.