Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jpelay committed Sep 8, 2023
1 parent f56709d commit a972787
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/cypress/e2e/hedy_page/editor_box.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ describe('Test editor box functionality', () => {
cy.visit(`${Cypress.env('hedy_page')}#default`);
// click on textaread to get focus
cy.get('#editor > .ace_scroller > .ace_content').click();
// empty textarea
// We wait until the editor is focused
// TODO: replace this wait. The editor takes a while to be focused
cy.wait(1000);
cy.focused().clear();
});

it('Ask modal should hold input and the answer should be shown in output', () => {
cy.get('#editor').type('print Hello world\nask Hello!\necho');
cy.get('#editor > .ace_scroller > .ace_content').should('contain.text', 'print Hello worldask Hello!echo');
cy.get('#editor > .ace_scroller > .ace_content').should('have.text', 'print Hello worldask Hello!echo');
cy.get('#runit').click();
cy.get('#output').should('contain.text', 'Hello world');
cy.get('#ask-modal').should('be.visible');
Expand All @@ -45,15 +47,18 @@ describe('Test editor box functionality', () => {
// First we write and run the program and leave the ask modal unanswered
cy.get('#editor').type('print Hello world\nask Hello!');
// the \n is not shown as a charecter when you get the text
cy.get('#editor > .ace_scroller > .ace_content').should('contain.text', 'print Hello worldask Hello!');
cy.get('#editor > .ace_scroller > .ace_content').should('have.text', 'print Hello worldask Hello!');
cy.get('#runit').click();
cy.get('#output').should('contain.text', 'Hello world');
cy.get('#ask-modal').should('be.visible');

// Now we edit the program and the ask modal should be hidden
cy.get('#editor > .ace_scroller > .ace_content').click();
cy.focused().clear();
// TODO: replace this wait. The editor takes a while to be focused
cy.wait(500)
cy.focused().clear();
cy.get('#editor').type('print Hello world\nask Hello!');
cy.get('#editor > .ace_scroller > .ace_content').should('have.text', 'print Hello worldask Hello!');
cy.get('#ask-modal').should('not.be.visible');

// Running program again and it should show the modal
Expand All @@ -64,7 +69,7 @@ describe('Test editor box functionality', () => {

it ('When making an error the error modal should be shown', () => {
cy.get('#editor').type('echo');
cy.get('#editor > .ace_scroller > .ace_content').should('contain.text', 'echo');
cy.get('#editor > .ace_scroller > .ace_content').should('have.text', 'echo');
cy.get('#runit').click();

cy.get('#errorbox').should('be.visible');
Expand All @@ -74,7 +79,7 @@ describe('Test editor box functionality', () => {

it ('When making an error the keywords must be highligted', () => {
cy.get('#editor').type('prin Hello world');
cy.get('#editor > .ace_scroller > .ace_content').should('contain.text', 'prin Hello world');
cy.get('#editor > .ace_scroller > .ace_content').should('have.text', 'prin Hello world');
cy.get('#runit').click();

cy.get('#errorbox').should('be.visible');
Expand Down

0 comments on commit a972787

Please sign in to comment.