Skip to content

Commit

Permalink
fix(codeviewer): make CM view read-only (#390)
Browse files Browse the repository at this point in the history
* fix(codeviewer): make CM view read-only

* test: content editable
  • Loading branch information
danilowoz authored Feb 23, 2022
1 parent ef2f7b0 commit 56ac9f2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
10 changes: 6 additions & 4 deletions cypress/integration/CodeViewer.spec.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import "cypress-real-events/support";

describe("CodeViewer", () => {
it("should not be editable", () => {
cy.viewport(600, 1000).visit(
`/iframe.html?id=components-code-viewer--component`
);

cy.get(".cm-content").type("{selectall}").type("{backspace}");

cy.get(".cm-content").snapshot();
cy.get(".cm-content").should("have.attr", "contenteditable", "false");
});

it("should not be able to cut the content", () => {
cy.viewport(600, 1000).visit(
`/iframe.html?id=components-code-viewer--component`
);

cy.get(".cm-content").type("{selectall}").type("{meta}x");
// Force select and Command+X: it should fail for non-ready-only component
cy.get(".cm-content").trigger("mousedown").realPress(["Meta", "x"]);

// content should still be there
cy.get(".cm-content").snapshot();
});
});
Loading

0 comments on commit 56ac9f2

Please sign in to comment.