add draft/publishing workflow
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { bindDraftActions } from '../src/Modules/GrapesJS/resources/assets/js/draft-actions.js';
|
||||
|
||||
function button() {
|
||||
let clickHandler;
|
||||
return {
|
||||
addEventListener(eventName, handler) {
|
||||
assert.equal(eventName, 'click');
|
||||
clickHandler = handler;
|
||||
},
|
||||
click() {
|
||||
clickHandler();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test('draft action saves edits and publishes only after confirmation', () => {
|
||||
const saveButton = button();
|
||||
const publishButton = button();
|
||||
const actions = [];
|
||||
let confirmation = false;
|
||||
|
||||
bindDraftActions(saveButton, publishButton, publishAfterSave => actions.push(publishAfterSave), () => confirmation);
|
||||
saveButton.click();
|
||||
publishButton.click();
|
||||
confirmation = true;
|
||||
publishButton.click();
|
||||
|
||||
assert.deepEqual(actions, [false, true]);
|
||||
});
|
||||
Reference in New Issue
Block a user