Files
freeCodeCamp/cypress/integration/default/learn/challenges/multifileCertProject.js
Ahmad Abdolsaheb 29e4a18a56 feat(tools): donation tests (#46633)
* feat: add stripe donate page test for non donors

* fix: revert changes to see if ev is passed correctly

* feat: download artifacts

* fix: add quotations for spec args with global patterns

* fix: remove firefox from cypress donation tests

* fix: trigger action on main push

* Apply suggestions from code review

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* feat: remove matrix and simplify

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2022-08-08 08:43:23 -07:00

54 lines
1.7 KiB
JavaScript

const save1text = 'save 1';
const save2text = 'save 2';
const selectors = {
editor: '.react-monaco-editor-container',
saveCodeBtn: '[data-cy="save-code-to-database-btn"]'
};
describe('multifileCertProjects', function () {
before(() => {
cy.exec('npm run seed');
cy.login();
cy.visit(
'learn/responsive-web-design/responsive-web-design-projects/build-a-tribute-page'
);
});
beforeEach(() => {
cy.preserveSession();
});
it('should save and reload user code', function () {
// save to database (savedChallenges) when clicking save code button
cy.get(selectors.editor).click().focused().clear().type(save1text);
cy.get(selectors.saveCodeBtn).click();
cy.contains('Your code was saved to the database.');
// load saved code on a hard refresh
cy.reload();
cy.contains(save1text);
});
it('should save to using ctrl+s hotkey and persist through navigation', function () {
// since rapid clicks will cause the save requests to be ignored, we have to
// purge the db:
cy.exec('npm run seed');
// and the redux store:
cy.reload();
cy.get(selectors.editor)
.click()
.focused()
.clear()
.type(`${save2text}{ctrl+s}`);
cy.contains('Your code was saved to the database.');
// load saved code when navigating site (no hard refresh)'
cy.contains('Responsive Web Design Projects').click();
cy.contains('In this Responsive Web Design Certification');
cy.contains('Build a Tribute Page').click();
cy.contains(save2text);
// trigger the warning about saving too quickly
cy.get(selectors.saveCodeBtn).click().click();
cy.contains('Your code was not saved.');
});
});