bug(deeplinking): escaping breaks whitespaces & underscored tags/ids (via #4953)
* add tests for operation lacking an operationId * add deep linking tests for tags/operationIds with underscores * migrate from `_` to `%20` for deeplink hash whitespace escaping * add backwards compatibility for `_` whitespace escaping * update util unit tests
This commit is contained in:
@@ -18,6 +18,29 @@ paths:
|
||||
operationId: "my Operation"
|
||||
tags: ["my Tag"]
|
||||
summary: an operation
|
||||
responses:
|
||||
'200':
|
||||
description: a pet to be returned
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
/withUnderscores:
|
||||
patch:
|
||||
operationId: "underscore_Operation"
|
||||
tags: ["underscore_Tag"]
|
||||
summary: an operation
|
||||
responses:
|
||||
'200':
|
||||
description: a pet to be returned
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
/noOperationId:
|
||||
put:
|
||||
tags: ["tagTwo"]
|
||||
summary: some operations are anonymous...
|
||||
responses:
|
||||
'200':
|
||||
description: a pet to be returned
|
||||
|
||||
@@ -17,3 +17,18 @@ paths:
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
/withUnderscores:
|
||||
patch:
|
||||
operationId: "underscore_Operation"
|
||||
tags: ["underscore_Tag"]
|
||||
summary: an operation
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
/noOperationId:
|
||||
put:
|
||||
tags: ["tagTwo"]
|
||||
summary: an operation
|
||||
responses:
|
||||
"200":
|
||||
description: ok
|
||||
|
||||
@@ -41,7 +41,83 @@ describe("Deep linking feature", () => {
|
||||
describe("Operation with whitespace in tag+id", () => {
|
||||
const elementToGet = ".opblock-post"
|
||||
const correctElementId = "operations-my_Tag-my_Operation"
|
||||
const correctFragment = "#/my_Tag/my_Operation"
|
||||
const correctFragment = "#/my%20Tag/my%20Operation"
|
||||
const legacyFragment = "#/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")
|
||||
})
|
||||
|
||||
it("should expand the operation when reloaded and provided the legacy fragment", () => {
|
||||
cy.visit(`${baseUrl}${legacyFragment}`)
|
||||
.reload()
|
||||
.get(`${elementToGet}.is-open`)
|
||||
.should("exist")
|
||||
})
|
||||
})
|
||||
|
||||
describe("Operation with underscores in tag+id", () => {
|
||||
const elementToGet = ".opblock-patch"
|
||||
const correctElementId = "operations-underscore_Tag-underscore_Operation"
|
||||
const correctFragment = "#/underscore_Tag/underscore_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("Operation with no operationId", () => {
|
||||
const elementToGet = ".opblock-put"
|
||||
const correctElementId = "operations-tagTwo-put_noOperationId"
|
||||
const correctFragment = "#/tagTwo/put_noOperationId"
|
||||
|
||||
it("should generate a correct element ID", () => {
|
||||
cy.get(elementToGet)
|
||||
@@ -127,7 +203,83 @@ describe("Deep linking feature", () => {
|
||||
describe("Operation with whitespace in tag+id", () => {
|
||||
const elementToGet = ".opblock-post"
|
||||
const correctElementId = "operations-my_Tag-my_Operation"
|
||||
const correctFragment = "#/my_Tag/my_Operation"
|
||||
const correctFragment = "#/my%20Tag/my%20Operation"
|
||||
const legacyFragment = "#/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")
|
||||
})
|
||||
|
||||
it("should expand the operation when reloaded and provided the legacy fragment", () => {
|
||||
cy.visit(`${baseUrl}${legacyFragment}`)
|
||||
.reload()
|
||||
.get(`${elementToGet}.is-open`)
|
||||
.should("exist")
|
||||
})
|
||||
})
|
||||
|
||||
describe("Operation with underscores in tag+id", () => {
|
||||
const elementToGet = ".opblock-patch"
|
||||
const correctElementId = "operations-underscore_Tag-underscore_Operation"
|
||||
const correctFragment = "#/underscore_Tag/underscore_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("Operation with no operationId", () => {
|
||||
const elementToGet = ".opblock-put"
|
||||
const correctElementId = "operations-tagTwo-put_noOperationId"
|
||||
const correctFragment = "#/tagTwo/put_noOperationId"
|
||||
|
||||
it("should generate a correct element ID", () => {
|
||||
cy.get(elementToGet)
|
||||
|
||||
Reference in New Issue
Block a user