-
-
Notifications
You must be signed in to change notification settings - Fork 782
(feat): Autosave using localStorage #6864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
8a984a7
bring 4252 up to date
dobri1408 0cc0fd4
Merge branch 'main' into auto-save
dobri1408 38b1057
fix cypress
dobri1408 385834b
fix snapshots
dobri1408 6168544
Create 6864.feature
dobri1408 6a8d787
fix unit test
dobri1408 0443f7a
fix unit test
dobri1408 c3178ce
Merge branch 'main' into auto-save
dobri1408 f36ed6a
Merge branch 'main' into auto-save
dobri1408 528884a
Update packages/volto/news/6864.feature
dobri1408 32065c1
semantics
dobri1408 e9e1f4d
Merge branch 'auto-save' of https://github.com/plone/volto into auto-…
dobri1408 f468afb
semantics
dobri1408 d4e19c7
merge
dobri1408 523545f
fix logic
dobri1408 997022d
fix logic
dobri1408 9127860
snapshots
dobri1408 a0ec6c4
fix pnpm and snapshots
dobri1408 e5bcfd5
fix cy mistake
dobri1408 f96ed97
docs
dobri1408 499d103
revert to main
dobri1408 8b20095
Update blocks.md
dobri1408 c1209cf
Update docs/source/user-manual/blocks.md
dobri1408 a1bcd06
Update docs/source/user-manual/blocks.md
dobri1408 dba6368
Update docs/source/user-manual/blocks.md
dobri1408 f9d5ed1
Update docs/source/user-manual/blocks.md
dobri1408 383060d
Update docs/source/user-manual/blocks.md
dobri1408 6beafed
Update docs/source/user-manual/blocks.md
dobri1408 decc498
Update docs/source/user-manual/blocks.md
dobri1408 90951dd
add save icon
dobri1408 b86c3b0
Update blocks.md
dobri1408 ea4f5a3
Update docs/source/user-manual/blocks.md
dobri1408 c0a3b3e
Update docs/source/user-manual/blocks.md
dobri1408 67a1f04
Merge branch 'main' into auto-save
dobri1408 db70e10
fix conflicts
dobri1408 1f517f9
fix tests
dobri1408 1d01fc5
fix tests
dobri1408 df02429
Merge branch 'main' into auto-save
dobri1408 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
describe('createContent Tests', () => { | ||
beforeEach(() => { | ||
cy.autologin(); | ||
cy.createContent({ | ||
contentType: 'Document', | ||
contentId: 'comments-page', | ||
contentTitle: 'Comments Page', | ||
allow_discussion: true, | ||
}); | ||
cy.setRegistry( | ||
'plone.app.discussion.interfaces.IDiscussionSettings.globally_enabled', | ||
true, | ||
); | ||
cy.createContent({ | ||
contentType: 'Document', | ||
contentId: 'my-first-page', | ||
contentTitle: 'My First Page', | ||
}); | ||
cy.createContent({ | ||
contentType: 'Document', | ||
contentId: 'my-second-page', | ||
contentTitle: 'My Second Page', | ||
}); | ||
}); | ||
|
||
it('As editor I can autosave when editing a content item', () => { | ||
cy.visit('/my-first-page'); | ||
|
||
cy.log('adding a text block on the first page'); | ||
|
||
cy.navigate('/my-first-page/edit'); | ||
cy.getSlateEditorAndType('My first text').contains('My first text'); | ||
cy.wait(1000); | ||
|
||
cy.visit('/my-second-page'); | ||
|
||
cy.log('adding a text block on the second page'); | ||
cy.navigate('/my-second-page/edit'); | ||
|
||
cy.getSlateEditorAndType('My second text').contains('My second text'); | ||
cy.wait(1000); | ||
|
||
cy.log('visit first page and start editing'); | ||
|
||
cy.visit('/my-first-page'); | ||
cy.navigate('/my-first-page/edit'); | ||
cy.wait(1000); | ||
|
||
cy.get('.toast-inner-content') | ||
.contains('Autosaved content found') | ||
.get('button.ui.icon.button.save.toast-box') | ||
.eq(0) | ||
.click(); | ||
|
||
cy.wait(1000); | ||
|
||
cy.getSlate().contains('My first text'); | ||
|
||
cy.log('visit second page and start editing'); | ||
|
||
cy.visit('/my-second-page'); | ||
cy.navigate('/my-second-page/edit'); | ||
cy.wait(1000); | ||
|
||
cy.get('.toast-inner-content') | ||
.contains('Autosaved content found') | ||
.get('button.ui.icon.button.save.toast-box') | ||
.eq(0) | ||
.click(); | ||
|
||
cy.wait(1000); | ||
|
||
cy.getSlate().contains('My second text'); | ||
cy.reload(); | ||
|
||
cy.log( | ||
'test is cancel load data will delete from storage (toast does not show)', | ||
); | ||
cy.get('.toast-inner-content') | ||
.contains('Autosaved content found') | ||
.get('button.ui.icon.button.save.toast-box') | ||
.eq(1) | ||
.click(); | ||
|
||
cy.wait(1000); | ||
cy.reload(); | ||
|
||
cy.wait(1000); | ||
|
||
cy.contains('Autosaved content found').should('not.exist'); | ||
}); | ||
|
||
it('As editor I can autosave when adding a content item', function () { | ||
cy.visit('/'); | ||
|
||
cy.log( | ||
'adding a Document content type and refresh to verify if content is autosaved and retrieved', | ||
); | ||
cy.get('#toolbar-add').click().get('#toolbar-add-document').click(); | ||
cy.getSlateTitle().type('Page 1 title'); | ||
cy.getSlateEditorAndType('Page 1 content').contains('Page 1 content'); | ||
cy.wait(1000); | ||
cy.reload(); | ||
|
||
cy.log('test if autosaved toast shows retrieved data and click OK to load'); | ||
cy.get('.toast-inner-content') | ||
.contains('Autosaved content found') | ||
.get('button.ui.icon.button.save.toast-box') | ||
.eq(0) | ||
.click(); | ||
|
||
cy.wait(1000); | ||
|
||
cy.log('test if autosaved data is loaded'); | ||
cy.getSlateTitle().contains('Page 1 title'); | ||
cy.getSlate().contains('Page 1 content'); | ||
|
||
cy.log( | ||
'test if draft is autosaved after I cancel adding a new page content type', | ||
); | ||
|
||
cy.get('button.button.cancel').click(); | ||
|
||
cy.wait(1000); | ||
|
||
cy.get('#toolbar-add').click().get('#toolbar-add-document').click(); | ||
|
||
cy.get('.toast-inner-content') | ||
.contains('Autosaved content found') | ||
.get('button.ui.icon.button.save.toast-box') | ||
.eq(0) | ||
.click(); | ||
|
||
cy.wait(1000); | ||
cy.getSlateTitle().contains('Page 1 title'); | ||
cy.getSlate().contains('Page 1 content'); | ||
|
||
cy.wait(1000); | ||
|
||
cy.log('test if page content type is added as new page after Toolbar Save'); | ||
|
||
cy.get('#toolbar-save').focus().click(); | ||
cy.wait(2000); | ||
cy.contains('Page 1 title'); | ||
cy.wait(1000); | ||
|
||
cy.log('test draft is deleted from local storage after save'); | ||
|
||
cy.visit('/'); | ||
cy.get('#toolbar-add').click().get('#toolbar-add-document').click(); | ||
|
||
cy.wait(1000); | ||
|
||
cy.contains('Autosaved content found').should('not.exist'); | ||
}); | ||
|
||
it('As editor I can autosave comments', function () { | ||
cy.log('adding a comment and refresh,'); | ||
cy.visit('/comments-page'); | ||
cy.get('textarea[id="field-comment"]').clear().type('This is a comment'); | ||
cy.wait(1000); | ||
cy.reload(); | ||
|
||
cy.log('test if comment is retrieved from local storage'); | ||
|
||
cy.get('.toast-inner-content') | ||
.contains('Autosaved content found') | ||
.get('button.ui.icon.button.save.toast-box') | ||
.eq(0) | ||
.click(); | ||
|
||
cy.get('#field-comment').contains('This is a comment'); | ||
|
||
cy.wait(1000); | ||
cy.reload(); | ||
|
||
cy.log( | ||
'test if comment is deleted from local storage after selecting Cancel in the Autosave toast', | ||
); | ||
|
||
cy.get('.toast-inner-content') | ||
.contains('Autosaved content found') | ||
.get('button.ui.icon.button.save.toast-box') | ||
.eq(1) | ||
.click(); | ||
|
||
cy.wait(1000); | ||
cy.reload(); | ||
cy.contains('Autosaved content found').should('not.exist'); | ||
|
||
cy.log('adding another comment and save it'); | ||
|
||
cy.get('textarea[id="field-comment"]') | ||
.clear() | ||
.type('This is a another comment'); | ||
cy.wait(1000); | ||
cy.reload(); | ||
|
||
cy.get('.toast-inner-content') | ||
.contains('Autosaved content found') | ||
.get('button.ui.icon.button.save.toast-box') | ||
.eq(0) | ||
.click(); | ||
|
||
cy.wait(1000); | ||
|
||
cy.get('button[type="submit"').click(); | ||
|
||
cy.get('.comment').contains('This is a another comment'); | ||
|
||
cy.log('test if the local storage comment was deleted after submit'); | ||
|
||
cy.wait(1000); | ||
cy.reload(); | ||
cy.contains('Autosaved content found').should('not.exist'); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.