From 46aaa50e7b4b9c705c6e84d0a3de415d27b11721 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 16:47:32 -0600 Subject: [PATCH] allow the graphql endpoint to be passed we can use this to fix the subdirectory test, too, but later --- .github/tests/wpcm.spec.ts | 4 ++-- .github/workflows/playwright.yml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/tests/wpcm.spec.ts b/.github/tests/wpcm.spec.ts index 573fa177..daa4d933 100644 --- a/.github/tests/wpcm.spec.ts +++ b/.github/tests/wpcm.spec.ts @@ -3,6 +3,7 @@ import { test, expect } from "@playwright/test"; const exampleArticle = "Hello world!"; const siteTitle = process.env.SITE_NAME || "WPCM Playwright Tests"; const siteUrl = process.env.SITE_URL || "https://dev-wpcm-playwright-tests.pantheonsite.io"; +let graphqlEndpoint = process.env.GRAPHQL_ENDPOINT || `${siteUrl}/wp/graphql`; test("homepage loads and contains example content", async ({ page }) => { await page.goto(siteUrl); @@ -41,8 +42,7 @@ test("validate core resource URLs", async ({ request }) => { }); test("graphql is able to access hello world post", async ({ request }) => { - let graphqlEndpoint = `${siteUrl}/wp/graphql`; - let apiRoot = await request.get(`${siteUrl}/wp/graphql`); + let apiRoot = await request.get(graphqlEndpoint); // If the above request doesn't resolve, it's because we're on a subsite where the path is ${siteUrl}/graphql -- similar to the rest api. if (!apiRoot.ok()) { graphqlEndpoint = `${siteUrl}/graphql`; diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index d9099541..b739cd30 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -447,9 +447,11 @@ jobs: env: SITE_NAME: ${{ env.SITE_NAME }} SITE_URL: ${{ env.SITE_URL }} + GRAPHQL_ENDPOINT: ${{ env.SITE_URL }}/wp/graphql run: npm run test .github/tests/wpcm.spec.ts - name: Run Playwright tests on subdomain site env: SITE_NAME: Foo SITE_URL: ${{ env.SUBDOMAIN_URL }} + GRAPHQL_ENDPOINT: ${{ env.SUBDOMAIN_URL }}/wp/graphql run: npm run test .github/tests/wpcm.spec.ts