Skip to content

Commit

Permalink
History tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed May 23, 2021
1 parent 3f3c59b commit 468589c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 35 deletions.
84 changes: 50 additions & 34 deletions cypress/integration/history.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,58 @@ describe('Save History', () => {
cy.clearLocalStorage();
cy.visit('/edit');
});
xit('should save when clicked', () => {
cy.get('#historyList').find('li').should('have.length', 0);
cy.get('#historyList').contains('No items in History');
cy.get('#saveHistory').click();
cy.get('#historyList').find('No items in History').should('not.exist');
cy.get('#historyList').find('li').should('have.length', 1);
cy.get('#saveHistory').click();
cy.on('window:alert', (str) => {
expect(str).to.equal('State already saved.');
});
cy.on('window:confirm', () => true);
cy.get('#editor').type(' C --> HistoryTest');
cy.get('#saveHistory').click();
cy.get('#historyList').find('li').should('have.length', 2);
});
// it('should save when clicked', () => {
// cy.get('#historyList').find('li').should('have.length', 0);
// cy.get('#historyList').contains('No items in History');
// cy.get('#saveHistory').click();
// cy.get('#historyList').find('No items in History').should('not.exist');
// cy.get('#historyList').find('li').should('have.length', 1);
// cy.get('#saveHistory').click();
// cy.on('window:alert', (str) => {
// expect(str).to.equal('State already saved.');
// });
// cy.on('window:confirm', () => true);
// cy.get('#editor').type(' C --> HistoryTest');
// cy.get('#saveHistory').click();
// cy.get('#historyList').find('li').should('have.length', 2);
// });

it('should be able to restore and delete', () => {
cy.get('#saveHistory').click();
// it('should be able to restore and delete', () => {
// cy.get('#saveHistory').click();
// cy.get('#editor').type(' C --> HistoryTest');
// cy.get('#historyList').find('No items in History').should('not.exist');
// cy.get('#historyList').find('li').should('have.length', 1);
// cy.contains('HistoryTest');
// cy.contains('Restore').click();
// cy.contains('HistoryTest').should('not.exist');
// cy.contains('Delete').click();
// cy.get('#historyList').find('li').should('have.length', 0);
// cy.get('#historyList').contains('No items in History');
// cy.get('#saveHistory').click();
// cy.get('#editor').type(' C --> HistoryTest');
// cy.get('#saveHistory').click();
// cy.get('#editor').type('ing');
// cy.get('#clearHistory').click();
// cy.on('window:alert', (str) => {
// expect(str).to.equal('Clear all saved items?');
// });
// cy.on('window:confirm', () => true);
// cy.get('#historyList').contains('No items in History');
// });

it('should auto save history', () => {
cy.clock();
cy.get('#editor').type(' C --> HistoryTest');
cy.get('#historyList').find('No items in History').should('not.exist');
cy.tick(70000);
cy.contains('Timeline').click();
cy.get('#historyList').find('li').should('have.length', 1);
cy.contains('HistoryTest');
cy.contains('Restore').click();
cy.contains('HistoryTest').should('not.exist');
cy.get('#editor').type('ing');
cy.tick(70000);
cy.get('#historyList').find('li').should('have.length', 2);
for (let i = 0; i < 31; i++) {
cy.get('#editor').type('.');
cy.tick(70000);
}
cy.get('#historyList').find('li').should('have.length', 30);
});

// it('Check Redirect from old URL', () => {
// cy.visit(
// '/#/edit/eyJjb2RlIjoiZ3JhcGggVERcbiAgICBBW0NocmlzdG1hc10gLS0-fEdldCBtb25leXwgQihHbyBzaG9wcGluZylcbiAgICBCIC0tPiBDe0xldCBtZSB0aGlua31cbiAgICBDIC0tPnxPbmV8IERbTGFwdG9wXVxuICAgIEMgLS0-fFR3b3wgRVtpUGhvbmVdXG4gICAgQyAtLT58VGhyZWV8IEZbZmE6ZmEtY2FyIENhcl0iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9LCJ1cGRhdGVFZGl0b3IiOmZhbHNlfQ'
// );
// cy.url().should(
// 'include',
// '/edit/eyJjb2RlIjoiZ3JhcGggVERcbiAgICBBW0NocmlzdG1hc10gLS0-fEdldCBtb25leXwgQihHbyBzaG9wcGluZylcbiAgICBCIC0tPiBDe0xldCBtZSB0aGlua31cbiAgICBDIC0tPnxPbmV8IERbTGFwdG9wXVxuICAgIEMgLS0-fFR3b3wgRVtpUGhvbmVdXG4gICAgQyAtLT58VGhyZWV8IEZbZmE6ZmEtY2FyIENhcl0iLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9LCJ1cGRhdGVFZGl0b3IiOmZhbHNlfQ'
// );

// cy.contains('History').click();
// cy.wrap(localStorage).snapshot();
// });
});
2 changes: 1 addition & 1 deletion src/lib/components/navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<label for="menu-toggle" class="pointer-cursor lg:hidden block"
><svg
class="fill-current text-gray-900"
class="fill-current "
xmlns="http:https://www.w3.org/2000/svg"
width="20"
height="20"
Expand Down

0 comments on commit 468589c

Please sign in to comment.