|
| 1 | +describe("Sort entries", () => { |
| 2 | + // Top concepts from systematik.ttl, in source (TTL) order: |
| 3 | + // n1 Geisteswissenschaften, n2 Sport, n3 Rechts-..., n4 Mathematik, |
| 4 | + // n5 Humanmedizin, n7 Agrar-..., n8 Ingenieurwissenschaften, n9 Kunst |
| 5 | + // Notations: 1, 2, 3, 4, 5, 7, 8, 9 |
| 6 | + // Alphabetical (de): Agrar-, Geisteswissenschaften, Humanmedizin, |
| 7 | + // Ingenieurwissenschaften, Kunst, Mathematik, Rechts-, Sport |
| 8 | + const url = "/w3id.org/kim/hochschulfaechersystematik/scheme.html?lang=de" |
| 9 | + |
| 10 | + it("renders the sort selector with prefLabel as default", () => { |
| 11 | + cy.visit(url) |
| 12 | + cy.findByRole("combobox", { name: /sort entries by/i }) |
| 13 | + .should("exist") |
| 14 | + .and("have.value", "prefLabel") |
| 15 | + }) |
| 16 | + |
| 17 | + it("default order is alphabetical by prefLabel", () => { |
| 18 | + cy.visit(url) |
| 19 | + // First top-level link in the tree should start with "Agrar" |
| 20 | + cy.get(".concepts > nav, .concepts").should("exist") |
| 21 | + cy.get(".concepts ul li > div > a") |
| 22 | + .first() |
| 23 | + .invoke("text") |
| 24 | + .should("match", /Agrar/) |
| 25 | + }) |
| 26 | + |
| 27 | + it("switching to Notation reorders the tree by notation", () => { |
| 28 | + cy.visit(url) |
| 29 | + cy.findByRole("combobox", { name: /sort entries by/i }).select("notation") |
| 30 | + // Notation 1 → Geisteswissenschaften |
| 31 | + cy.get(".concepts ul li > div > a") |
| 32 | + .first() |
| 33 | + .invoke("text") |
| 34 | + .should("match", /Geisteswissenschaften/) |
| 35 | + }) |
| 36 | + |
| 37 | + it("switching to Source order preserves TTL order", () => { |
| 38 | + cy.visit(url) |
| 39 | + cy.findByRole("combobox", { name: /sort entries by/i }).select("none") |
| 40 | + cy.get(".concepts ul li > div > a") |
| 41 | + .first() |
| 42 | + .invoke("text") |
| 43 | + .should("match", /Geisteswissenschaften/) |
| 44 | + }) |
| 45 | + |
| 46 | + it("sort selector is visible even on flat schemes (no hierarchy)", () => { |
| 47 | + cy.visit("/purl.org/dcx/lrmi-vocabs/interactivityType/index.html", { |
| 48 | + onBeforeLoad(win) { |
| 49 | + Object.defineProperty(win.navigator, "language", { value: "en-EN" }) |
| 50 | + }, |
| 51 | + }) |
| 52 | + cy.findByRole("combobox", { name: /sort entries by/i }).should("exist") |
| 53 | + // Collapse/Expand should still be hidden on flat schemes |
| 54 | + cy.contains("Collapse").should("not.exist") |
| 55 | + cy.contains("Expand").should("not.exist") |
| 56 | + }) |
| 57 | +}) |
0 commit comments