From eb6c43405f87303b5e816630544f9f81b7bfa024 Mon Sep 17 00:00:00 2001 From: kyle Date: Fri, 7 Sep 2018 14:13:43 -0700 Subject: [PATCH] fix: resolved model data invalidation (via #4858) --- src/core/components/models.jsx | 2 +- .../static/documents/bugs/editor-1868.yaml | 13 ++++++++++ test/e2e-cypress/tests/bugs/editor-1868.js | 26 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/e2e-cypress/static/documents/bugs/editor-1868.yaml create mode 100644 test/e2e-cypress/tests/bugs/editor-1868.js diff --git a/src/core/components/models.jsx b/src/core/components/models.jsx index 86c82d7d..0818be1d 100644 --- a/src/core/components/models.jsx +++ b/src/core/components/models.jsx @@ -59,7 +59,7 @@ export default class Models extends Component { const rawSchema = specSelectors.specJson().getIn(fullPath, Im.Map()) const displayName = schema.get("title") || rawSchema.get("title") || name - if(layoutSelectors.isShown(["models", name], false) && schema === undefined) { + if(layoutSelectors.isShown(["models", name], false) && (schema.size === 0 && rawSchema.size > 0)) { // Firing an action in a container render is not great, // but it works for now. this.props.specActions.requestResolvedSubtree([...this.getSchemaBasePath(), name]) diff --git a/test/e2e-cypress/static/documents/bugs/editor-1868.yaml b/test/e2e-cypress/static/documents/bugs/editor-1868.yaml new file mode 100644 index 00000000..ef0d8f71 --- /dev/null +++ b/test/e2e-cypress/static/documents/bugs/editor-1868.yaml @@ -0,0 +1,13 @@ +swagger: "2.0" + +paths: + /: + get: + description: wow + +definitions: + MyModel: + type: object + properties: + a: + type: string \ No newline at end of file diff --git a/test/e2e-cypress/tests/bugs/editor-1868.js b/test/e2e-cypress/tests/bugs/editor-1868.js new file mode 100644 index 00000000..cf78e0e3 --- /dev/null +++ b/test/e2e-cypress/tests/bugs/editor-1868.js @@ -0,0 +1,26 @@ +import repeat from "lodash/repeat" + +describe("Editor #1868: model changes break rendering", () => { + it("should render model content changes correctly", () => { + cy + .visit("/?url=/documents/bugs/editor-1868.yaml") + + .get(".model-toggle.collapsed") + .click() + + .get("#model-MyModel") + .contains("a") + + .window() + .then(win => { + // Simulate Swagger Editor updating a model + const content = win.ui.specSelectors.specStr() + win.ui.specActions.updateSpec(content + `\n b:\n type: string`) + }) + + .get("#model-MyModel") + .contains("a") + .get("#model-MyModel") + .contains("b") + }) +}) \ No newline at end of file -- GitLab