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

[FIX] Highlighted commands are shown in errors again #4468

Merged
merged 7 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion static/css/additional.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
padding: 0.25rem;
font-family: monospace;
border-radius: 0.25rem;
}}
}

.command-highlighted {
background-color: #272822;
Expand Down
2 changes: 1 addition & 1 deletion templates/incl/editor-and-output.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</div>
<div>
<p class="caption font-bold">Oops</p>
<p class="details text-sm">An error occurred.</p>
<p class="details text-sm" data-cy="error_details">An error occurred.</p>
</div>
</div>
</div>
Expand Down
35 changes: 31 additions & 4 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);
Felienne marked this conversation as resolved.
Show resolved Hide resolved
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,20 +47,45 @@ 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
cy.get('#runit').click();
cy.get('#output').should('contain.text', 'Hello world');
cy.get('#ask-modal').should('be.visible');
});

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

cy.get('#errorbox').should('be.visible');
// The error should be about the lonely echo
cy.getBySel('error_details').should('contain.text', 'echo');
});

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('have.text', 'prin Hello world');
cy.get('#runit').click();

cy.get('#errorbox').should('be.visible');
// The error should be about the lonely echo
cy.getBySel('error_details').should('contain.text', 'prin');
cy.get('[data-cy="error_details"] span').should('have.class', 'command-highlighted');

});
});
Loading