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

🧪 Test a few broken programs from the front-end #5421

Merged
merged 9 commits into from
Apr 17, 2024
75 changes: 75 additions & 0 deletions tests/cypress/e2e/hedy_page/invalid_program.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import {goToHedyLevel5Page, goToHedyPage} from "../tools/navigation/nav";

describe('Error code gives correct error', () => {
describe('Misspelled Keyword', () => {
it('tests the print keyword', () => {
const error_code = "prnt Hello world!"
const error_message = `prnt is not a Hedy level 1 command. Did you mean print?`;
goToHedyPage();

cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').click();
cy.focused().type(error_code);

cy.intercept('/parse').as('parse')
cy.get('#runit').click();
cy.wait('@parse')
cy.get('#errorbox').should('be.visible').should('contain', error_message);
})

it('tests the ask keyword', () => {
const error_code = "print Hello world!\nak Hello world?"
const error_message = `ak is not a Hedy level 1 command. Did you mean ask?`;
goToHedyPage();

cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').click();
cy.focused().type(error_code);

cy.intercept('/parse').as('parse')
cy.get('#runit').click();
cy.wait('@parse')
cy.get('#errorbox').should('be.visible').should('contain', error_message);
})
})

describe('Missing Command', () => {
const error_code = "hello world"
const error_message = `It looks like you forgot to use a command on line 1.`;
goToHedyPage();

cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').click();
cy.focused().type(error_code);

cy.intercept('/parse').as('parse')
cy.get('#runit').click();
cy.wait('@parse')
cy.get('#errorbox').should('be.visible').should('contain', error_message);
})

idescribet('Invalid Argument Type', () => {
const error_code = "forward lalala"
const error_message = `You cannot use forward with lalala because it is text. Try changing lalala to a number or input from ask`;
goToHedyPage();

cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').click();
cy.focused().type(error_code);

cy.intercept('/parse').as('parse')
cy.get('#runit').click();
cy.wait('@parse')
cy.get('#errorbox').should('be.visible').should('contain', error_message);
})

describe('Invalid Argument', () => {
const error_code = "turn test"
const error_message = `You cannot use the command turn`;
goToHedyPage();

cy.get('#editor > .cm-editor > .cm-scroller > .cm-content').click();
cy.focused().type(error_code);

cy.intercept('/parse').as('parse')
cy.get('#runit').click();
cy.wait('@parse')
cy.get('#errorbox').should('be.visible').should('contain', error_message);
})
})
Loading