From b4f18863069be2bac81ca2f95de719ed02d3337f Mon Sep 17 00:00:00 2001 From: kyle Date: Thu, 23 Aug 2018 15:18:13 -0700 Subject: [PATCH] meta: supplemental tests for #4537 (via #4828) * `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 * Update package.json --- .../features/deep-linking.openapi.yaml | 27 +++++++++++ .../features/deep-linking.swagger.yaml | 20 ++++++++- test/e2e-cypress/tests/deep-linking.js | 45 +++++++++++++++++-- 3 files changed, 88 insertions(+), 4 deletions(-) diff --git a/test/e2e-cypress/static/documents/features/deep-linking.openapi.yaml b/test/e2e-cypress/static/documents/features/deep-linking.openapi.yaml index e69de29b..b423ece3 100644 --- a/test/e2e-cypress/static/documents/features/deep-linking.openapi.yaml +++ b/test/e2e-cypress/static/documents/features/deep-linking.openapi.yaml @@ -0,0 +1,27 @@ +openapi: "3.0.0" + +paths: + /: + get: + operationId: "myOperation" + tags: ["myTag"] + summary: an operation + responses: + '200': + description: a pet to be returned + content: + application/json: + schema: + type: object + /withSpaces: + post: + operationId: "my Operation" + tags: ["my Tag"] + summary: an operation + responses: + '200': + description: a pet to be returned + content: + application/json: + schema: + type: object \ No newline at end of file diff --git a/test/e2e-cypress/static/documents/features/deep-linking.swagger.yaml b/test/e2e-cypress/static/documents/features/deep-linking.swagger.yaml index 5b308b04..3eb90bf0 100644 --- a/test/e2e-cypress/static/documents/features/deep-linking.swagger.yaml +++ b/test/e2e-cypress/static/documents/features/deep-linking.swagger.yaml @@ -1 +1,19 @@ -swagger: "2.0" \ No newline at end of file +swagger: "2.0" + +paths: + /: + get: + operationId: "myOperation" + tags: ["myTag"] + summary: an operation + responses: + "200": + description: ok + /withSpaces: + post: + operationId: "my Operation" + tags: ["my Tag"] + summary: an operation + responses: + "200": + description: ok diff --git a/test/e2e-cypress/tests/deep-linking.js b/test/e2e-cypress/tests/deep-linking.js index 5ff1cdac..1aeebe2c 100644 --- a/test/e2e-cypress/tests/deep-linking.js +++ b/test/e2e-cypress/tests/deep-linking.js @@ -1,5 +1,44 @@ -describe("The Home Page", function () { - it("successfully loads", function () { - cy.visit("/") +describe("Deep linking feature", () => { + describe("in Swagger 2", () => { + beforeEach(() => { + cy.visit("/?deepLinking=true&url=/documents/features/deep-linking.swagger.yaml") + }) + 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") + }) + 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("in OpenAPI 3", () => { + beforeEach(() => { + cy.visit("/?deepLinking=true&url=/documents/features/deep-linking.openapi.yaml") + }) + 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") + }) + 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") + }) }) }) \ No newline at end of file