mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 16:28:31 +00:00
* Add ADR-013 for workspace level integrations * Add implementation * Improve context section and remove technical points * Move bulk replacement point to v2 * Remove workspace-level ownership on import since manual promotion should handle this. * Add a glossary section * Do Lazy creation + Celery migration * Remove demotion * Tighten the Options considered section * Add Decision describing where the integrations are managed * Update implementation plan after changes to ADR * Sync plan and adr * Rename adr and implementation * Add the shared application that owns workspace integrations * Create the shared application of every workspace * Let only workspace admins manage workspace integrations * Let applications use the integrations of their workspace. * Trash workspace integrations in their workspace. * Copy workspace integrations into exports and keep them in duplicates. * Workspace admins can share integrations with every application in the workspace. * Load the shared application of each workspace in the frontend and keep it out of application lists. * Manage workspace integrations from an Integrations page in workspace settings. * Offer workspace integrations in the integration dropdowns of every application. * Move promoted integrations to the workspace list in other open tabs. * Let admins make an app's integration available to the whole workspace from its integration settings. * Preselect a workspace integration for new nodes and data sources when the app has none of its own. * fix tests * Delete implementation file * More fixes after rebase * Fix tests * Let builders of an application see and use the workspace integrations from it. * Show the workspace integrations, read-only, in the integration settings of applications. * Keep a dashboard's integration out of promotion to the workspace. * Leave the shared applications out of the admin dashboard's application count. * Create the shared application of the workspaces made by the fill commands. * Say in the promotion modal that an integration nobody authorized will run as the promoting admin. * Say in the promotion modal that undoing it won't make the integration run as the previous person again. * Ignore integration ids in sample data when publishing copies the workspace integrations an app uses. * Let only undoing a promotion move an integration out of the workspace. * Let the shared application backfill stop itself after 5 minutes and skip workspaces another transaction has locked. * Say in the workspace integrations settings that published applications and workflows keep their own copy until they're published again. * Leave the shared application out of the assistant evals' application counts. * Refresh the workspace integrations when the Builder's data, events, users and integrations panels open. * Say that anything new using a promoted integration blocks undoing the promotion, even from its own application. * Warn when a database button sends through a workspace integration with no host or token. * Refuse roles and invitations on the shared application. * Fix tests * Show an application only the workspace integrations of types it can use. * Say in the promotion modal what builders of other applications can do as the integration. * Leave the shared application type out of the API docs for creating and updating applications. * Check who receives a workspace integration event in one permission call. * Say which workspaces have a shared application and who creates it. * Let a redone promotion record what uses the integration again. * Update docstrings * Stop template visitors from listing the integrations of the template's workspace. * Let database buttons find their own copy of a workspace integration after an import. * Say what holds the workspace row lock while a shared application is created. * Fix tests * Stop the workspace integration form component from being made reactive. * Make test runs use a new copy of the workflow after an integration it uses changes. * Hide the Members settings tab from members who can't list the workspace members. * Add changelog * Fix migration conflict * Fix migration conflict * Fix test * Update comments and ADR number * Link to the workspace integrations from the sidebar's Settings menu. * fix: refresh agent action errors when workspace integrations change * fix: move workspace integrations into workspace settings * fix: use share icon for workspace integration promotion * refactor: use explicit shared application relations * feat: centralize default integration selection * refactor: share integration change notifications * refactor: prepare integration mappings before import * refactor: collect integration references during export * refactor: prepare integration ownership changes without a new hook * test: restore registered service model after mocking * test: cover shared integration defaults in Builder * test: include Slack in Agent workspace integration choices * Fix migrations * Stop template visitors from listing the workspace integrations through an application of the template. * Only offer integrations of the user source's integration type when updating a user source. * Say the workspace integration copy means published Application Builder apps and automation workflows. * Use the same spacing under both integration settings sections and enlarge their headings. * Keep the shared application out of automatic snapshot schedules. * Fix test after rebase --------- Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
230 lines
8.6 KiB
TypeScript
230 lines
8.6 KiB
TypeScript
import type { Page } from "@playwright/test";
|
|
import { getClient } from "../../client";
|
|
import { createBuilderElement } from "../../fixtures/builder/builderElement";
|
|
import { createWorkspaceLocalBaserowIntegration } from "../../fixtures/integration";
|
|
import { createDatabase } from "../../fixtures/database/database";
|
|
import { getFieldsForTable } from "../../fixtures/database/field";
|
|
import { listRows } from "../../fixtures/database/rows";
|
|
import { createTable } from "../../fixtures/database/table";
|
|
import type { BuilderPagePage } from "../../pages/builder/builderPagePage";
|
|
import { expect, test } from "../baserowTest";
|
|
|
|
/** Choose a service through the creation modal, without touching the connection. */
|
|
async function openListRowsSource(page: Page) {
|
|
await page.locator('a[data-item-type="data_sources"]').click();
|
|
await page.getByRole("button", { name: "Add new data source" }).click();
|
|
const modal = page.locator(".modal__box:visible").filter({
|
|
has: page.locator(".data-source-form"),
|
|
});
|
|
await modal.getByRole("button", { name: "Choose action..." }).click();
|
|
const menu = page.locator(".grouped-dropdown__context:visible");
|
|
await menu
|
|
.locator(".grouped-menu__navigation")
|
|
.getByRole("menuitem", { name: /^Local Baserow/ })
|
|
.click();
|
|
await menu
|
|
.locator(".grouped-menu__actions")
|
|
.getByRole("menuitem", { name: /^List multiple rows/ })
|
|
.click();
|
|
return modal;
|
|
}
|
|
|
|
/** Create the action in the editor so default selection happens on the backend. */
|
|
async function addCreateRowAction(page: Page, builder: BuilderPagePage) {
|
|
await builder.selectButtonByName("Create shared row");
|
|
const events = await builder.getElementEventsTab();
|
|
await events.getByText("add action").click();
|
|
const menu = page.locator(".event__add-action-context:visible");
|
|
await menu
|
|
.locator(".grouped-menu__navigation")
|
|
.getByRole("menuitem", { name: /^Local Baserow/ })
|
|
.click();
|
|
const created = page.waitForResponse(
|
|
(response) =>
|
|
response.request().method() === "POST" &&
|
|
response.url().endsWith(`/page/${builder.builderPage.id}/workflow_actions/`)
|
|
);
|
|
await menu
|
|
.locator(".grouped-menu__actions")
|
|
.getByRole("menuitem", { name: /^Create a row/ })
|
|
.click();
|
|
const response = await created;
|
|
expect(response.ok()).toBeTruthy();
|
|
const action = await response.json();
|
|
await events.getByText("Create a row", { exact: true }).click();
|
|
return { action, events };
|
|
}
|
|
|
|
test.describe("Builder default workspace integration", () => {
|
|
test.setTimeout(90000);
|
|
test.use({ actionTimeout: 15000 });
|
|
|
|
test("preselects a shared connection and displays its rows", async ({
|
|
page,
|
|
context,
|
|
workspacePage,
|
|
builderPagePage,
|
|
}) => {
|
|
const { user, workspace } = workspacePage;
|
|
const database = await createDatabase(user, "Shared data", workspace);
|
|
const table = await createTable(user, "Contacts", database, [
|
|
["Name"],
|
|
["Ada from the shared connection"],
|
|
]);
|
|
const integration = await createWorkspaceLocalBaserowIntegration(workspace);
|
|
await builderPagePage.goto();
|
|
const modal = await openListRowsSource(page);
|
|
await expect(
|
|
modal.locator(".integration-dropdown .dropdown__selected-text")
|
|
).toHaveText(integration.name);
|
|
const created = page.waitForResponse(
|
|
(response) =>
|
|
response.request().method() === "POST" &&
|
|
response.url().endsWith(
|
|
`/page/${builderPagePage.builderPage.id}/data-sources/`
|
|
)
|
|
);
|
|
await modal.getByRole("button", { name: "Create", exact: true }).click();
|
|
const response = await created;
|
|
expect(response.ok()).toBeTruthy();
|
|
const source = await response.json();
|
|
expect(source.integration_id).toBe(integration.id);
|
|
// Creation opens the edit form, where the table can be configured.
|
|
await modal
|
|
.locator(".form-row .dropdown")
|
|
.first()
|
|
.locator(".dropdown__selected")
|
|
.click();
|
|
await page
|
|
.locator(".select__item:visible")
|
|
.getByText(table.name, { exact: true })
|
|
.click();
|
|
await modal.getByRole("button", { name: "Save", exact: true }).click();
|
|
await expect(modal).toBeHidden();
|
|
const fields = await getFieldsForTable(user, table);
|
|
await createBuilderElement(builderPagePage.builderPage, "table", {
|
|
data_source_id: source.id,
|
|
fields: [
|
|
{
|
|
name: "Name",
|
|
type: "text",
|
|
value: `get('current_record.field_${fields[0].id}')`,
|
|
},
|
|
],
|
|
});
|
|
const { data: grant } = await getClient(user).post(
|
|
`builder/preview/${builderPagePage.builder.id}/grant/`,
|
|
{ path: builderPagePage.builderPage.path }
|
|
);
|
|
const preview = await context.newPage();
|
|
await preview.goto(grant.url);
|
|
await expect(preview.locator(".ab-table tbody")).toContainText(
|
|
"Ada from the shared connection"
|
|
);
|
|
});
|
|
|
|
test("leaves a new data source connection empty when shared choices are ambiguous", async ({
|
|
page,
|
|
workspacePage,
|
|
builderPagePage,
|
|
}) => {
|
|
const first = await createWorkspaceLocalBaserowIntegration(
|
|
workspacePage.workspace,
|
|
"Shared first"
|
|
);
|
|
const second = await createWorkspaceLocalBaserowIntegration(
|
|
workspacePage.workspace,
|
|
"Shared second"
|
|
);
|
|
await builderPagePage.goto();
|
|
const modal = await openListRowsSource(page);
|
|
const dropdown = modal.locator(".integration-dropdown");
|
|
await expect(
|
|
dropdown.locator(".dropdown__selected-placeholder")
|
|
).toHaveText("Choose connection...");
|
|
await modal.getByRole("button", { name: "Create", exact: true }).click();
|
|
await expect(
|
|
modal.getByText("This field is required.", { exact: true })
|
|
).toBeVisible();
|
|
await dropdown.locator(".dropdown__selected").click();
|
|
for (const integration of [first, second]) {
|
|
await expect(
|
|
page
|
|
.locator(".select__item:visible")
|
|
.getByText(integration.name, { exact: true })
|
|
).toBeVisible();
|
|
}
|
|
});
|
|
|
|
for (const ambiguous of [false, true]) {
|
|
test(`a new action ${ambiguous ? "leaves ambiguous shared connections empty" : "preselects and uses the shared connection"}`, async ({
|
|
page,
|
|
context,
|
|
workspacePage,
|
|
builderPagePage,
|
|
}) => {
|
|
const { user, workspace } = workspacePage;
|
|
const integration = await createWorkspaceLocalBaserowIntegration(workspace);
|
|
if (ambiguous) {
|
|
await createWorkspaceLocalBaserowIntegration(
|
|
workspace,
|
|
"Another shared connection"
|
|
);
|
|
}
|
|
const database = await createDatabase(user, "Action results", workspace);
|
|
const table = await createTable(user, "Created rows", database, [["Name"]]);
|
|
await createBuilderElement(builderPagePage.builderPage, "button", {
|
|
value: "'Create shared row'",
|
|
});
|
|
await builderPagePage.goto();
|
|
const { action, events } = await addCreateRowAction(page, builderPagePage);
|
|
const dropdown = events.locator(".integration-dropdown");
|
|
expect(action.service.integration_id).toBe(
|
|
ambiguous ? null : integration.id
|
|
);
|
|
if (ambiguous) {
|
|
await expect(
|
|
dropdown.locator(".dropdown__selected-placeholder")
|
|
).toBeVisible();
|
|
return;
|
|
}
|
|
await expect(dropdown.locator(".dropdown__selected-text")).toHaveText(
|
|
integration.name
|
|
);
|
|
const fields = await getFieldsForTable(user, table);
|
|
// Configure the payload using the connection returned by action creation.
|
|
await getClient(user).patch(`builder/workflow_action/${action.id}/`, {
|
|
service: {
|
|
type: action.service.type,
|
|
integration_id: action.service.integration_id,
|
|
table_id: table.id,
|
|
field_mappings: [
|
|
{
|
|
field_id: fields[0].id,
|
|
value: "'Created through shared connection'",
|
|
enabled: true,
|
|
},
|
|
],
|
|
},
|
|
});
|
|
const { data: grant } = await getClient(user).post(
|
|
`builder/preview/${builderPagePage.builder.id}/grant/`,
|
|
{ path: builderPagePage.builderPage.path }
|
|
);
|
|
const preview = await context.newPage();
|
|
await preview.goto(grant.url);
|
|
const dispatched = preview.waitForResponse(
|
|
(response) =>
|
|
response.request().method() === "POST" &&
|
|
response.url().endsWith(`/${action.id}/dispatch/`)
|
|
);
|
|
await preview.getByRole("button", { name: "Create shared row" }).click();
|
|
const response = await dispatched;
|
|
expect(response.status(), await response.text()).toBe(200);
|
|
await expect.poll(() => listRows(user, table)).toEqual([
|
|
expect.objectContaining({ Name: "Created through shared connection" }),
|
|
]);
|
|
});
|
|
}
|
|
});
|