Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into pr/16955
Browse files Browse the repository at this point in the history
  • Loading branch information
akristen committed May 6, 2024
2 parents a4f3214 + fa50bb4 commit 7bf2ed1
Show file tree
Hide file tree
Showing 1,235 changed files with 86,237 additions and 72,257 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
Thanks for your pull request! Your PR is in a queue, and a writer will take a look soon. We generally publish small edits within one business day, and larger edits within three days.
We will automatically generate a preview of your request, and will comment with a link when the preview is ready (usually 10 to 20 minutes). If you add any more commits, you can comment `netlify build` on this PR to update the preview.
We will automatically generate a preview of your request, and will comment with a link when the preview is ready (usually 10 to 20 minutes).
issuesOpened: |
Hi @{{ author }} 👋
Expand Down
3 changes: 3 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ module.exports = {
'./plugins/gatsby-remark-remove-button-paragraphs'
),
},
{
resolve: require.resolve('./plugins/fix-remark-path-prefix-plugin'),
}
],
},
},
Expand Down
17 changes: 4 additions & 13 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
edges {
node {
frontmatter {
type
subject
}
fields {
fileRelativePath
Expand All @@ -82,7 +82,6 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
slug
}
frontmatter {
type
subject
}
}
Expand All @@ -99,7 +98,6 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
slug
}
frontmatter {
type
subject
translationType
}
Expand Down Expand Up @@ -369,6 +367,9 @@ exports.onCreatePage = ({ page, actions }) => {
if (page.path.match(/404/)) {
page.context.layout = 'basic';
}
if (page.path === '/') {
page.context.layout = 'homepage';
}

if (page.path.match(/404/) && page.path.match(/\/docs\//)) {
page.context.layout = 'default';
Expand Down Expand Up @@ -451,23 +452,13 @@ const createPageFromNode = (
}
};

const TEMPLATES_BY_TYPE = {
landingPage: 'landingPage',
apiDoc: 'docPage',
releaseNote: 'releaseNote',
troubleshooting: 'docPage',
};

const getTemplate = (node) => {
const {
frontmatter,
fields: { fileRelativePath },
} = node;

switch (true) {
case Boolean(frontmatter.type):
return { template: TEMPLATES_BY_TYPE[frontmatter.type] };

case /docs\/release-notes\/.*\/index.mdx$/.test(fileRelativePath):
return {
template: 'releaseNoteLandingPage',
Expand Down
4 changes: 0 additions & 4 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ package = "@netlify/plugin-gatsby"
[functions]
included_files = ["!.cache/data/datastore/data.mdb","!.cache/query-engine"]

[[edge_functions]]
path = "/*"
function = "osano-country"

[[headers]]
for = "/*"

Expand Down
53 changes: 0 additions & 53 deletions netlify/edge-functions/osano-country.js

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@emotion/styled": "^11.3.0",
"@mdx-js/mdx": "2.0.0-next.8",
"@mdx-js/react": "2.0.0-next.8",
"@newrelic/gatsby-theme-newrelic": "9.5.0",
"@newrelic/gatsby-theme-newrelic": "9.5.2",
"@splitsoftware/splitio-react": "^1.2.4",
"ansi-colors": "^4.1.3",
"cockatiel": "^3.0.0-beta.0",
Expand Down Expand Up @@ -220,4 +220,4 @@
"bugs": {
"url": "https://github.com/newrelic/docs-website/issues"
}
}
}
21 changes: 21 additions & 0 deletions plugins/fix-remark-path-prefix-plugin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const visit = require('unist-util-visit');

module.exports = ({ markdownAST, pathPrefix }, { basePath = ''}) => {
// https://github.com/gatsbyjs/gatsby/issues/38362

if (pathPrefix?.match('^(https?:\\/\\/)?')) {
const url = pathPrefix.replace(/(http(s)*:)\/\//, `$1/`);
visit(markdownAST, 'link', node => {
if (node.url.includes(url)) {
const newUrl = node.url.replace(url, basePath) || '/';
node.url = newUrl;
if (node.data?.hProperties?.target === '_blank') {
delete node.data.hProperties.target;
delete node.data.hProperties.rel;
}
}
});
}

return markdownAST;
}
1 change: 1 addition & 0 deletions plugins/fix-remark-path-prefix-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
28 changes: 21 additions & 7 deletions scripts/actions/webdriver-desktop.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
* synthetics check that runs on the production site.
* if you make updates, be sure to add them there as well.
* https://staging.onenr.io/037jbB4Akjy
*
*
* To test locally:
* Run `yarn start`, and make sure the localhost testUrl
* matches the one where your site is running.
*
* Then run `yarn webdriver-desktop`. It is very slow.
*
* If you want to watch the webdriver run in a browser
* you can comment out the options on lines 25-27
*/

import assert from 'assert';
Expand All @@ -23,15 +33,19 @@ const waitForXPath = (xpath, timeout = TIMEOUT) =>
driver.wait(until.elementsLocated(By.xpath(xpath)), timeout);

const main = async () => {
console.log('\n🧪 Beginning desktop test...');
// running on develop builds because the url is static
// github workflow triggers on PRs to main

const testUrl =
process.env.WEBDRIVER_ENV === 'main'
? 'https://docswebsitedevelop.gatsbyjs.io/'
? 'https://develop--docs-website-netlify.netlify.app/'
: 'http://localhost:8000/';

console.log('\n🔍 looking for site at', testUrl);
await driver.get(testUrl + 'docs/mdx-test-page/');

console.log('\n⏳ Waiting for kitchen sink page to load.');
// Ensure page loads, 2000 ms wait
await driver.sleep(SLEEP_TIME);

Expand All @@ -40,7 +54,9 @@ const main = async () => {
await searchTest();
await navTest();

console.log('\n⏳ Waiting for home page to load.');
await driver.get(testUrl);

// Ensure home page loads, 2000 ms wait
await driver.sleep(SLEEP_TIME);
await tileTest();
Expand All @@ -55,7 +71,7 @@ const collapserTest = async () => {
);

const { y: initialTop } = await secondCollapser.getRect();
console.log('clicking first collapser');
console.log('\nClicking first collapser');
await firstCollapser.click();
const { y: afterTop } = await secondCollapser.getRect();
assert.notEqual(
Expand All @@ -71,7 +87,7 @@ const navTest = async () => {
const [releaseNotes] = await waitForXPath(releaseNotesXPath);
const [initialNextNode] = await waitForXPath(nextNodeXPath);
await driver.executeScript('arguments[0].scrollIntoView()', releaseNotes);
console.log('clicking Release Notes div');
console.log('\nClicking Release Notes div in the Nav');
await releaseNotes.click();
const [afterNextNode] = await waitForXPath(nextNodeXPath);
assert.notEqual(
Expand All @@ -83,7 +99,7 @@ const navTest = async () => {

const searchTest = async () => {
const [searchInput] = await waitForXPath('//aside//input');
console.log('clicking search input');
console.log('\nClicking search input');
await searchInput.click();
const activeEl = await driver.executeScript('return document.activeElement');
assert(
Expand All @@ -94,9 +110,7 @@ const searchTest = async () => {

const tileTest = async () => {
const initialUrl = await driver.getCurrentUrl();

console.log('clicking Homepage doctile');

console.log('\nClicking home page Doctile');
// Added this xpath for the scroll function.
// for some reason, when running in headless mode the site
// header overlaps the tile we need to click
Expand Down
22 changes: 13 additions & 9 deletions scripts/actions/webdriver-mobile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,28 @@ const waitForXPath = (xpath, timeout = TIMEOUT) =>
driver.wait(until.elementsLocated(By.xpath(xpath)), timeout);

const main = async () => {
console.log('\n🧪 Beginning mobile test...');

// running on develop builds because the url is static
// github workflow triggers on PRs to main
const testUrl =
// TODO: search modal click breaks page on mobile localhost
process.env.WEBDRIVER_ENV === 'main'
? 'https://docswebsitedevelop.gatsbyjs.io/'
? 'https://develop--docs-website-netlify.netlify.app/'
: 'http://localhost:8000/';

await driver.get(testUrl + 'docs/mdx-test-page/');
console.log('\n🔍 looking for site at', testUrl);

// order here matters — some tests scroll the page
// `searchTest` opens the search modal, any tests on the same page
// that come afterwards would have to close the modal
await collapserTest();
await searchTest();

// and the current homepage does not have the hamburger menu for `navTest`
await driver.get(testUrl);
await tileTest();
await navTest();
await driver.get(testUrl + 'docs/mdx-test-page/');
await collapserTest();
await searchTest();

// this step isn't necessary in synthetics
await driver.quit();
Expand All @@ -55,7 +58,7 @@ const collapserTest = async () => {
'//h5[contains(@id, "collapser")]/ancestor::button'
);
const { y: initialTop } = await secondCollapser.getRect();
console.log('clicking first collapser');
console.log('\nClicking first collapser');
await firstCollapser.click();
// sleep is required here on mobile to account for the click delay
await driver.sleep(SLEEP_TIME);
Expand All @@ -73,13 +76,14 @@ const navTest = async () => {
const [hamburgerButton] = await waitForXPath(
'//header//button[contains(@aria-label, "Mobile")]'
);
console.log('\nOpening mobile Nav menu');
await hamburgerButton.click();
await driver.sleep(SLEEP_TIME);
// nav on mobile is a new list, the desktop nav comes first in the DOM but is hidden
const [_desktopRN, releaseNotes] = await waitForXPath(releaseNotesXPath);
const [_desktopINN, initialNextNode] = await waitForXPath(nextNodeXPath);
await driver.executeScript('arguments[0].scrollIntoView()', releaseNotes);
console.log('clicking Release Notes div');
console.log('\nClicking Release Notes div');
await releaseNotes.click();
const [_desktopANN, afterNextNode] = await waitForXPath(nextNodeXPath);
assert.notEqual(
Expand All @@ -91,7 +95,7 @@ const navTest = async () => {

const searchTest = async () => {
const [searchButton] = await waitForXPath('//a[contains(@href, "?q=")]');
console.log('clicking search button');
console.log('\nClicking search input');
await searchButton.click();
// sleep is required here on mobile to account for the click delay
await driver.sleep(SLEEP_TIME);
Expand All @@ -113,7 +117,7 @@ const tileTest = async () => {
'arguments[0].scrollIntoView(false)',
firstDocTile
);
console.log('clicking doc tile');
console.log('\nClicking home page Doctile');
await firstDocTile.click();
await driver.wait(
until.stalenessOf(firstDocTile),
Expand Down

0 comments on commit 7bf2ed1

Please sign in to comment.