Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

263 vocabs without apache #279

Merged
merged 38 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3865e0a
WIP Kind of working now without the custom language tags #263
sroertgen Oct 27, 2023
5becf90
Fix components, especially collections. Remove non necessary files
sroertgen Nov 2, 2023
fab2912
Add `fail on validation` config option.
sroertgen Nov 2, 2023
188768b
Update components and hooks
sroertgen Nov 2, 2023
037ed00
Adjust e2e tests
sroertgen Nov 2, 2023
413d937
Adjust concept tests
sroertgen Nov 3, 2023
895ade7
Adjust config test
sroertgen Nov 3, 2023
2747b3e
Adjust header tests. Almost everything working now!
sroertgen Nov 3, 2023
8239354
Simplify mock
sroertgen Nov 3, 2023
b2b07fe
Adjust collection test. Now all tests are working! 🎉
sroertgen Nov 3, 2023
bafe81b
Add missing optional chaining operator. But now it should work! 🎉🎉
sroertgen Nov 3, 2023
7c5eb37
Adjust scrolling test
sroertgen Nov 6, 2023
09a217b
update start-server package
sroertgen Nov 6, 2023
3b1d058
Turn on e2e tests again
sroertgen Nov 7, 2023
ddbf1b2
Update packages to most recent version
sroertgen Nov 7, 2023
46ae7d4
Remove logging from build
sroertgen Nov 7, 2023
4243f5d
Try headed mode for GitHub Action
sroertgen Nov 7, 2023
8512ade
Disable currentLanguage check to see if the rest goes through
sroertgen Nov 7, 2023
a2f8bfa
Add e2e as dependency to docker build
sroertgen Nov 7, 2023
d675ac2
Add wait command. Test still randomly fails sometimes
sroertgen Nov 7, 2023
930c74b
Remove wait command. Works locally.
sroertgen Nov 7, 2023
d6fef4e
Lets try an interceptor
sroertgen Nov 7, 2023
f4c12ed
Add more defaults if languages can't be found #280
sroertgen Nov 16, 2023
4920c8e
Add optional chaining operator
sroertgen Nov 17, 2023
0f5919e
Add second interceptor, because test in CI sometimes fails
sroertgen Nov 17, 2023
5f88603
Add interceptor
sroertgen Nov 17, 2023
e0b7482
Improve language parsing
sroertgen Nov 17, 2023
6d8a149
Fix search index import and export for ConceptSchemes containing a ha…
sroertgen Nov 20, 2023
f43abfe
Fix language parsing if a language was already selected
sroertgen Nov 20, 2023
28f46d2
Remove unused dependency from component
sroertgen Nov 20, 2023
57281f3
Adjust tests to improved language parsing
sroertgen Nov 20, 2023
70ae53c
Add e2e tests for hash URIs
sroertgen Nov 21, 2023
25da862
Layout component does not need language info any more
sroertgen Dec 5, 2023
ef56223
Fix navigation issue #283
sroertgen Dec 5, 2023
e4ab042
Add state to determin if on index page. Fixes #283
sroertgen Dec 12, 2023
5bc7693
Add support for parsing of language from url param
sroertgen Jan 12, 2024
45e7e7c
Add e2e tests for language parsing from URL when visting Concept Sche…
sroertgen Jan 15, 2024
10cec8f
Add info about i18n and URL parameters
sroertgen Jan 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,33 @@ jobs:
- run: npm run test

# disables because the action fails on github action but tests works locally
# e2e:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# node-version: [18.x]
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
# - run: echo Using node version $(node --version)
# - run: echo Using npm version $(npm --version)
# - run: cypress/prepare-cypress-test.sh
# - name: Cypress run
# uses: cypress-io/github-action@v5
# with:
# browser: chrome
# headed: true
# start: npm run develop -- -p 8000
# wait-on: http://localhost:8000/index.de.html
# config: baseUrl=http://localhost:8000
e2e:
runs-on: ubuntu-22.04
container:
image: cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: echo Using node version $(node --version)
- run: echo Using npm version $(npm --version)
- run: cypress/prepare-cypress-test.sh
- name: Cypress run
uses: cypress-io/github-action@v6
with:
headed: true
start: npm run develop -- -p 8000
wait-on: 'http://0.0.0.0:8000' # see https://github.com/cypress-io/github-action#wait-on-with-nodejs-18
config: baseUrl=http://localhost:8000

