From 675196bab3f6e14c8e8342a0f1d3f464665135d2 Mon Sep 17 00:00:00 2001 From: Arnab Sen Date: Tue, 19 Apr 2022 11:21:49 +0530 Subject: [PATCH] test for checking saved items in the open pane --- cypress/integration/interface.test.js | 44 +++++++++++++++++++++++++++ src/components/CreateNewModal.jsx | 1 + 2 files changed, 45 insertions(+) diff --git a/cypress/integration/interface.test.js b/cypress/integration/interface.test.js index e08b7de..81b09ec 100644 --- a/cypress/integration/interface.test.js +++ b/cypress/integration/interface.test.js @@ -104,4 +104,48 @@ describe('Testing interfaces', () => { expect(ls['html']).to.eq(sampleText); }); }); + + it('Clicking "OPEN" should open the saved items pane', () => { + cy.on('window:confirm', text => { + expect(text).to.contains('Do you still want to continue saving locally?'); + return true; + }); + + const addCreation = message => { + // start with blank project + cy.get('[data-testid=newButton').click(); + cy.get('[data-testid=startBlankButton]').click(); + + // type a message in the HTML section + cy.get('#htmlCodeEl').type('{ctrl+a}{backspace}' + message); + + // type the title + cy.get('#titleInput').clear().type(message); + + // save it + cy.get('#saveBtn').click(); + // cy.get('#saveBtn').click(); + cy.wait(1500); + cy.then(() => { + const ls = JSON.parse(localStorage.getItem('code')); + console.log(ls); + expect(ls).to.be.not.null; + expect(ls['title']).to.eq(message); + expect(ls['html']).to.eq(message); + }); + }; + + // save some projects + const messages = ['test', 'test2', 'abc']; + messages.forEach(m => addCreation(m)); + + // check for the saved projects + cy.get('#openItemsBtn').click(); + messages.forEach((m, index) => { + cy.get('#js-saved-items-wrap') + .children() + .eq(messages.length - index - 1) + .contains(m); + }); + }); }); diff --git a/src/components/CreateNewModal.jsx b/src/components/CreateNewModal.jsx index 1bd5aab..f15c0e4 100644 --- a/src/components/CreateNewModal.jsx +++ b/src/components/CreateNewModal.jsx @@ -159,6 +159,7 @@ export class CreateNewModal extends Component { trackEvent('ui', 'startBlankBtnClick'); onBlankTemplateSelect(); }} + data-testid="startBlankButton" > Start Blank