Skip to content

Commit

Permalink
Merge branch 'main' into issues/716-Replace_margin_physical_propertie…
Browse files Browse the repository at this point in the history
…s_with_logical
  • Loading branch information
magdalenajadach committed Nov 8, 2023
2 parents 78ed6a4 + 44943db commit ebfc060
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 107 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## Unreleased

## [0.19.4] - 2023-11-08

### Changed

- Allow external rpf.io links (#729)

## [0.19.3] - 2023-10-25

### Added
Expand Down Expand Up @@ -551,7 +557,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Events in Web Component indicating whether Mission Zero criteria have been met (#113)

[unreleased]: https://github.com/RaspberryPiFoundation/editor-ui/compare/v0.19.3...HEAD
[unreleased]: https://github.com/RaspberryPiFoundation/editor-ui/compare/v0.19.4...HEAD
[0.19.4]: https://github.com/RaspberryPiFoundation/editor-ui/releases/tag/v0.19.4
[0.19.3]: https://github.com/RaspberryPiFoundation/editor-ui/releases/tag/v0.19.3
[0.19.2]: https://github.com/RaspberryPiFoundation/editor-ui/releases/tag/v0.19.2
[0.19.1]: https://github.com/RaspberryPiFoundation/editor-ui/releases/tag/v0.19.1
Expand Down
18 changes: 16 additions & 2 deletions cypress/e2e/spec-html.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const baseUrl = "localhost:3000/en/projects/blank-html-starter";
const baseUrl = "http://localhost:3000/en/projects/blank-html-starter";

const getIframeDocument = () => {
return cy
Expand Down Expand Up @@ -43,7 +43,7 @@ it("updates the preview after a change when you click run", () => {
getIframeBody().find("p").should("include.text", "hello world");
});

it("blocks external links", () => {
it("blocks non-permitted external links", () => {
localStorage.clear();
cy.visit(baseUrl);
cy.get("div[class=cm-content]").invoke(
Expand All @@ -57,6 +57,20 @@ it("blocks external links", () => {
.should("include.text", "An error has occurred");
});

it("allows permitted external links", () => {
localStorage.clear();
cy.visit(baseUrl);
cy.get("div[class=cm-content]").invoke(
"text",
'<a href="https://rpf.io/seefood">some external link</a>',
);
cy.get(".btn--run").click();
const externalLink = getIframeBody().find("a");
externalLink.click();
cy.url().should("be.equals", baseUrl);
cy.get("div[class=modal-content__header]").should("not.exist");
});

it("allows internal links", () => {
localStorage.clear();
cy.visit(baseUrl);
Expand Down
89 changes: 56 additions & 33 deletions cypress/e2e/spec-wc.cy.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,73 @@
const baseUrl = "http://localhost:3001"
const baseUrl = "http://localhost:3001";

beforeEach(() => {
cy.visit(baseUrl)
})
cy.visit(baseUrl);
});

it("renders the web component", () => {
cy.get("editor-wc").shadow().find("button").should("contain", "Run")
})
cy.get("editor-wc").shadow().find("button").should("contain", "Run");
});

it("defaults to the text output tab", () => {
const runnerContainer = cy.get("editor-wc").shadow().find('.proj-runner-container')
runnerContainer.find('.react-tabs__tab--selected').should("contain", "Text output")
})
const runnerContainer = cy
.get("editor-wc")
.shadow()
.find(".proj-runner-container");
runnerContainer
.find(".react-tabs__tab--selected")
.should("contain", "Text output");
});

it("runs the python code", () => {
cy.get("editor-wc").shadow().find("div[class=cm-content]").invoke('text', 'print("Hello world")')
cy.get("editor-wc").shadow().find(".btn--run").click()
cy.get("editor-wc").shadow().find(".pythonrunner-console-output-line").should("contain", "Hello world")
})
cy.get("editor-wc")
.shadow()
.find("div[class=cm-content]")
.invoke("text", 'print("Hello world")');
cy.get("editor-wc").shadow().find(".btn--run").click();
cy.get("editor-wc")
.shadow()
.find(".pythonrunner-console-output-line")
.should("contain", "Hello world");
});

it("does not render visual output tab on page load", () => {
cy.get("editor-wc").shadow().find('#root').should("not.contain", "Visual output")
})
cy.get("editor-wc")
.shadow()
.find("#root")
.should("not.contain", "Visual output");
});

it("renders visual output tab if sense hat imported", () => {
cy.get("editor-wc").shadow().find("div[class=cm-content]").invoke('text', 'import sense_hat')
cy.get("editor-wc").shadow().find(".btn--run").click()
cy.get("editor-wc").shadow().find('#root').should("contain", "Visual output")
})
cy.get("editor-wc")
.shadow()
.find("div[class=cm-content]")
.invoke("text", "import sense_hat");
cy.get("editor-wc").shadow().find(".btn--run").click();
cy.get("editor-wc").shadow().find("#root").should("contain", "Visual output");
});

it("does not render astro pi component on page load",() => {
cy.get("editor-wc").shadow().find("#root").should("not.contain", "yaw")
})
it("does not render astro pi component on page load", () => {
cy.get("editor-wc").shadow().find("#root").should("not.contain", "yaw");
});

it("renders astro pi component if sense hat imported", () => {
cy.get("editor-wc").shadow().find("div[class=cm-content]").invoke('text', 'import sense_hat')
cy.get("editor-wc").shadow().find(".btn--run").click()
cy.get("editor-wc").shadow().contains('Visual output').click()
cy.get("editor-wc").shadow().find("#root").should("contain", "yaw")
})
cy.get("editor-wc")
.shadow()
.find("div[class=cm-content]")
.invoke("text", "import sense_hat");
cy.get("editor-wc").shadow().find(".btn--run").click();
cy.get("editor-wc").shadow().contains("Visual output").click();
cy.get("editor-wc").shadow().find("#root").should("contain", "yaw");
});

it("does not render astro pi component if sense hat unimported", () => {
cy.get("editor-wc").shadow().find("div[class=cm-content]").invoke('text', 'import sense_hat')
cy.get("editor-wc").shadow().find(".btn--run").click()
cy.get("editor-wc").shadow().find("div[class=cm-content]").invoke('text', '')
cy.get("editor-wc").shadow().find(".btn--run").click()
cy.get("editor-wc").shadow().contains('Visual output').click()
cy.get("editor-wc").shadow().find("#root").should("not.contain", "yaw")
})
cy.get("editor-wc")
.shadow()
.find("div[class=cm-content]")
.invoke("text", "import sense_hat");
cy.get("editor-wc").shadow().find(".btn--run").click();
cy.get("editor-wc").shadow().find("div[class=cm-content]").invoke("text", "");
cy.get("editor-wc").shadow().find(".btn--run").click();
cy.get("editor-wc").shadow().contains("Visual output").click();
cy.get("editor-wc").shadow().find("#root").should("not.contain", "yaw");
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@raspberrypifoundation/editor-ui",
"version": "0.19.3",
"version": "0.19.4",
"private": true,
"dependencies": {
"@RaspberryPiFoundation/design-system-react": "^0.1.2",
Expand Down
Loading

0 comments on commit ebfc060

Please sign in to comment.