|
| 1 | +describe('Happy path', () => { |
| 2 | + const getFirstNote = () => cy.get('.note-item'); |
| 3 | + const firstNoteTitle = () => getFirstNote().get('.title-part'); |
| 4 | + const getFirstNoteStar = () => getFirstNote().get('.fa-star'); |
| 5 | + const getFirstGroupCounter = () => cy.get('.counter'); |
| 6 | + const getFirstGroupFavCounter = () => cy.get('.fav-counter'); |
| 7 | + const evenIfNotVisible = { force: true }; |
| 8 | + |
| 9 | + before(() => { |
| 10 | + cy.login(); |
| 11 | + cy.visit('/'); |
| 12 | + }); |
| 13 | + |
| 14 | + after(async () => { |
| 15 | + await cy.deleteRepo(); |
| 16 | + cy.window().then(win => { |
| 17 | + win.localStorage.clear(); |
| 18 | + return indexedDB.deleteDatabase('pensieve-data'); |
| 19 | + }); |
| 20 | + }); |
| 21 | + |
| 22 | + it('Create note', () => { |
| 23 | + const clickCreateNote = () => cy.get(`aside .fa-plus`).click(); |
| 24 | + |
| 25 | + cy.expectCommitFrom(clickCreateNote); |
| 26 | + getFirstNote().should('be.exist'); |
| 27 | + }); |
| 28 | + |
| 29 | + it('Unfavorite note', () => { |
| 30 | + getFirstNoteStar().should('have.class', 'fas'); |
| 31 | + cy.expectCommitFrom(() => getFirstNoteStar().click()); |
| 32 | + getFirstNoteStar().should('have.class', 'far'); |
| 33 | + }); |
| 34 | + |
| 35 | + it('Favorite note', () => { |
| 36 | + getFirstNoteStar().should('have.class', 'far'); |
| 37 | + cy.expectCommitFrom(() => getFirstNoteStar().click(evenIfNotVisible)); |
| 38 | + getFirstNoteStar().should('have.class', 'fas'); |
| 39 | + }); |
| 40 | + |
| 41 | + it('Edit note title', () => { |
| 42 | + getFirstNote().click(); |
| 43 | + cy.writeToEditor('TESTING'); |
| 44 | + firstNoteTitle().should('include.text', 'TESTING'); |
| 45 | + cy.saveNote(); |
| 46 | + }); |
| 47 | + |
| 48 | + it('Move note to folder', () => { |
| 49 | + const getFirstGroup = () => cy.get('.group'); |
| 50 | + const getFirstGroupTitle = () => getFirstGroup().get('.group-title'); |
| 51 | + |
| 52 | + getFirstNote().click(); |
| 53 | + cy.writeToEditor('MY FOLDER / NOTE NAME'); |
| 54 | + firstNoteTitle().contains('NOTE NAME'); |
| 55 | + cy.saveNote(); |
| 56 | + getFirstGroup().should('be.exist'); |
| 57 | + getFirstGroupTitle().contains('MY FOLDER'); |
| 58 | + getFirstGroupCounter().contains('1'); |
| 59 | + }); |
| 60 | + |
| 61 | + it('Unfavorite note in group', () => { |
| 62 | + getFirstGroupFavCounter().contains('1'); |
| 63 | + getFirstNoteStar().should('have.class', 'fas'); |
| 64 | + cy.expectCommitFrom(() => getFirstNoteStar().click()); |
| 65 | + getFirstNoteStar().should('have.class', 'far'); |
| 66 | + getFirstGroupFavCounter().should('not.exist'); |
| 67 | + }); |
| 68 | + |
| 69 | + it('Favorite note in group', () => { |
| 70 | + getFirstGroupFavCounter().should('not.exist'); |
| 71 | + getFirstNoteStar().should('have.class', 'far'); |
| 72 | + cy.expectCommitFrom(() => getFirstNoteStar().click(evenIfNotVisible)); |
| 73 | + getFirstNoteStar().should('have.class', 'fas'); |
| 74 | + getFirstGroupFavCounter().contains('1'); |
| 75 | + }); |
| 76 | + |
| 77 | + it('Delete note', () => { |
| 78 | + const deleteFirstNote = () => |
| 79 | + cy.get('.note-item .fa-trash').click(evenIfNotVisible); |
| 80 | + |
| 81 | + cy.expectCommitFrom(deleteFirstNote); |
| 82 | + getFirstNote().should('not.exist'); |
| 83 | + }); |
| 84 | +}); |
0 commit comments