Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛(tests) more stable tests #22

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Comment on lines +91 to +94
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you changed the commands

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to group together similar tasks.
Currently, in the bootstrap ci step, we start all services except the edX CMS and then in the test step, we start the CMS and run the tests.
Thus, I suggest starting all services in the bootstrap CI step and only running the tests in the test CI step.
WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed I think it's a good idea 👍


lint-test:
docker:
Expand Down
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ node_modules

e2e/cypress/screenshots
e2e/cypress/videos

# Don't lint edX sources
edx/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ data/
# Sources
src/

# EdX modules
edx/modules/

# End-to-end testing
e2e/cypress/screenshots
e2e/cypress/videos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions env.d/cypress
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CYPRESS_BASE_URL=http://edx_lms:8000
CYPRESS_RETRIES=9
CYPRESS_CHROME_WEB_SECURITY=false

[email protected]
CYPRESS_EDX_ADMIN_PASSWORD=admin
Expand Down