Skip to content

Commit

Permalink
Merge pull request #3178 from owid/nav-updates
Browse files Browse the repository at this point in the history
🎉 update header nav to new taxonomy
  • Loading branch information
ikesau authored Feb 8, 2024
2 parents 83c8974 + 6f0b3d3 commit a9497ba
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 291 deletions.
41 changes: 41 additions & 0 deletions devTools/navigationTest/navigationTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Test all the slugs in the SiteNavigationStatic object and makes sure
// https://ourworldindata.org/{slug} returns a 200

import { SiteNavigationStatic } from "../../site/SiteNavigation.js"

const testSiteNavigation = async () => {
const slugs = SiteNavigationStatic.categories
.map((category) => {
const categorySlugs = category.entries
.map((entry) => entry.slug)
.concat(
(category.subcategories?.length &&
category.subcategories.flatMap((subcategory) =>
subcategory.entries.map((entry) => entry.slug)
)) ||
[]
)
return categorySlugs
})
.flat()

let promises = slugs.map((slug) => {
return fetch(`https://ourworldindata.org/${slug}`, {
method: "HEAD",
})
})

const responses: Response[] = await Promise.all(promises)
if (responses.some((response) => !response.ok)) {
console.error(
"❌ One or more fetches failed: ",
responses
.filter((response) => !response.ok)
.map((response) => response.url)
)
return
}
console.log("✅ All fetches completed")
}

testSiteNavigation()
8 changes: 8 additions & 0 deletions devTools/navigationTest/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfigs/tsconfig.base.json",
"compilerOptions": {
"outDir": "../../itsJustJavascript/devTools/navigationTest",
"rootDir": "."
},
"references": [{ "path": "../../site" }]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"testLint": "eslint .",
"testPrettierAll": "yarn prettier --check \"**/*.{tsx,ts,jsx,js,json,md,html,css,scss,yml}\"",
"testJest": "lerna run buildTests && jest",
"testSiteNavigation": "node --enable-source-maps ./itsJustJavascript/devTools/navigationTest/navigationTest.js",
"generateDbTypes": "npx @rmp135/sql-ts -c db/sql-ts/sql-ts-config.json"
},
"dependencies": {
Expand Down
Loading

0 comments on commit a9497ba

Please sign in to comment.