Skip to content

Commit

Permalink
[CMSP-1459] Fixes URL normalization process (#138)
Browse files Browse the repository at this point in the history
* add new helper function that parses and normalizes a url from parts

* Update URL normalization function to refactor using __rebuild_url_from_parts

* check if endpoint is defined already

* dont' use anonymous function

* add host if exists

* replace graphql endpoint filter with an action hook to prepopulate
this is a setting that can be changed, so this way we're setting it to what we think it should be without forcing users to use our path

* move the prepopulate action and make it more robust
use dynamic site_url and make the setting conditional based on whether there's already a /wp/ i the siteurl

* add exclusions to site_url filter for graphql

* add playwright tests

* change ci to install

* don't create the site if it already exists

* add git config for the user

* wait for the last action to finish before switching to sftp mode

* set pretty permalinks for playwright test site

* switch the existing site to git mode

* force yes

* check the h2 instead of the site title
that's a theme thing. the canary sites are running a different theme

* test that the resource urls have /wp/ in the path

* missing "

* expect the resource url to be truthy on a request

* append the commit message from the PR to the commit to the test site

* use github token so we can use gh

* add package.json to export-ignore

* move the commit msg var up
so we haven't cd'd into the local copy when we're looking for the commit message

* we don't need `page` at all

* this doesn't change anything other than seeing if we're getting the PR number

* fix the commit message

* Include the git commit message body
so it's not just truncated if it's long

* don't fail if there's nothing to commit

* add caching for dependencies

* fix hello world test

* emdash problems

* fix the locator on the welcome message test

* generate lock files so we can use the cache

* pass default values
so the substr check isn't null

* change test to toContainText

* only generate the npm lock
use the composer.json instead of composer.lock
use the conditional to check for cache

* party pooper 💩

Co-authored-by: Phil Tyler <[email protected]>

* bail early

---------

Co-authored-by: Phil Tyler <[email protected]>
  • Loading branch information
jazzsequence and pwtyler committed Aug 1, 2024
1 parent e3d1199 commit da41ae7
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 374 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github export-ignore
/package.json export-ignore
19 changes: 3 additions & 16 deletions .github/tests/wpcm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "@playwright/test";

const exampleArticle = "Hello world!";
const siteTitle = process.env.SITE_NAME || "WPCM Playwright Tests";
const siteTitle = "WPCM Playwright Tests";
const siteUrl = process.env.SITE_URL || "https://dev-wpcm-playwright-tests.pantheonsite.io";

test("homepage loads and contains example content", async ({ page }) => {
Expand All @@ -11,11 +11,7 @@ test("homepage loads and contains example content", async ({ page }) => {
});

test("WP REST API is accessible", async ({ request }) => {
let apiRoot = await request.get(`${siteUrl}/wp-json`);
// If the api endpoint isn't /wp-json, it should be /wp/wp-json. This will probably be the case for main sites on subdirectory multisites.
if (!apiRoot.ok()) {
apiRoot = await request.get(`${siteUrl}/wp/wp-json`);
}
const apiRoot = await request.get(`${siteUrl}/wp-json`);
expect(apiRoot.ok()).toBeTruthy();
});

Expand All @@ -41,15 +37,6 @@ 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`);
// 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`;
apiRoot = await request.get(`${siteUrl}/graphql`);
}

expect(apiRoot.ok()).toBeTruthy();
const query = `
query {
posts(where: { search: "${exampleArticle}" }) {
Expand All @@ -62,7 +49,7 @@ test("graphql is able to access hello world post", async ({ request }) => {
}
`;

const response = await request.post(graphqlEndpoint, {
const response = await request.post(`${siteUrl}/wp/graphql`, {
data: {
query: query
},
Expand Down
Loading

0 comments on commit da41ae7

Please sign in to comment.