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

Fix CE tests for travis #7218

Merged
merged 4 commits into from
Jul 29, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
111 changes: 72 additions & 39 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,66 @@ cache:

# end to end testing template
e2e_tests: &e2e_tests
stage: 'End to End tests'
stage: 'End to End tests CE'
script:
- STRAPI_DISABLE_EE=true yarn run -s test:generate-app -- $DB_STRING
- STRAPI_DISABLE_EE=true 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
alexandrebodin marked this conversation as resolved.
Show resolved Hide resolved

pg_test: &pg_test
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='

mysql_test: &mysql_test
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='

sqlite_test: &sqlite_test
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'

mongo_test: &mongo_test
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='

before_script:
- yarn build
Expand Down Expand Up @@ -55,47 +110,25 @@ jobs:
- yarn run -s test:front && codecov -C -F front

- <<: *e2e_tests
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='
<<: *pg_test

- <<: *e2e_tests
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='
<<: *mysql_test

- <<: *e2e_tests
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'
<<: *sqlite_test

- <<: *e2e_tests
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='
<<: *mongo_test

- <<: *e2e_tests_ee
alexandrebodin marked this conversation as resolved.
Show resolved Hide resolved
<<: *pg_test

- <<: *e2e_tests_ee
<<: *mysql_test

- <<: *e2e_tests_ee
<<: *sqlite_test

- <<: *e2e_tests_ee
<<: *mongo_test
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];
}
alexandrebodin marked this conversation as resolved.
Show resolved Hide resolved
}, 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
6 changes: 5 additions & 1 deletion test/helpers/testAppGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ const generateTestApp = async ({ appName, database }) => {
* @param {string} options.appName - Name of the app / folder in which run the start script
*/
const startTestApp = ({ appName }) => {
return execa.shell('BROWSER=none strapi develop --no-build', {
return execa('strapi', ['develop', '--no-build'], {
stdio: 'inherit',
cwd: path.resolve(appName),
env: {
FORCE_COLOR: 1,
BROWSER: 'none',
},
});
};

Expand Down