mirror of
https://github.com/codex-team/editor.js
synced 2026-03-17 08:05:47 +01:00
test case for file drop added
This commit is contained in:
parent
fedab192c4
commit
1e8f689444
1 changed files with 63 additions and 0 deletions
|
|
@ -11,6 +11,15 @@ describe("Drag and drop the block of Editor", function () {
|
|||
image: Image,
|
||||
},
|
||||
}).as("editorInstance");
|
||||
|
||||
const numberOfBlocks = 5;
|
||||
for (let i = 0; i < numberOfBlocks; i++) {
|
||||
cy.get('[data-cy=editorjs]')
|
||||
.get('div.ce-block')
|
||||
.last()
|
||||
.click()
|
||||
.type(`Block ${i}{enter}`);
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
|
@ -18,4 +27,58 @@ describe("Drag and drop the block of Editor", function () {
|
|||
this.editorInstance.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @todo check with dropping file other than the image.
|
||||
*/
|
||||
it("should drop file", function () {
|
||||
// Read file locally
|
||||
cy.readFile('example/assets/codex2x.png', 'base64').then((base64) => {
|
||||
// Create URI
|
||||
const uri = 'data:image/png;base64,' + base64;
|
||||
// Test by dropping the image.
|
||||
cy.get("[data-cy=editorjs]")
|
||||
.get('div.ce-block')
|
||||
.last()
|
||||
.attachFile('../../../example/assets/codex2x.png', { subjectType: 'drag-n-drop' })
|
||||
.wait(10);
|
||||
|
||||
cy.get('[data-cy=editorjs]')
|
||||
// In Edge test are performed slower, so we need to
|
||||
// increase timeout to wait until image is loaded on the page
|
||||
.get('img', { timeout: 10000 })
|
||||
.should('have.attr', 'src', uri);
|
||||
})
|
||||
});
|
||||
|
||||
// it("should drag the block", function () {
|
||||
|
||||
// cy.get('[data-cy=editorjs]')
|
||||
// .get('div.ce-block')
|
||||
// .first()
|
||||
// .click();
|
||||
|
||||
// const dataTransfer = new DataTransfer();
|
||||
// cy.get('.ce-toolbar__settings-btn')
|
||||
// .trigger("dragstart", { dataTransfer });
|
||||
// cy.get('[data-cy=editorjs]')
|
||||
// .get('div.ce-block')
|
||||
// .eq(2)
|
||||
// .trigger("dragenter").then((e) => {
|
||||
// const bbox = e[0].getBoundingClientRect();
|
||||
// cy.get('[data-cy=editorjs]')
|
||||
// .get('div.ce-block')
|
||||
// .eq(2)
|
||||
// .trigger("dragover", { clientX: bbox.x, clientY: (bbox.y + (bbox.width / 2 - 20)) })
|
||||
// .trigger("drop", { dataTransfer });
|
||||
// })
|
||||
// // .invoke('attr', 'class') // returns "class1 class2 class3"
|
||||
// // .then(classList => {
|
||||
// // console.log(classList);
|
||||
// // });
|
||||
|
||||
|
||||
// // cy.get('.ce-toolbar__settings-btn')
|
||||
// // .trigger("dragend", { dataTransfer });
|
||||
// });
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue