From 79105af50db855040be96cbe8a731b454fbcaa22 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Mon, 14 Sep 2020 14:48:44 +0200 Subject: [PATCH] test(e2e): submission of unfinished challenge urls --- .../integration/learn/challenges/backend.js | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 cypress/integration/learn/challenges/backend.js diff --git a/cypress/integration/learn/challenges/backend.js b/cypress/integration/learn/challenges/backend.js new file mode 100644 index 00000000000..573369dc385 --- /dev/null +++ b/cypress/integration/learn/challenges/backend.js @@ -0,0 +1,41 @@ +/* global cy */ + +const locations = { + index: + 'learn/apis-and-microservices/managing-packages-with-npm/' + + 'how-to-use-package-json-the-core-of-any-node-js-project-or-npm-package' +}; + +const selectors = { + defaultOutput: '.output-text', + input: 'input[name="solution"]' +}; + +const unhandledErrorMessage = 'Something is not quite right'; +const runningOutput = '// running tests'; +const finishedOutput = '// tests completed'; + +describe('Backend challenge', function() { + it('renders', () => { + cy.visit(locations.index); + + cy.title().should( + 'eq', + 'Managing Packages with Npm - How to Use package.json, the Core of Any' + + ' Node.js Project or npm Package | Learn | freeCodeCamp.org' + ); + }); + + it('does not generate unhandled errors on submission', () => { + cy.visit(locations.index); + cy.get(selectors.input) + .type('https://example.com') + .type('{enter}') + .then(() => { + cy.get(selectors.defaultOutput) + .contains(runningOutput) + .contains(finishedOutput); + cy.contains(unhandledErrorMessage).should('not.exist'); + }); + }); +});