Files
freeCodeCamp/cypress/integration/learn/challenges/multifileCertProject.js
Tom f04fbba22d feat: convert RWD cert projects (#44564)
* feat: convert RWD cert projects

* feat: convert original projects

* fix: add usesMultiFileEditor to meta

* feat: add cypress tests for saving and loading to/from database

* fix: broken cypress tests

* fix: inconsistent variable naming

* fix: missed variable name

* fix: more cypress

* feat: add solutions for english

* fix: ctrl+s to database only if signed in

* fix: prioritize code from db

* refactor: expand the comments slightly
2022-05-05 10:58:14 +02:00

57 lines
1.6 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 show a save code button', function () {
cy.get(selectors.saveCodeBtn);
});
it('should save to database (savedChallenges) when clicking save code button', function () {
cy.get(selectors.editor).click().focused().clear().type(save1text);
cy.get(selectors.saveCodeBtn).click();
cy.contains('Your code was saved to the database.');
});
it('should not allow you to save twice in a row too fast', function () {
cy.get(selectors.saveCodeBtn).click().click();
cy.contains('Your code was not saved.');
});
it('should load saved code on a hard refresh', function () {
cy.reload();
cy.contains(save1text);
});
it('should save to database (savedChallenges) when using ctrl+s hotkey', function () {
cy.get(selectors.editor)
.click()
.focused()
.clear()
.type(`${save2text}{ctrl+s}`);
cy.contains('Your code was saved to the database.');
});
it('should load saved code when navigating site (no hard refresh)', function () {
cy.contains('Responsive Web Design Projects').click();
cy.contains('Build a Tribute Page').click();
cy.contains(save2text);
});
});