From f22d1615dd71080e62cbfa99fba607ec669a406b Mon Sep 17 00:00:00 2001 From: Jackie Quach Date: Thu, 19 Dec 2024 12:07:03 -0500 Subject: [PATCH] try running tests on local with updated hostname --- .github/workflows/Playwright.yml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Playwright.yml b/.github/workflows/Playwright.yml index 6c5b20f1..a9d34823 100644 --- a/.github/workflows/Playwright.yml +++ b/.github/workflows/Playwright.yml @@ -1,15 +1,12 @@ name: Playwright Tests for Digital Research Books on: - deployment_status: + pull_request: jobs: tests: - if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' name: Run Tests runs-on: ubuntu-latest - env: - BASE_URL: ${{ github.event.deployment_status.target_url }} steps: - name: Checkout uses: actions/checkout@v4 @@ -18,6 +15,19 @@ jobs: with: node-version-file: ".nvmrc" + - name: Set environment for branch + run: | + if [[ $GITHUB_REF_NAME == 'production' ]]; then + echo "BASE_URL=https://drb-qa.nypl.org/" >> "$GITHUB_ENV" + else + echo "BASE_URL=http://local.nypl.org:3000/" >> "$GITHUB_ENV" + fi + + - name: Add hosts to /etc/hosts + if: github.ref != 'production' + run: | + sudo echo "127.0.0.1 local.nypl.org" | sudo tee -a /etc/hosts + - name: Install Test Dependencies run: npm i @cucumber/cucumber@8.11.1 @playwright/test@1.29.1 @@ -27,6 +37,13 @@ jobs: - name: Build app run: NODE_ENV=test npm run build + - name: Start the app + if: github.ref != 'production' + run: | + NODE_ENV=test npm start & + sleep 5 + shell: bash + - name: Run your tests run: npm run playwright