Skip to content

Commit

Permalink
Merge branch '263-vocabs-without-apache' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sroertgen committed Dec 11, 2023
2 parents 115e038 + ef56223 commit fbe716a
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 3 deletions.
41 changes: 41 additions & 0 deletions cypress/e2e/conceptSchemeAndConcept.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,45 @@ describe("Concept Scheme and Concept", () => {
.then((clip) => clip.readText())
.should("equal", "https://w3id.org/kim/hochschulfaechersystematik/n1")
})

it("Visting a slash URI Concept Scheme works", () => {
cy.visit("/w3id.org/index.html", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "de-DE" })
},
})
cy.get(".conceptScheme > a").should("have.text", "Test Vokabular")
cy.get("h1").should("have.text", "Test Vokabular")
cy.get(".markdown > span").should("have.text", "Test Beschreibung")
})

it("Visting a slash URI Concept works", () => {
cy.visit("/w3id.org/c1.html", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "de-DE" })
},
})
cy.get(".conceptScheme > a").should("have.text", "Test Vokabular")
cy.get("h1").should("include.text", "Konzept 1")
})

it("Visting a hash URI Concept Scheme works", () => {
cy.visit("/example.org/hashURIConceptScheme.html", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "de-DE" })
},
})
cy.get(".conceptScheme > a").should("have.text", "Hash URI Konzept Schema")
cy.get("h1").should("have.text", "Hash URI Konzept Schema")
})

it("Visting a hash URI Concept works", () => {
cy.visit("/example.org/hashURIConceptScheme.html#concept1", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "de-DE" })
},
})
cy.get(".conceptScheme > a").should("have.text", "Hash URI Konzept Schema")
cy.get("h1").should("have.text", "Konzept 1")
})
})
14 changes: 14 additions & 0 deletions cypress/e2e/index.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,18 @@ describe("Main Vocab Index page", () => {
name: "Test Vokabular",
}).should("exist")
})

it("shows no concept scheme in header if going back to index page from concept", () => {
cy.visit("/", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "de-DE" })
},
})
cy.contains("Destatis-Systematik").click()
cy.findByRole("link", {
name: "Destatis-Systematik der Fächergruppen, Studienbereiche und Studienfächer",
}).should("exist")
cy.go("back")
cy.get(".conceptScheme > a").should("not.exist")
})
})
20 changes: 19 additions & 1 deletion cypress/e2e/searchAndFilter.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,25 @@ describe("search and filter", () => {
cy.get("span").contains("Konzept 2").should("not.exist")
})

it("search for nested concept works", () => {
it("search for nested concept works (hash URIs)", () => {
cy.intercept("GET", "/example.org/hashURIConceptScheme-cs/search/**").as(
"getSearchIndices"
)
cy.visit("/example.org/hashURIConceptScheme.html", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "de-DE" })
},
})

cy.wait("@getSearchIndices")
cy.get("span").contains("Konzept 2").should("exist")
cy.findByRole("textbox").type("Konzept 4")
cy.get("span").contains("Konzept 1").should("exist")
cy.get("span").contains("Konzept 2").should("not.exist")
cy.get("span").contains("Konzept 3").should("not.exist")
})

it("search for nested concept works (slash URIs)", () => {
cy.intercept("GET", "/w3id.org/index-cs/search/**").as("getSearchIndices")
cy.visit("/w3id.org/index.html", {
onBeforeLoad(win) {
Expand Down
15 changes: 14 additions & 1 deletion src/components/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ const Header = ({ siteTitle }) => {
}
}
`

const [languages, setLanguages] = useState([])
const [language, setLanguage] = useState("")

Expand Down Expand Up @@ -126,6 +125,20 @@ const Header = ({ siteTitle }) => {
}
}, [data?.currentScheme?.id, data?.languages])

// we check if we are on the root i.e. index page.
// if so we set the concept scheme to an empty object
useEffect(() => {
const handleNavigation = () => {
if (window.location.pathname === "/") {
updateState({ ...data, currentScheme: {} })
}
}
window.addEventListener("popstate", handleNavigation)
return () => {
window.removeEventListener("popstate", handleNavigation)
}
}, [])

return (
<header css={style}>
<div className="headerContent">
Expand Down
2 changes: 1 addition & 1 deletion src/templates/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const App = ({ pageContext, children }) => {
const toggleClick = (e) => setLabels({ ...labels, [e]: !labels[e] })

return (
<Layout language={pageContext.language}>
<Layout>
<SEO
title={i18n(pageContext.language)(
pageContext.node.prefLabel || pageContext.node.title
Expand Down

0 comments on commit fbe716a

Please sign in to comment.