Skip to content

Commit

Permalink
add cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
jpelay committed May 23, 2024
1 parent 7c39fd8 commit 5860cbe
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/cypress/e2e/hedy_page/run_code_button.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,38 @@ describe('Is able to run code', () => {
cy.visit('/hedy/14#tic')

const program_1 = "for i in range 1 to 10\n choice = ask 'What is your choice?'"
cy.intercept('/parse').as('parse')
cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').clear()
cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').type(program_1)
cy.get('#runit')
cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').type(program_1)
cy.get('#runit').click()
cy.wait('@parse')

cy.getBySel('quizmaster').click()
const program_2 = "name = ask 'what is your name?'"
cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').clear()
cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').type(program_2)
cy.get('#runit').click()
cy.wait('@parse')
cy.get('#ask-modal').type('Hedy')
cy.get('#ask-modal > form').submit()

cy.get('#ask-modal').should('not.be.visible')
})

it("After successfully executing a program, the stop program button is hidden", () => {
cy.intercept('/parse').as('parse')
cy.visit('/hedy/2')

const program = "var1 is 1\nvar2 is 2\nvar3 is 3\nvar4 is 4\nprint var1 var2 var3 var4"
cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').clear()
cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').type(program)

cy.get('#runit').click()
cy.wait('@parse')
// A hardcoded wait to ensure that the program finishes execution
cy.wait(500)
cy.get('#stopit').should('not.be.visible')
cy.get('#runit').should('be.visible')
cy.get('#variable-list').should('be.visible').and('have.text', 'var1: 1var2: 2var3: 3var4: 4')
})
})

0 comments on commit 5860cbe

Please sign in to comment.