refactor: files{} -> challengeFiles[], and key -> fileKey (#43023)
* fix(client): fix client * fix propType and add comment * revert user.json prettification * slight type refactor and payload correction Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * update ChallengeFile type imports * add cypress test for code-storage * update test and storage epic * fix Shaun's tired brain's logic * refactor with suggestions Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * update codeReset * increate cypress timeout because firefox is slow * remove unused import to make linter happy * use focus on editor Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * use more specific seletor for cypress editor test * account for silly null challengeFiles Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
37
cypress/integration/learn/challenges/code-storage.js
Normal file
37
cypress/integration/learn/challenges/code-storage.js
Normal file
@ -0,0 +1,37 @@
|
||||
/* global cy */
|
||||
|
||||
const selectors = {
|
||||
defaultOutput: '.output-text',
|
||||
editor: '.react-monaco-editor-container'
|
||||
};
|
||||
|
||||
const location =
|
||||
'/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements';
|
||||
|
||||
describe('Challenge with editor', function () {
|
||||
before(() => {
|
||||
cy.visit(location);
|
||||
});
|
||||
|
||||
it('renders seed code without localStorage', () => {
|
||||
const editorContents = `<h1>Hello</h1>`;
|
||||
cy.get(selectors.editor).as('editor').contains(editorContents);
|
||||
cy.get('@editor').click().focused().type(`{movetoend}<h1>Hello World</h1>`);
|
||||
cy.reload();
|
||||
cy.get('@editor', { timeout: 10000 }).contains(editorContents);
|
||||
});
|
||||
|
||||
it('renders code from localStorage after "Ctrl + S"', () => {
|
||||
const editorContents = `<h1>Hello</h1>`;
|
||||
cy.get(selectors.editor).as('editor').contains(editorContents);
|
||||
cy.get('@editor')
|
||||
.click()
|
||||
.focused()
|
||||
.type(`{movetoend}<h1>Hello World</h1>{ctrl+s}`);
|
||||
cy.contains("Saved! Your code was saved to your browser's local storage.");
|
||||
cy.reload();
|
||||
cy.get('@editor', { timeout: 10000 }).contains(
|
||||
'<h1>Hello</h1><h1>Hello World</h1>'
|
||||
);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user