Files
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

115 lines
3.6 KiB
JavaScript
Executable File

describe("configuration options: `urls` and `urls.primaryName`", () => {
describe("`urls` only", () => {
it("should render a list of URLs correctly", () => {
cy.visit("/?configUrl=/configs/urls.yaml")
.get("select")
.children()
.should("have.length", 2)
.get("select > option")
.eq(0)
.should("have.text", "One")
.should("have.attr", "value", )
.and("match", /\/documents\/features\/urls\/1\.yaml$/)
.get("select > option")
.eq(1)
.should("have.text", "Two")
.should("have.attr", "value")
.and("match", /\/documents\/features\/urls\/2\.yaml$/)
})
it("should render the first URL in the list", () => {
cy.visit("/?configUrl=/configs/urls.yaml")
.get("h2.title")
.should("have.text", "OneOAS 2.0")
.window()
.then(win => win.ui.specSelectors.url())
.should("match", /\/documents\/features\/urls\/1\.yaml$/)
})
})
it("should respect a `urls.primaryName`", () => {
cy.visit("/?configUrl=/configs/urls-primary-name.yaml")
.get("select")
.should("contain.value", "/documents/features/urls/2.yaml")
.get("h2.title")
.should("have.text", "TwoOAS 3.0")
.window()
.then(win => win.ui.specSelectors.url())
.get("select")
.should("contain.value", "/documents/features/urls/2.yaml")
})
})
describe("urls with server variables", () => {
it("should compute a url and default server variables", () => {
cy.visit("/?configUrl=/configs/urls-server-variables.yaml")
.get("code")
.should("have.text", "https://localhost:3200/oneFirstUrl")
.get("tr > :nth-child(1)")
.should("have.text", "basePath")
.get("input")
.should("have.value", "/oneFirstUrl")
})
it("should change server variables", () => {
cy.visit("/?configUrl=/configs/urls-server-variables.yaml")
.get("code")
.should("have.text", "https://localhost:3200/oneFirstUrl")
.get("tr > :nth-child(1)")
.should("have.text", "basePath")
.get("input")
.should("have.value", "/oneFirstUrl")
.get(".servers > label > select")
.eq(0)
.select(1)
.get("input")
.should("have.value", "/oneSecondUrl")
})
it("should select and compute second url", () => {
cy.visit("/?configUrl=/configs/urls-server-variables.yaml")
.get("select > option")
.eq(1)
.should("have.text", "Two")
.get("select")
.eq(0)
.select(1)
.get("code")
.should("have.text", "https://localhost:3200/twoFirstUrl")
.get("input")
.should("have.value", "/twoFirstUrl")
})
it("should select second url, then toggle back to first url", () => {
cy.visit("/?configUrl=/configs/urls-server-variables.yaml")
.get("select > option")
.get("select")
.eq(0)
.select(1)
.get("input")
.should("have.value", "/twoFirstUrl")
// toggle url back
.get("select")
.eq(0)
.select(0)
.get("code")
.should("have.text", "https://localhost:3200/oneFirstUrl")
.get("input")
.should("have.value", "/oneFirstUrl")
})
it("should change server variables, then select second url, and maintain server variables index", () => {
cy.visit("/?configUrl=/configs/urls-server-variables.yaml")
.get(".servers > label >select")
.eq(0)
.select(1)
.get("input")
.should("have.value", "/oneSecondUrl")
// change url
.get("select > option")
.get("select")
.eq(0)
.select(1)
.get("input")
.should("have.value", "/twoSecondUrl")
.get("input")
.should("have.value", "/twoSecondUrl")
})
})