Add a new graphql mutation in the pageLayout resolver to handle page layout update with tabs and widgets (#14612)

Add a new graphql mutation in the pageLayout resolver to handle page
layout update with tabs and widgets.

Later we will add validation inside the service to check if the page
layout tab structure is correct (for instance check widgets don't
overlap or aren't out of the grid, or to check that they have a correct
configuration ...).

This mutation will be plugged to the save action of the dashboards in
the frontend.
This commit is contained in:
Raphaël Bosi
2025-09-23 11:00:36 +02:00
committed by GitHub
parent fbd3286792
commit 7cb294169d
20 changed files with 1858 additions and 8 deletions
@@ -0,0 +1,77 @@
import { computeDiffBetweenObjects } from '../compute-diff-between-objects';
describe('computeDiffBetweenObjects', () => {
it('should return the correct diff', () => {
const existingObjects = [
{ id: '1', name: 'Object 1' },
{ id: '2', name: 'Object 2' },
];
const receivedObjects = [
{ id: '1', name: 'Object 1' },
{ id: '3', name: 'Object 3' },
];
const diff = computeDiffBetweenObjects({
existingObjects,
receivedObjects,
propertiesToCompare: ['name'],
});
expect(diff).toEqual({
toCreate: [{ id: '3', name: 'Object 3' }],
toUpdate: [],
idsToDelete: ['2'],
});
});
it('should return the correct diff when the properties to compare are empty', () => {
const existingObjects = [{ id: '1', name: 'Object 1' }];
const receivedObjects = [{ id: '1', name: 'Object 1' }];
const diff = computeDiffBetweenObjects({
existingObjects,
receivedObjects,
propertiesToCompare: [],
});
expect(diff).toEqual({
toCreate: [],
toUpdate: [],
idsToDelete: [],
});
});
it('should return the correct diff when the existing objects are empty', () => {
const existingObjects: { id: string; name: string }[] = [];
const receivedObjects = [{ id: '1', name: 'Object 1' }];
const diff = computeDiffBetweenObjects({
existingObjects,
receivedObjects,
propertiesToCompare: ['name'],
});
expect(diff).toEqual({
toCreate: [{ id: '1', name: 'Object 1' }],
toUpdate: [],
idsToDelete: [],
});
});
it('should return the correct diff when the received objects are empty', () => {
const existingObjects = [{ id: '1', name: 'Object 1' }];
const receivedObjects: { id: string; name: string }[] = [];
const diff = computeDiffBetweenObjects({
existingObjects,
receivedObjects,
propertiesToCompare: ['name'],
});
expect(diff).toEqual({
toCreate: [],
toUpdate: [],
idsToDelete: ['1'],
});
});
});