diff --git a/.github/workflows/ci-workflows.yml b/.github/workflows/ci-workflows.yml new file mode 100644 index 00000000..2e5e8d35 --- /dev/null +++ b/.github/workflows/ci-workflows.yml @@ -0,0 +1,91 @@ +name: CI + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Setup PostgreSQL + uses: ikalnytskyi/action-setup-postgres@v5 + with: + port: 5432 + database: planka + username: planka + password: planka + + - name: Cache Node.js modules + id: cache-npm + uses: actions/cache@v3 + with: + path: | + /home/runner/work/planka/planka/node_modules + /home/runner/work/planka/planka/client/node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node_modules- + + - name: Install dependencies + run: | + npm install + cd client + npm run build + + - name: Save Node.js modules cache + uses: actions/cache@v3 + with: + path: | + /home/runner/work/planka/planka/node_modules + /home/runner/work/planka/planka/client/node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} + + - name: Symbolic fun + run: | + ln -s /home/runner/work/planka/planka/client/build/asset-manifest.json /home/runner/work/planka/planka/server/public/asset-manifest.json + ln -s /home/runner/work/planka/planka/client/build/favicon.ico /home/runner/work/planka/planka/server/public/favicon.ico + ln -s /home/runner/work/planka/planka/client/build/logo192.png /home/runner/work/planka/planka/server/public/logo192.png + ln -s /home/runner/work/planka/planka/client/build/logo512.png /home/runner/work/planka/planka/server/public/logo512.png + ln -s /home/runner/work/planka/planka/client/build/manifest.json /home/runner/work/planka/planka/server/public/manifest.json + ln -s /home/runner/work/planka/planka/client/build/robots.txt /home/runner/work/planka/planka/server/public/robots.txt + ln -s /home/runner/work/planka/planka/client/build/static /home/runner/work/planka/planka/server/public/static + ln -s /home/runner/work/planka/planka/client/build/index.html /home/runner/work/planka/planka/server/views/index.ejs + + - name: server setup + run: | + SECRETKEY=$(openssl rand -hex 64) + cd server + cp .env.sample .env + sed -i 's|^DATABASE_URL=.*|DATABASE_URL=postgresql://planka:planka@localhost/planka|' .env + sed -i "s|^SECRET_KEY=.*|SECRET_KEY=${SECRETKEY}/|" .env + sed -i 's/^# DEFAULT_ADMIN_EMAIL/DEFAULT_ADMIN_EMAIL/' .env + sed -i 's/^# DEFAULT_ADMIN_PASSWORD/DEFAULT_ADMIN_PASSWORD/' .env + sed -i 's/^# DEFAULT_ADMIN_NAME/DEFAULT_ADMIN_NAME/' .env + sed -i 's/^# DEFAULT_ADMIN_USERNAME/DEFAULT_ADMIN_USERNAME/' .env + npm run db:init + npm start --prod & + + - name: Wait for development server + run: | + sudo apt-get install wait-for-it -y + wait-for-it -h localhost -p 1337 -t 10 + + - name: Run e2e tests + run: | + cd client + npm install + npx playwright install chromium + npm run test:e2e tests diff --git a/client/cucumber.conf.js b/client/cucumber.conf.js index ab6f9a29..86a68ab0 100644 --- a/client/cucumber.conf.js +++ b/client/cucumber.conf.js @@ -8,7 +8,8 @@ setDefaultTimeout(60000); // launch the browser BeforeAll(async function () { global.browser = await chromium.launch({ - headless: false, + // makes true for CI + headless: true, slowMo: 1000, }); }); diff --git a/client/tests/acceptance/features/webUILogin/login.feature b/client/tests/acceptance/features/webUILogin/login.feature index 65ba588f..73c2c8b8 100644 --- a/client/tests/acceptance/features/webUILogin/login.feature +++ b/client/tests/acceptance/features/webUILogin/login.feature @@ -15,10 +15,10 @@ Feature: login When user logs in with username "" and password "" using the webUI Then user should see the error message "" Examples: - | username | password | message | - | spiderman | spidy123 | Invalid e-mail or username | - | ironman | iron123 | Invalid e-mail or username | - | aquaman | aqua123 | Invalid e-mail or username | + | username | password | message | + | spiderman | spidy123 | Invalid credentials | + | ironman | iron123 | Invalid credentials | + | aquaman | aqua123 | Invalid credentials | Scenario: User can log out diff --git a/client/tests/acceptance/pageObjects/LoginPage.js b/client/tests/acceptance/pageObjects/LoginPage.js index 5a8cdd8c..6b40d48d 100644 --- a/client/tests/acceptance/pageObjects/LoginPage.js +++ b/client/tests/acceptance/pageObjects/LoginPage.js @@ -1,7 +1,7 @@ class LoginPage { constructor() { // url - this.homeUrl = 'http://localhost:3000'; + this.homeUrl = 'http://localhost:1337'; this.loginUrl = `${this.homeUrl}/login`; this.loginButtonSelector = `//i[@class="right arrow icon"]`;