fix: deep link fragment escaping (via #4832)
* `test/e2e` -> `test/e2e-selenium` * add Cypress * ESLint fixes * MOAR cypress * `integration` -> `tests` * wire Cypress up to a hot e2e server * add failing tests for #4537 * add petstore for future use * don't tack `operations/` onto href path * escape generated URL fragments * Update package.json
This commit is contained in:
@@ -1,44 +1,148 @@
|
||||
describe("Deep linking feature", () => {
|
||||
describe("in Swagger 2", () => {
|
||||
const baseUrl = "/?deepLinking=true&url=/documents/features/deep-linking.swagger.yaml"
|
||||
beforeEach(() => {
|
||||
cy.visit("/?deepLinking=true&url=/documents/features/deep-linking.swagger.yaml")
|
||||
cy.visit(baseUrl)
|
||||
})
|
||||
it("should generate an element ID and URL fragment for an operation", () => {
|
||||
cy.get(".opblock-get")
|
||||
.should("exist")
|
||||
.should("have.id", "operations-myTag-myOperation")
|
||||
.click()
|
||||
.window()
|
||||
.should("have.deep.property", "location.hash", "#/myTag/myOperation")
|
||||
describe("regular Operation", () => {
|
||||
const elementToGet = ".opblock-get"
|
||||
const correctElementId = "operations-myTag-myOperation"
|
||||
const correctFragment = "#/myTag/myOperation"
|
||||
|
||||
it("should generate a correct element ID", () => {
|
||||
cy.get(elementToGet)
|
||||
.should("have.id", correctElementId)
|
||||
})
|
||||
|
||||
it("should add the correct element fragment to the URL when expanded", () => {
|
||||
cy.get(elementToGet)
|
||||
.click()
|
||||
.window()
|
||||
.should("have.deep.property", "location.hash", correctFragment)
|
||||
})
|
||||
|
||||
it("should provide an anchor link that has the correct fragment as href", () => {
|
||||
cy.get(elementToGet)
|
||||
.find("a")
|
||||
.should("have.attr", "href", correctFragment)
|
||||
.click()
|
||||
.window()
|
||||
.should("have.deep.property", "location.hash", correctFragment)
|
||||
})
|
||||
|
||||
it("should expand the operation when reloaded", () => {
|
||||
cy.visit(`${baseUrl}${correctFragment}`)
|
||||
.reload()
|
||||
.get(`${elementToGet}.is-open`)
|
||||
.should("exist")
|
||||
})
|
||||
})
|
||||
it("should generate an element ID and URL fragment for an operation with spaces", () => {
|
||||
cy.get(".opblock-post")
|
||||
.should("exist")
|
||||
.should("have.id", "operations-my_Tag-my_Operation")
|
||||
.click()
|
||||
.window()
|
||||
.should("have.deep.property", "location.hash", "#/my%20Tag/my%20Operation")
|
||||
|
||||
describe("Operation with whitespace in tag+id", () => {
|
||||
const elementToGet = ".opblock-post"
|
||||
const correctElementId = "operations-my_Tag-my_Operation"
|
||||
const correctFragment = "#/my_Tag/my_Operation"
|
||||
|
||||
it("should generate a correct element ID", () => {
|
||||
cy.get(elementToGet)
|
||||
.should("have.id", correctElementId)
|
||||
})
|
||||
|
||||
it("should add the correct element fragment to the URL when expanded", () => {
|
||||
cy.get(elementToGet)
|
||||
.click()
|
||||
.window()
|
||||
.should("have.deep.property", "location.hash", correctFragment)
|
||||
})
|
||||
|
||||
it("should provide an anchor link that has the correct fragment as href", () => {
|
||||
cy.get(elementToGet)
|
||||
.find("a")
|
||||
.should("have.attr", "href", correctFragment)
|
||||
.click()
|
||||
.should("have.attr", "href", correctFragment) // should be valid after expanding
|
||||
|
||||
})
|
||||
|
||||
it("should expand the operation when reloaded", () => {
|
||||
cy.visit(`${baseUrl}${correctFragment}`)
|
||||
.reload()
|
||||
.get(`${elementToGet}.is-open`)
|
||||
.should("exist")
|
||||
})
|
||||
})
|
||||
})
|
||||
describe("in OpenAPI 3", () => {
|
||||
const baseUrl = "/?deepLinking=true&url=/documents/features/deep-linking.swagger.yaml"
|
||||
beforeEach(() => {
|
||||
cy.visit("/?deepLinking=true&url=/documents/features/deep-linking.openapi.yaml")
|
||||
cy.visit(baseUrl)
|
||||
})
|
||||
it("should generate an element ID and URL fragment for an operation", () => {
|
||||
cy.get(".opblock-get")
|
||||
.should("exist")
|
||||
.should("have.id", "operations-myTag-myOperation")
|
||||
.click()
|
||||
.window()
|
||||
.should("have.deep.property", "location.hash", "#/myTag/myOperation")
|
||||
describe("regular Operation", () => {
|
||||
const elementToGet = ".opblock-get"
|
||||
const correctElementId = "operations-myTag-myOperation"
|
||||
const correctFragment = "#/myTag/myOperation"
|
||||
|
||||
it("should generate a correct element ID", () => {
|
||||
cy.get(elementToGet)
|
||||
.should("have.id", correctElementId)
|
||||
})
|
||||
|
||||
it("should add the correct element fragment to the URL when expanded", () => {
|
||||
cy.get(elementToGet)
|
||||
.click()
|
||||
.window()
|
||||
.should("have.deep.property", "location.hash", correctFragment)
|
||||
})
|
||||
|
||||
it("should provide an anchor link that has the correct fragment as href", () => {
|
||||
cy.get(elementToGet)
|
||||
.find("a")
|
||||
.should("have.attr", "href", correctFragment)
|
||||
.click()
|
||||
.window()
|
||||
.should("have.deep.property", "location.hash", correctFragment)
|
||||
})
|
||||
|
||||
it("should expand the operation when reloaded", () => {
|
||||
cy.visit(`${baseUrl}${correctFragment}`)
|
||||
.reload()
|
||||
.get(`${elementToGet}.is-open`)
|
||||
.should("exist")
|
||||
})
|
||||
})
|
||||
it("should generate an element ID and URL fragment for an operation with spaces", () => {
|
||||
cy.get(".opblock-post")
|
||||
.should("exist")
|
||||
.should("have.id", "operations-my_Tag-my_Operation")
|
||||
.click()
|
||||
.window()
|
||||
.should("have.deep.property", "location.hash", "#/my%20Tag/my%20Operation")
|
||||
|
||||
describe("Operation with whitespace in tag+id", () => {
|
||||
const elementToGet = ".opblock-post"
|
||||
const correctElementId = "operations-my_Tag-my_Operation"
|
||||
const correctFragment = "#/my_Tag/my_Operation"
|
||||
|
||||
it("should generate a correct element ID", () => {
|
||||
cy.get(elementToGet)
|
||||
.should("have.id", correctElementId)
|
||||
})
|
||||
|
||||
it("should add the correct element fragment to the URL when expanded", () => {
|
||||
cy.get(elementToGet)
|
||||
.click()
|
||||
.window()
|
||||
.should("have.deep.property", "location.hash", correctFragment)
|
||||
})
|
||||
|
||||
it("should provide an anchor link that has the correct fragment as href", () => {
|
||||
cy.get(elementToGet)
|
||||
.find("a")
|
||||
.should("have.attr", "href", correctFragment)
|
||||
.click()
|
||||
.should("have.attr", "href", correctFragment) // should be valid after expanding
|
||||
|
||||
})
|
||||
|
||||
it("should expand the operation when reloaded", () => {
|
||||
cy.visit(`${baseUrl}${correctFragment}`)
|
||||
.reload()
|
||||
.get(`${elementToGet}.is-open`)
|
||||
.should("exist")
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user