Files
swagger-ui/test/e2e-cypress/e2e/features/license.cy.js
kyy f464ba2d31
Some checks failed
Node.js CI / build (push) Failing after 2s
Node.js CI / e2e-tests (+(a11y|security|bugs)/**/*cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/!(o|d|m)*.cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/+(o|d)*.cy.js) (push) Failing after 2s
Node.js CI / e2e-tests (features/**/m*.cy.js) (push) Failing after 2s
CodeQL / Analyze (javascript) (push) Failing after 2m49s
Security scan for docker image / build (push) Failing after 51s
Update swagger-ui
2025-06-24 13:40:26 +09:00

114 lines
3.5 KiB
JavaScript
Executable File

/**
* @prettier
*/
describe("Render License Component", () => {
describe("OpenAPI 2.0", () => {
const baseUrl = "/?url=/documents/features/license-openAPI2.yaml"
it("should render License URL", () => {
cy.visit(baseUrl)
.get(".info__license")
.should("exist")
.should("contains.text", "Apache 2.0")
})
it("should render License URL anchor target xss link with safe `rel` attributes", () => {
cy.visit(baseUrl)
.get(".info__license__url > .link")
.should("have.attr", "rel")
.and("include", "noopener")
.and("include", "noreferrer")
.get(".info .main > a")
.should("have.attr", "target")
.and("equal", "_blank")
})
})
describe("OpenAPI 3.0.x", () => {
const baseUrl = "/?url=/documents/features/license-openAPI30.yaml"
it("should render License URL", () => {
cy.visit(baseUrl)
.get(".info__license__url")
.should("exist")
.should("contains.text", "Apache 2.0")
})
it("should render URL anchor target xss link with safe `rel` attributes", () => {
cy.visit(baseUrl)
.get(".info__license__url > a")
.should("have.attr", "rel")
.and("include", "noopener")
.and("include", "noreferrer")
.get(".info .main > a")
.should("have.attr", "target")
.and("equal", "_blank")
})
})
describe("OpenAPI 3.1.x", () => {
describe("given URL field", () => {
const baseUrl = "/?url=/documents/features/license-openAPI31-url.yaml"
it("should render URL", () => {
cy.visit(baseUrl)
.get(".info__license__url")
.should("exist")
.should("contains.text", "Apache 2.0")
.get(".info__license__url > a")
.should("have.attr", "href")
.and("equal", "https://www.apache.org/licenses/LICENSE-2.0.html")
})
it("should render URL anchor target xss link with safe `rel` attributes", () => {
cy.visit(baseUrl)
.get(".info__license__url > a")
.should("have.attr", "rel")
.and("include", "noopener")
.and("include", "noreferrer")
.get(".info .main > a")
.should("have.attr", "target")
.and("equal", "_blank")
})
})
describe("given identifier field", () => {
const baseUrl =
"/?url=/documents/features/license-openAPI31-identifier.yaml"
it("should render URL using identifier", () => {
cy.visit(baseUrl)
.get(".info__license__url")
.should("exist")
.should("contains.text", "Apache 2.0")
.get(".info__license__url > a")
.should("have.attr", "href")
.and("equal", "https://spdx.org/licenses/Apache-2.0.html")
})
it("should render URL anchor target xss links with safe `rel` attributes", () => {
cy.visit(baseUrl)
.get(".info__license__url > a")
.should("have.attr", "rel")
.and("include", "noopener")
.and("include", "noreferrer")
.get(".info .main > a")
.should("have.attr", "target")
.and("equal", "_blank")
})
})
describe("URL and SPX are mutually exclusive", () => {
it("should render nothing if both URL & SPDX exists", () => {
const baseUrl =
"/?url=/documents/features/license-openAPI31-error-both-identifier-and-url.yaml"
cy.visit(baseUrl)
.get(".info__license__identifier")
.should("not.exist")
.get(".info__license__url")
.should("not.exist")
})
})
})
})