1
0
mirror of https://gitlab.com/bramw/baserow.git synced 2024-11-21 23:37:55 +00:00
bramw_baserow/e2e-tests/fixtures/builder/builderElement.ts
2024-11-14 12:30:42 +00:00

30 lines
750 B
TypeScript

import { getClient } from "../../client";
import { BuilderPage } from "./builderPage";
import { User } from "../user";
export class BuilderElement {
constructor(
public page: BuilderPage,
public id: number,
public type: string,
public properties: Object
) {}
}
export async function createBuilderElement(
page: BuilderPage,
elementType: string,
properties: Object = {}
): Promise<BuilderElement> {
const response: any = await getClient(page.builder.workspace.user).post(
`builder/page/${page.id}/elements/`,
{
page_id: page.id,
type: elementType,
...properties,
}
);
const { id, type, ...rest } = response.data;
return new BuilderElement(page, response.data.id, elementType, rest);
}