-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for the double click on image and for the save mechanism
- Loading branch information
Showing
4 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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,26 @@ | ||
import { expect, test } from "@odoo/hoot"; | ||
import { animationFrame, dblclick } from "@odoo/hoot-dom"; | ||
import { defineWebsiteModels, openSnippetsMenu, setupWebsiteBuilder } from "./helpers"; | ||
|
||
defineWebsiteModels(); | ||
|
||
const base64Img = | ||
"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA\n AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO\n 9TXL0Y4OHwAAAABJRU5ErkJggg=="; | ||
|
||
test("double click on Image", async () => { | ||
await setupWebsiteBuilder(`<div><img class=a_nice_img src='${base64Img}'></div>`); | ||
await openSnippetsMenu(); | ||
expect(".modal-content").toHaveCount(0); | ||
await dblclick(":iframe img.a_nice_img"); | ||
await animationFrame(); | ||
expect(".modal-content:contains(Select a media) .o_upload_media_button").toHaveCount(1); | ||
}); | ||
|
||
test("double click on text", async () => { | ||
await setupWebsiteBuilder("<div><p class=text_class>Text</p></div>"); | ||
await openSnippetsMenu(); | ||
expect(".modal-content").toHaveCount(0); | ||
await dblclick(":iframe .text_class"); | ||
await animationFrame(); | ||
expect(".modal-content").toHaveCount(0); | ||
}); |
This file contains 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,30 @@ | ||
import { expect, test } from "@odoo/hoot"; | ||
import { defineWebsiteModels, openSnippetsMenu, setupWebsiteBuilder } from "./helpers"; | ||
import { insertText } from "@html_editor/../tests/_helpers/user_actions"; | ||
import { setContent } from "@html_editor/../tests/_helpers/selection"; | ||
import { onRpc } from "@web/../tests/web_test_helpers"; | ||
|
||
defineWebsiteModels(); | ||
|
||
test("basic save", async () => { | ||
const result = []; | ||
onRpc("ir.ui.view", "save", ({ args }) => { | ||
result.push(args[1]); | ||
return true; | ||
}); | ||
const { getEditor } = await setupWebsiteBuilder(getEditable('<h1 class="title">Hello</h1>')); | ||
await openSnippetsMenu(); | ||
const editor = getEditor(); | ||
setContent(editor.editable, getEditable('<h1 class="title">Hello[]</h1>')); | ||
await insertText(editor, "test"); | ||
expect(":iframe #wrap").toHaveClass("o_dirty"); | ||
// await click(".o-snippets-top-actions button:contains(Save)"); | ||
// expect(result.length).toBe(1); | ||
// expect(result[0]).toBe( | ||
// '<div id="wrap" data-oe-model="ir.ui.view" data-oe-id="539" data-oe-field="arch"><h1 class="title">Hellotest</h1></div>' | ||
// ); | ||
}); | ||
|
||
function getEditable(inWrap) { | ||
return `<div id="wrap" data-oe-model="ir.ui.view" data-oe-id="539" data-oe-field="arch">${inWrap}</div>`; | ||
} |
This file contains 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