fix: duplicate and new entry action (#3003)

* fix: duplicate and new entry action

* test(e2e): flush clock when duplicating entry to handle debounced fields

Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
This commit is contained in:
Bartholomew
2019-12-25 10:47:02 +01:00
committed by Erez Rokah
parent e4ba4d9d74
commit 9e7aa0c500
4 changed files with 37 additions and 21 deletions

View File

@ -184,22 +184,7 @@ function selectDropdownItem(label, item) {
});
}
function populateEntry(entry) {
const keys = Object.keys(entry);
for (let key of keys) {
const value = entry[key];
if (key === 'body') {
cy.getMarkdownEditor()
.click()
.clear()
.type(value);
} else {
cy.get(`[id^="${key}-field"]`)
.clear()
.type(value);
}
}
function flushClockAndSave() {
cy.clock().then(clock => {
// some input fields are de-bounced thus require advancing the clock
if (clock) {
@ -218,6 +203,25 @@ function populateEntry(entry) {
});
}
function populateEntry(entry) {
const keys = Object.keys(entry);
for (let key of keys) {
const value = entry[key];
if (key === 'body') {
cy.getMarkdownEditor()
.click()
.clear()
.type(value);
} else {
cy.get(`[id^="${key}-field"]`)
.clear()
.type(value);
}
}
flushClockAndSave();
}
function newPost() {
cy.contains('a', 'New Post').click();
}
@ -257,7 +261,7 @@ function unpublishEntry(entry) {
function duplicateEntry(entry) {
selectDropdownItem('Published', 'Duplicate');
cy.url().should('contain', '/#/collections/posts/new');
cy.contains('button', 'Save').click();
flushClockAndSave();
updateWorkflowStatusInEditor(editorStatus.ready);
publishEntryInEditor(publishTypes.publishNow);
exitEditor();