From 7d8c137695cf243f4194bbb664fe3c5bf407c5fb Mon Sep 17 00:00:00 2001 From: SergioSim Date: Tue, 8 Nov 2022 14:25:53 +0100 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=99=88(gitignore)=20add=20edx/modules?= =?UTF-8?q?=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When bootstraping this project in the dev branch two additional directories are created: edx/src and edx/modules. To ease switching between a feature branch and the dev branch we choose to ignore the edx/modules directory. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 6651719..8004954 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ data/ # Sources src/ +# EdX modules +edx/modules/ + # End-to-end testing e2e/cypress/screenshots e2e/cypress/videos From be63116d820954947478fff5a68ce6f0409ff603 Mon Sep 17 00:00:00 2001 From: SergioSim Date: Tue, 8 Nov 2022 14:44:25 +0100 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=9A=A8(linter)=20ignore=20edx=20direc?= =?UTF-8?q?tory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When bootstraping this project in the dev branch two additional directories are created: edx/src and edx/modules. To ease switching between a feature branch and the dev branch we choose to make the linter ignore the edx directory. --- .eslintignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.eslintignore b/.eslintignore index bc18641..0fcf0a0 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,3 +3,6 @@ node_modules e2e/cypress/screenshots e2e/cypress/videos + +# Don't lint edX sources +edx/ From 18a536b43feafd6acef5aa56086e0cc53bf39880 Mon Sep 17 00:00:00 2001 From: SergioSim Date: Tue, 8 Nov 2022 14:49:00 +0100 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=91=B7(circle)=20update=20machine=20i?= =?UTF-8?q?mage=20to=20version=202022.10.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To keep the circleci machine up to date. --- .circleci/config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1ef2738..54554c0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -78,7 +78,8 @@ jobs: test-e2e: machine: - image: ubuntu-2004:202201-02 + image: ubuntu-2004:2022.10.1 + docker_layer_caching: true working_directory: ~/fun steps: - checkout @@ -87,10 +88,10 @@ jobs: command: docker network create potsie - run: name: Bootstrap project - command: make bootstrap + command: make bootstrap run-edx - run: name: Run e2e tests - command: make run-edx test + command: make test lint-test: docker: From c9b0a3873809f1dae3602e37e93d236d41c0d15b Mon Sep 17 00:00:00 2001 From: SergioSim Date: Thu, 3 Nov 2022 09:19:59 +0100 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=90=9B(tests)=20wait=20for=20iframe?= =?UTF-8?q?=20to=20become=20interactive=20in=20js=5Finput=5Fresponse=20tes?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The iframe in the js_input_response test needs some time to become interactive. Therefore we disable chromeWebSecurity to give cypress access to the cross-domain iframe to check whether the iframe is ready or not. --- .../js_input_response_spec.js | 35 ++++++++++++++++++- env.d/cypress | 1 + 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/e2e/cypress/integration/lms_problem_interaction/js_input_response_spec.js b/e2e/cypress/integration/lms_problem_interaction/js_input_response_spec.js index 6d274d6..7d946d0 100644 --- a/e2e/cypress/integration/lms_problem_interaction/js_input_response_spec.js +++ b/e2e/cypress/integration/lms_problem_interaction/js_input_response_spec.js @@ -7,20 +7,53 @@ describe("LMS JS Input Response Problem Interaction Test", () => { const problem = getProblem(section, "jsinputResponse"); const problemId = getXblockId(problem); + const getIframeWindow = () => { + return cy + .get(`#iframe_${problemId}_2_1`) + .its("0.contentWindow") + .should("exist"); + }; + before(() => { cy.lmsLoginStudent(); cy.lmsEnroll(true); + // Reset Problem + const { courseId } = Cypress.env("EDX_COURSES").demoCourse1; + const handlerURL = "handler/xmodule_handler/problem_reset"; + const url = `/courses/${courseId}/xblock/${problem.locator}/${handlerURL}`; + const method = "POST"; + const body = { id: problem.locator }; + cy.request({ url, method, body }).then((response) => { + expect(response.status).to.equal(200); + }); // Navigate to the courseware. cy.visit(sectionUrl); + // Wait for iframe to become interactive. + getIframeWindow().and((win) => { + expect(win.WebGLDemo).to.be.an("object"); + }); // Input wrong answers. cy.get(`#iframe_${problemId}_2_1`).click(118, 200); + // Wait for iframe state to be updated. + getIframeWindow().and((win) => { + expect(win.WebGLDemo).to.be.an("object"); + expect(JSON.parse(win.WebGLDemo.getState())).deep.to.equal({ + selectedObjects: { cylinder: false, cube: true }, + }); + }); // Submit answer. cy.get(".check.Valider").click(); cy.get(".check.Valider").should("not.have.class", "is-disabled"); cy.get(`#status_${problemId}_2_1`).should("contain", "incorrect"); // Input correct answers. cy.get(`#iframe_${problemId}_2_1`).click(300, 200); - cy.wait(200); + // Wait for iframe state to be updated. + getIframeWindow().and((win) => { + expect(win.WebGLDemo).to.be.an("object"); + expect(JSON.parse(win.WebGLDemo.getState())).to.deep.equal({ + selectedObjects: { cylinder: false, cube: false }, + }); + }); // Submit answer. cy.get(".check.Valider").click(); cy.get(".check.Valider").should("not.have.class", "is-disabled"); diff --git a/env.d/cypress b/env.d/cypress index 3942a93..8fa5391 100644 --- a/env.d/cypress +++ b/env.d/cypress @@ -1,5 +1,6 @@ CYPRESS_BASE_URL=http://edx_lms:8000 CYPRESS_RETRIES=9 +CYPRESS_CHROME_WEB_SECURITY=false CYPRESS_EDX_ADMIN_EMAIL=admin@example.com CYPRESS_EDX_ADMIN_PASSWORD=admin From 152a6e99bde85dacd729ef0f095207d3bb67afaf Mon Sep 17 00:00:00 2001 From: SergioSim Date: Thu, 3 Nov 2022 09:23:57 +0100 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=90=9B(tests)=20reset=20drag=5Fand=5F?= =?UTF-8?q?drop=20test=20before=20interaction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The drag_and_drop test relies on the problem beeing at it's initial state. However, edX preserves the state of the problem once it's submitted. Therefore we reset the drag_and_drop problem before answering it. --- .../lms_problem_interaction/drag_and_drop_spec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e/cypress/integration/lms_problem_interaction/drag_and_drop_spec.js b/e2e/cypress/integration/lms_problem_interaction/drag_and_drop_spec.js index e7fd67b..4f06df6 100644 --- a/e2e/cypress/integration/lms_problem_interaction/drag_and_drop_spec.js +++ b/e2e/cypress/integration/lms_problem_interaction/drag_and_drop_spec.js @@ -23,6 +23,15 @@ describe("LMS Drag And Drop Problem Interaction Test", () => { before(() => { cy.lmsLoginStudent(); cy.lmsEnroll(true); + // Reset Problem + const { courseId } = Cypress.env("EDX_COURSES").demoCourse1; + const handlerURL = "handler/xmodule_handler/problem_reset"; + const url = `/courses/${courseId}/xblock/${problem.locator}/${handlerURL}`; + const method = "POST"; + const body = { id: problem.locator }; + cy.request({ url, method, body }).then((response) => { + expect(response.status).to.equal(200); + }); // Navigate to the courseware. cy.visit(sectionUrl); // Input answers (first image).