Skip to content

Commit

Permalink
test(examples): added cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mgordel committed Sep 26, 2023
1 parent 6aa1e91 commit 0ec83c7
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cypress-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
python -m goth create-assets ../goth/assets
sed -Ezi 's/(use\-proxy:\s)(True)/\1False/mg' ../goth/assets/goth-config.yml
sed -Ezi 's/(use\-prerelease:\s)(false)/\1true\n release-tag: "0.13.0-rc10"/mg' ../goth/assets/goth-config.yml
sed -i '/^ENTRYPOINT/i ENV YAGNA_AUTOCONF_APPKEY=try_golem' ../goth/assets/docker/yagna-goth-deb.Dockerfile
- name: Disconnect Docker containers from default network
continue-on-error: true
Expand Down
14 changes: 14 additions & 0 deletions examples/web/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ const server = http.createServer((req, res) => {
} else if (req.url === "/image") {
res.writeHead(200, { "content-type": "text/html" });
fs.createReadStream(`${__dirname}/image.html`).pipe(res);
} else if (req.url === "/docs-example-transfer-data") {
res.writeHead(200, { "content-type": "text/html" });
fs.createReadStream(`${__dirname}/../docs-examples/examples/transferring-data/transferDatainBrowser.html`).pipe(
res,
);
} else if (req.url === "/docs-example-transfer-json") {
res.writeHead(200, { "content-type": "text/html" });
fs.createReadStream(`${__dirname}/../docs-examples/examples/transferring-data/uploadHSONinBrowser.html`).pipe(res);
} else if (req.url === "/docs-tutorial") {
res.writeHead(200, { "content-type": "text/html" });
fs.createReadStream(`${__dirname}/../docs-examples/tutorials/running-from-browser/index.html`).pipe(res);
} else if (req.url === "/docs-quickstart") {
res.writeHead(200, { "content-type": "text/html" });
fs.createReadStream(`${__dirname}/../docs-examples/quickstarts/web-quickstart/index.html`).pipe(res);
} else if (req.url === "/golem-js.min.js") {
res.writeHead(200, { "content-type": "text/javascript" });
fs.createReadStream(`${__dirname}/../../dist/golem-js.min.js`).pipe(res);
Expand Down
11 changes: 11 additions & 0 deletions tests/cypress/ui/docs-example-transfer-data.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe("Docs Examples Transfer Data", () => {
it("should transfer image file to provider", () => {
cy.visit("/docs-example-transfer-data");
cy.fixture("golem.png", { encoding: null }).as("imageFile");
cy.get("#MEME_IMG").selectFile("@imageFile");
cy.get("#RUN").click();
cy.get("#RESULT_MEME").should("have.attr", "src").and("contain", "blob:http://localhost:3000", { timeout: 60000 });
cy.get("#logs").contains("computed by provider");
cy.get("#logs").contains("Task Executor has shut down");
});
});
9 changes: 9 additions & 0 deletions tests/cypress/ui/docs-example-transfer-json.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe("Docs Examples Transfer JSON", () => {
it("should transfer json to provider", () => {
cy.visit("/docs-example-transfer-json");
cy.get("#echo").click();
cy.get("#results").should("include.text", "TODO", { timeout: 60000 });
cy.get("#logs").contains("computed by provider");
cy.get("#logs").contains("Task Executor has shut down");
});
});
8 changes: 8 additions & 0 deletions tests/cypress/ui/docs-quickstart.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe("Docs Examples Quickstart", () => {
it("should print hello world", () => {
cy.visit("/docs-example-quickstart");
cy.get("#echo").click();
cy.get("#results").should("include.text", "Hello World", { timeout: 60000 });
cy.get("#logs").contains("Task Executor has shut down");
});
});
8 changes: 8 additions & 0 deletions tests/cypress/ui/docs-tutorial.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe("Docs Examples Tutorial", () => {
it("should print hello world", () => {
cy.visit("/docs-example-tutorial");
cy.get("#echo").click();
cy.get("#results").should("include.text", "Hello World", { timeout: 60000 });
cy.get("#logs").contains("Task Executor has shut down");
});
});
File renamed without changes.

0 comments on commit 0ec83c7

Please sign in to comment.