docker:
needs: [build]
needs: [build, e2e]
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' }}
runs-on: ubuntu-latest
steps:
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ In general we advise the use of slash URIs for SKOS vocabularies.

If you would like more support of hash URIs for SkoHub Vocabs, [please open an issue](https://github.com/skohub-io/skohub-vocabs/issues/new/choose).

## Internationalization

To determine the language displayed of the vocabulary the browser language is used.
If the browser language is not present in the vocabulary a default language is chosen.
If you want to link to a specific language, you can use a URL parameter: `?lang=de`.

## Set up

### Install Node.js
Expand Down Expand Up @@ -125,6 +131,7 @@ You can configure the following settings:

- Tokenizer used for searching
- Custom Domain
- Fail on Validation
- UI Configurations
- Title
- Logo
Expand All @@ -148,6 +155,10 @@ Example:
The base of your concept scheme is: `http://my-awesome-domain.org/my-vocab`
Then provide `http://my-awesome-domain.org` as `custom_domain` in your `config.yaml`

### Fail on Validation

If `true` (default) the build process will stop if a validation error occures.

### UI

The following customizations can be made:
Expand Down
1 change: 1 addition & 0 deletions config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# see https://github.com/nextapps-de/flexsearch#tokenizer-prefix-search for options
tokenizer: "full" # strict, forward, reverse, full
custom_domain: ""
fail_on_validation: true
searchableAttributes:
- "prefLabel" # you should not delete this one
- "notation"
Expand Down
38 changes: 38 additions & 0 deletions cypress/config.e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# see https://github.com/nextapps-de/flexsearch#tokenizer-prefix-search for options
tokenizer: "full" # strict, forward, reverse, full
custom_domain: ""
fail_on_validation: false
searchableAttributes:
- "prefLabel" # you should not delete this one
- "notation"
- "altLabel"
- "hiddenLabel"
- "example"
- "definition"
ui:
title: "SkoHub Vocabs" # Title is mandatory
logo: "skohub-signet-color.svg" # Path
colors:
skoHubWhite: "rgb(255, 255, 255)"
skoHubDarkColor: "rgb(15, 85, 75)"
skoHubMiddleColor: "rgb(20, 150, 140)"
skoHubLightColor: "rgb(40, 200, 175)"
skoHubThinColor: "rgb(55, 250, 210)"
skoHubBlackColor: "rgb(5, 30, 30)"
skoHubAction: "rgb(230, 0, 125)"
skoHubNotice: "rgb(250, 180, 50)"
skoHubDarkGrey: "rgb(155, 155, 155)"
skoHubMiddleGrey: "rgb(200, 200, 200)"
skoHubLightGrey: "rgb(235, 235, 235)"
fonts:
regular:
font_family: "Ubuntu"
font_style: "normal"
font_weight: 400
name: "ubuntu-v20-latin-regular"
bold:
font_family: "Ubuntu"
font_style: "normal"
font_weight: 700
name: "ubuntu-v20-latin-700"
77 changes: 71 additions & 6 deletions cypress/e2e/conceptSchemeAndConcept.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,100 @@ describe("Concept Scheme and Concept", () => {
it("Scrolling in Nested List and Concept on wide screen", () => {
// we need a wider view to test scrolling in navbar and concept page
cy.viewport(1280, 768)
cy.visit("/w3id.org/kim/hochschulfaechersystematik/n1.de.html")
cy.visit("/w3id.org/kim/hochschulfaechersystematik/n1.html")
cy.findByRole("button", { name: "Expand" }).click()
cy.get(".concepts").scrollTo("bottom")
cy.get("[id$=n1]").scrollTo("bottom")
})

it("Scrolling in Nested List and Concept on smaller screen", () => {
// we need a wider view to test scrolling in navbar and concept page
cy.viewport(1024, 768)
cy.visit("/w3id.org/kim/hochschulfaechersystematik/n1.de.html")
cy.visit("/w3id.org/kim/hochschulfaechersystematik/n1.html")
cy.findByRole("button", { name: "Expand" }).click()
cy.get(".concepts").scrollTo("bottom")
cy.scrollTo("bottom")
})

it("Scrolling in Nested List and Concept on small screen", () => {
// we need a wider view to test scrolling in navbar and concept page
cy.viewport(800, 768)
cy.visit("/w3id.org/kim/hochschulfaechersystematik/n1.de.html")
cy.visit("/w3id.org/kim/hochschulfaechersystematik/n1.html")
cy.findByRole("button", { name: "Expand" }).click()
cy.get(".nav-block").scrollTo("bottom")
cy.scrollTo("bottom")
})

it("Copying URI works", () => {
cy.visit("/w3id.org/kim/hochschulfaechersystematik/n1.de.html")
cy.visit("/w3id.org/kim/hochschulfaechersystematik/n1.html")
cy.get(".tooltip > button").click()
cy.window()
.its("navigator.clipboard")
.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")
})
})

describe("Parsing language from URL on Concept Schemes and Concepts", () => {
it("Visting a Concept Scheme directly with a language url param shows correct language", () => {
cy.visit("/w3id.org/kim/hochschulfaechersystematik/scheme.html?lang=de", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "en-EN" })
},
})
cy.get(".conceptScheme > a").should(
"have.text",
"Destatis-Systematik der Fächergruppen, Studienbereiche und Studienfächer"
)
})
it("Visting a Concept directly with a language url param shows correct language", () => {
cy.visit("/w3id.org/kim/hochschulfaechersystematik/n1.html?lang=de", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "en-EN" })
},
})
cy.get(".conceptScheme > a").should(
"have.text",
"Destatis-Systematik der Fächergruppen, Studienbereiche und Studienfächer"
)
})
})
13 changes: 11 additions & 2 deletions cypress/e2e/header.cy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
describe("Test header specific rendering", () => {
it("shows only one concept scheme in header even when a concept has multiple", () => {
cy.visit("/w3id.org/two-concepts-one-file/c1.de.html")
cy.visit("/w3id.org/two-concepts-one-file/c1.html", {
// need to set browser language
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "de-DE" })
},
})
cy.findByRole("link", { name: "Test Vokabular 1" }).should("exist")
cy.findByRole("link", { name: "Test Vokabular 2" }).should("not.exist")
})

