Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 3s
256 lines
7.9 KiB
TypeScript
256 lines
7.9 KiB
TypeScript
import { createOnePageLayoutTab } from 'test/integration/metadata/suites/page-layout-tab/utils/create-one-page-layout-tab.util';
|
|
import { destroyOnePageLayoutTab } from 'test/integration/metadata/suites/page-layout-tab/utils/destroy-one-page-layout-tab.util';
|
|
import { findPageLayoutTabs } from 'test/integration/metadata/suites/page-layout-tab/utils/find-page-layout-tabs.util';
|
|
import { findPageLayoutWidgets } from 'test/integration/metadata/suites/page-layout-widget/utils/find-page-layout-widgets.util';
|
|
import { updateOnePageLayoutWidget } from 'test/integration/metadata/suites/page-layout-widget/utils/update-one-page-layout-widget.util';
|
|
import { findPageLayouts } from 'test/integration/metadata/suites/page-layout/utils/find-page-layouts.util';
|
|
import { PageLayoutTabLayoutMode, PageLayoutType } from 'twenty-shared/types';
|
|
|
|
const WIDGET_OVERRIDE_GQL_FIELDS = `
|
|
id
|
|
title
|
|
type
|
|
pageLayoutTabId
|
|
conditionalDisplay
|
|
createdAt
|
|
updatedAt
|
|
deletedAt
|
|
`;
|
|
|
|
describe('Page layout widget override behavior', () => {
|
|
let seededPageLayoutId: string;
|
|
let seededWidgetId: string;
|
|
let seededWidgetOriginalPageLayoutTabId: string;
|
|
let seededWidgetOriginalTabLayoutMode: PageLayoutTabLayoutMode;
|
|
let seededWidgetOriginalTitle: string;
|
|
|
|
beforeAll(async () => {
|
|
const { data: layoutsData } = await findPageLayouts({
|
|
expectToFail: false,
|
|
input: undefined,
|
|
});
|
|
|
|
const recordPageLayout = layoutsData.getPageLayouts.find(
|
|
(layout) => layout.type === PageLayoutType.RECORD_PAGE,
|
|
);
|
|
|
|
expect(recordPageLayout).toBeDefined();
|
|
|
|
seededPageLayoutId = recordPageLayout!.id;
|
|
|
|
const { data: tabsData } = await findPageLayoutTabs({
|
|
expectToFail: false,
|
|
input: { pageLayoutId: seededPageLayoutId },
|
|
gqlFields: `
|
|
id
|
|
title
|
|
position
|
|
layoutMode
|
|
pageLayoutId
|
|
`,
|
|
});
|
|
|
|
expect(tabsData.getPageLayoutTabs.length).toBeGreaterThanOrEqual(1);
|
|
|
|
const firstTabId = tabsData.getPageLayoutTabs[0].id;
|
|
|
|
seededWidgetOriginalTabLayoutMode = tabsData.getPageLayoutTabs[0]
|
|
.layoutMode as PageLayoutTabLayoutMode;
|
|
|
|
const { data: widgetsData } = await findPageLayoutWidgets({
|
|
expectToFail: false,
|
|
input: { pageLayoutTabId: firstTabId },
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
|
|
expect(widgetsData.getPageLayoutWidgets.length).toBeGreaterThanOrEqual(1);
|
|
|
|
const firstWidget = widgetsData.getPageLayoutWidgets[0];
|
|
|
|
seededWidgetId = firstWidget.id;
|
|
seededWidgetOriginalPageLayoutTabId = firstWidget.pageLayoutTabId;
|
|
seededWidgetOriginalTitle = firstWidget.title;
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await updateOnePageLayoutWidget({
|
|
expectToFail: false,
|
|
input: {
|
|
id: seededWidgetId,
|
|
pageLayoutTabId: seededWidgetOriginalPageLayoutTabId,
|
|
title: seededWidgetOriginalTitle,
|
|
},
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
});
|
|
|
|
it('should override a seeded widget title and return the overridden value', async () => {
|
|
const overriddenTitle = `Widget Override ${Date.now()}`;
|
|
|
|
const { data } = await updateOnePageLayoutWidget({
|
|
expectToFail: false,
|
|
input: {
|
|
id: seededWidgetId,
|
|
title: overriddenTitle,
|
|
},
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
|
|
expect(data.updatePageLayoutWidget.title).toBe(overriddenTitle);
|
|
});
|
|
|
|
it('should move a seeded widget to another tab through an override', async () => {
|
|
let destinationTabId: string | undefined;
|
|
|
|
try {
|
|
const { data: tabData } = await createOnePageLayoutTab({
|
|
expectToFail: false,
|
|
input: {
|
|
title: `Widget Move Override ${Date.now()}`,
|
|
pageLayoutId: seededPageLayoutId,
|
|
layoutMode: seededWidgetOriginalTabLayoutMode,
|
|
},
|
|
});
|
|
|
|
destinationTabId = tabData.createPageLayoutTab.id;
|
|
|
|
const { data } = await updateOnePageLayoutWidget({
|
|
expectToFail: false,
|
|
input: {
|
|
id: seededWidgetId,
|
|
pageLayoutTabId: destinationTabId,
|
|
},
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
|
|
expect(data.updatePageLayoutWidget.pageLayoutTabId).toBe(
|
|
destinationTabId,
|
|
);
|
|
|
|
const { data: originalTabWidgetsData } = await findPageLayoutWidgets({
|
|
expectToFail: false,
|
|
input: { pageLayoutTabId: seededWidgetOriginalPageLayoutTabId },
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
|
|
expect(
|
|
originalTabWidgetsData.getPageLayoutWidgets.map((widget) => widget.id),
|
|
).not.toContain(seededWidgetId);
|
|
|
|
const { data: destinationTabWidgetsData } = await findPageLayoutWidgets({
|
|
expectToFail: false,
|
|
input: { pageLayoutTabId: destinationTabId },
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
|
|
expect(
|
|
destinationTabWidgetsData.getPageLayoutWidgets.map(
|
|
(widget) => widget.id,
|
|
),
|
|
).toContain(seededWidgetId);
|
|
} finally {
|
|
await updateOnePageLayoutWidget({
|
|
expectToFail: false,
|
|
input: {
|
|
id: seededWidgetId,
|
|
pageLayoutTabId: seededWidgetOriginalPageLayoutTabId,
|
|
},
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
|
|
if (destinationTabId !== undefined) {
|
|
await destroyOnePageLayoutTab({
|
|
expectToFail: false,
|
|
input: { id: destinationTabId },
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
it('should return the overridden title when querying the widget', async () => {
|
|
const { data: tabsData } = await findPageLayoutTabs({
|
|
expectToFail: false,
|
|
input: {
|
|
pageLayoutId: (
|
|
await findPageLayouts({
|
|
expectToFail: false,
|
|
input: undefined,
|
|
})
|
|
).data.getPageLayouts.find(
|
|
(layout) => layout.type === PageLayoutType.RECORD_PAGE,
|
|
)!.id,
|
|
},
|
|
});
|
|
|
|
const { data: widgetsData } = await findPageLayoutWidgets({
|
|
expectToFail: false,
|
|
input: { pageLayoutTabId: tabsData.getPageLayoutTabs[0].id },
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
|
|
const widget = widgetsData.getPageLayoutWidgets.find(
|
|
(widgetItem) => widgetItem.id === seededWidgetId,
|
|
);
|
|
|
|
expect(widget).toBeDefined();
|
|
expect(widget!.title).not.toBe(seededWidgetOriginalTitle);
|
|
});
|
|
|
|
it('should implicitly restore when updating title back to original value', async () => {
|
|
const { data } = await updateOnePageLayoutWidget({
|
|
expectToFail: false,
|
|
input: {
|
|
id: seededWidgetId,
|
|
title: seededWidgetOriginalTitle,
|
|
},
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
|
|
expect(data.updatePageLayoutWidget.title).toBe(seededWidgetOriginalTitle);
|
|
});
|
|
|
|
it('should override conditionalDisplay independently from title', async () => {
|
|
const overriddenTitle = `Multi Override ${Date.now()}`;
|
|
const overriddenConditionalDisplay = {
|
|
fieldMetadataId: '00000000-0000-0000-0000-000000000001',
|
|
operator: 'is',
|
|
value: 'test',
|
|
};
|
|
|
|
const { data: titleData } = await updateOnePageLayoutWidget({
|
|
expectToFail: false,
|
|
input: {
|
|
id: seededWidgetId,
|
|
title: overriddenTitle,
|
|
},
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
|
|
expect(titleData.updatePageLayoutWidget.title).toBe(overriddenTitle);
|
|
|
|
const { data: conditionalData } = await updateOnePageLayoutWidget({
|
|
expectToFail: false,
|
|
input: {
|
|
id: seededWidgetId,
|
|
conditionalDisplay: overriddenConditionalDisplay,
|
|
},
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
|
|
expect(conditionalData.updatePageLayoutWidget.title).toBe(overriddenTitle);
|
|
expect(conditionalData.updatePageLayoutWidget.conditionalDisplay).toEqual(
|
|
overriddenConditionalDisplay,
|
|
);
|
|
|
|
await updateOnePageLayoutWidget({
|
|
expectToFail: false,
|
|
input: {
|
|
id: seededWidgetId,
|
|
title: seededWidgetOriginalTitle,
|
|
conditionalDisplay: null,
|
|
},
|
|
gqlFields: WIDGET_OVERRIDE_GQL_FIELDS,
|
|
});
|
|
});
|
|
});
|