mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] portal: unskip some tests
This commit is contained in:
committed by
Aaron Bohy
parent
af80cefa76
commit
ae30d9db7d
@@ -53,6 +53,11 @@ class VPortal extends VText implements Partial<VNode<VPortal>> {
|
|||||||
|
|
||||||
export class Portal extends Component {
|
export class Portal extends Component {
|
||||||
static template = xml`<t t-slot="default"/>`;
|
static template = xml`<t t-slot="default"/>`;
|
||||||
|
static props = {
|
||||||
|
target: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
constructor(props: any, env: any, node: ComponentNode) {
|
constructor(props: any, env: any, node: ComponentNode) {
|
||||||
super(props, env, node);
|
super(props, env, node);
|
||||||
|
|||||||
@@ -372,11 +372,11 @@ exports[`Portal portal with only text as content 1`] = `
|
|||||||
exports[`Portal portal with target not in dom 1`] = `
|
exports[`Portal portal with target not in dom 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
let { text, createBlock, list, multi, html, toggler } = bdom;
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture } = helpers;
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber } = helpers;
|
||||||
let assign = Object.assign;
|
let assign = Object.assign;
|
||||||
|
|
||||||
let block1 = createBlock(\`<div><owl-child-0/></div>\`);
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
let block2 = createBlock(\`<div>2</div>\`);
|
let block2 = createBlock(\`<div>2</div>\`);
|
||||||
|
|
||||||
const slot2 = ctx => (node, key) => {
|
const slot2 = ctx => (node, key) => {
|
||||||
@@ -384,7 +384,7 @@ exports[`Portal portal with target not in dom 1`] = `
|
|||||||
}
|
}
|
||||||
|
|
||||||
return function template(ctx, node, key = \\"\\") {
|
return function template(ctx, node, key = \\"\\") {
|
||||||
let b3 = assign(node.getChild(\`Portal\`, {target: '#does-not-exist'}, key + \`__1\`, ctx), {slots: {'default': slot2(ctx)}});
|
let b3 = assign(component(\`Portal\`, {target: '#does-not-exist'}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
||||||
return block1([], [b3]);
|
return block1([], [b3]);
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
@@ -466,6 +466,48 @@ exports[`Portal with target in template (before portal) 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Portal: Props validation target is mandatory 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber } = helpers;
|
||||||
|
let assign = Object.assign;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
let block2 = createBlock(\`<div>2</div>\`);
|
||||||
|
|
||||||
|
const slot2 = ctx => (node, key) => {
|
||||||
|
return block2();
|
||||||
|
}
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b3 = assign(component(\`Portal\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
||||||
|
return block1([], [b3]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Portal: Props validation target is not list 1`] = `
|
||||||
|
"function anonymous(bdom, helpers
|
||||||
|
) {
|
||||||
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||||
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber } = helpers;
|
||||||
|
let assign = Object.assign;
|
||||||
|
|
||||||
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||||
|
let block2 = createBlock(\`<div>2</div>\`);
|
||||||
|
|
||||||
|
const slot2 = ctx => (node, key) => {
|
||||||
|
return block2();
|
||||||
|
}
|
||||||
|
|
||||||
|
return function template(ctx, node, key = \\"\\") {
|
||||||
|
let b3 = assign(component(\`Portal\`, {target: ['body']}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}});
|
||||||
|
return block1([], [b3]);
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`Portal: UI/UX focus is kept across re-renders 1`] = `
|
exports[`Portal: UI/UX focus is kept across re-renders 1`] = `
|
||||||
"function anonymous(bdom, helpers
|
"function anonymous(bdom, helpers
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -149,9 +149,7 @@ describe("Portal", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip("portal with target not in dom", async () => {
|
test("portal with target not in dom", async () => {
|
||||||
// need error handling to unskip this one
|
|
||||||
|
|
||||||
class Parent extends Component {
|
class Parent extends Component {
|
||||||
static components = { Portal };
|
static components = { Portal };
|
||||||
static template = xml`
|
static template = xml`
|
||||||
@@ -170,8 +168,8 @@ describe("Portal", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
expect(error.message).toBe('Could not find any match for "#does-not-exist"');
|
expect(error.message).toBe("invalid portal target");
|
||||||
expect(fixture.innerHTML).toBe(`<div id="outside"></div>`);
|
expect(fixture.innerHTML).toBe(`<div></div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("portal with child and props", async () => {
|
test("portal with child and props", async () => {
|
||||||
@@ -508,7 +506,10 @@ describe("Portal: UI/UX", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Portal: Props validation", () => {
|
describe("Portal: Props validation", () => {
|
||||||
test.skip("target is mandatory", async () => {
|
test("target is mandatory", async () => {
|
||||||
|
const consoleInfo = console.info;
|
||||||
|
console.info = jest.fn();
|
||||||
|
|
||||||
class Parent extends Component {
|
class Parent extends Component {
|
||||||
static components = { Portal };
|
static components = { Portal };
|
||||||
static template = xml`
|
static template = xml`
|
||||||
@@ -519,16 +520,21 @@ describe("Portal: Props validation", () => {
|
|||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
let error;
|
let error;
|
||||||
|
let app = new App(Parent);
|
||||||
|
app.configure({ dev: true });
|
||||||
try {
|
try {
|
||||||
await mount(Parent, fixture);
|
await app.mount(fixture);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
expect(error.message).toBe(`Missing props 'target' (component 'Portal')`);
|
expect(error.message).toBe(`Missing props 'target' (component 'Portal')`);
|
||||||
|
console.info = consoleInfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip("target is not list", async () => {
|
test("target is not list", async () => {
|
||||||
|
const consoleInfo = console.info;
|
||||||
|
console.info = jest.fn();
|
||||||
class Parent extends Component {
|
class Parent extends Component {
|
||||||
static components = { Portal };
|
static components = { Portal };
|
||||||
static template = xml`
|
static template = xml`
|
||||||
@@ -539,12 +545,15 @@ describe("Portal: Props validation", () => {
|
|||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
let error;
|
let error;
|
||||||
|
let app = new App(Parent);
|
||||||
|
app.configure({ dev: true });
|
||||||
try {
|
try {
|
||||||
await mount(Parent, fixture);
|
await app.mount(fixture);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
expect(error).toBeDefined();
|
expect(error).toBeDefined();
|
||||||
expect(error.message).toBe(`Invalid Prop 'target' in component 'Portal'`);
|
expect(error.message).toBe(`Invalid Prop 'target' in component 'Portal'`);
|
||||||
|
console.info = consoleInfo;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user