Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Component, xml } from "@odoo/owl";
import { basicContainerBuilderComponentProps, useBuilderComponent } from "./utils";
import { BuilderComponent } from "./builder_component";

export class BuilderContext extends Component {
static template = xml`
<BuilderComponent dependencies="props.dependencies">
<t t-slot="default"/>
</BuilderComponent>
`;
static props = {
...basicContainerBuilderComponentProps,
slots: { type: Object },
};
static components = {
BuilderComponent,
};

setup() {
useBuilderComponent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { BuilderColorPicker } from "./builder_colorpicker";
import { BuilderTextInput } from "./builder_text_input";
import { BuilderCheckbox } from "./builder_checkbox";
import { BuilderRange } from "./builder_range";
import { BuilderContext } from "./builder_context";

export const defaultBuilderComponents = {
BuilderContext,
BuilderRow,
Dropdown,
DropdownItem,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { expect, test } from "@odoo/hoot";
import { xml } from "@odoo/owl";
import { contains } from "@web/../tests/web_test_helpers";
import {
addActionOption,
addOption,
defineWebsiteModels,
setupWebsiteBuilder,
} from "../../helpers";

defineWebsiteModels();

test("should pass the context", async () => {
addActionOption({
customAction: {
apply: ({ param, value }) => {
expect.step(`customAction ${param} ${value}`);
},
},
});
addOption({
selector: ".test-options-target",
template: xml`
<BuilderContext action="'customAction'" actionParam="'myParam'">
<BuilderButton actionValue="'myValue'">MyAction</BuilderButton>
</BuilderContext>
`,
});
await setupWebsiteBuilder(`<div class="test-options-target">b</div>`);
await contains(":iframe .test-options-target").click();
await contains(".we-bg-options-container button").click();
// The function `apply` should be called twice (on hover (for preview), then, on click).
expect.verifySteps(["customAction myParam myValue", "customAction myParam myValue"]);
});