it("when switching concepts there is only one concept scheme in header", () => {
cy.visit("/w3id.org/two-concepts-one-file/c2.de.html")
cy.visit("/w3id.org/two-concepts-one-file/c2.html", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "de-DE" })
},
})
cy.findByRole("link", { name: "Test Vokabular 1" }).should("exist")
cy.findByRole("link", { name: "Test Vokabular 2" }).should("not.exist")
})
Expand Down
54 changes: 52 additions & 2 deletions cypress/e2e/index.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
describe("Main Vocab Index page", () => {
it("Visits index page and test language switch", () => {
cy.visit("/index.de.html")

cy.visit("/", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "de-DE" })
},
})
// vocabs are found
cy.get(".centerPage > ul li").should("have.length", 7)

Expand Down Expand Up @@ -51,4 +54,51 @@ 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")
})

it("German language is selected, when lang=de param is given in url", () => {
cy.visit("/?lang=de", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "en-EN" })
},
})
cy.findByRole("link", {
name: "Test Vokabular",
}).should("exist")
})

it("The navigator language is used as fallback language, when the language from url param 'lang' is not found", () => {
cy.visit("/?lang=bla", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "en-EN" })
},
})
cy.findByRole("link", {
name: "Test Vocabulary",
}).should("exist")
})

it("A fallback language is used, when neither navigator language nor language from url param 'lang' is found", () => {
cy.visit("/?lang=bla", {
onBeforeLoad(win) {
Object.defineProperty(win.navigator, "language", { value: "fr-FR" })
},
})
cy.findByRole("link", {
name: "Test Vokabular",
}).should("exist")
})
})
Loading