mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* WIP: First approach to scene grid layout * Flex layout * Grid layout rows * Allow passing custom props to scene object renderers * Allow nesting grid layouts * Re-layout nested grid's enclosing grids * Update public/app/features/scenes/components/layout/SceneGridLayout.tsx Co-authored-by: Torkel Ödegaard <torkel@grafana.com> * Review comments * Got rid of flex & grid child layout objects * WIP: Recreating rows behaviour (almost working) * Major progress on rows * remove nested grid example (not supported) * Remove removal damn * Trying to use children directly * Ts fixes * chore: Fix TS * Fix issue when row bboxes when not updated on layout change * Now the tricky part * working * Removing some code * needs more work * Getting some thing working * Getting some thing working * fix toggle row * Starting to work * Fix * Yay it's working * Updates * Updates * Added some sorting of children * Updated comment * Simplify sorting * removed commented code * Updated * Pushed a fix so we can move a panel out from a row and into the parent grid * simplify move logic * Minor simplification * Removed some unnesary code * fixed comment * Removed unnessary condition in findGridSceneParent * remove unnessary if * Simplify toGridCell * removed duplicate if * removed unused code * Adds grid demo with different data scenarios * Make it green * Demo grid with multiple time ranges * Move child atomically * Add tests * Cleanup * Fix unused import Co-authored-by: Torkel Ödegaard <torkel@grafana.com> Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { screen, render } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import { NestedScene } from './NestedScene';
|
|
import { Scene } from './Scene';
|
|
import { SceneCanvasText } from './SceneCanvasText';
|
|
import { SceneFlexLayout } from './layout/SceneFlexLayout';
|
|
|
|
function setup() {
|
|
const scene = new Scene({
|
|
title: 'Hello',
|
|
layout: new SceneFlexLayout({
|
|
children: [
|
|
new NestedScene({
|
|
title: 'Nested title',
|
|
canRemove: true,
|
|
canCollapse: true,
|
|
layout: new SceneFlexLayout({
|
|
children: [new SceneCanvasText({ text: 'SceneCanvasText' })],
|
|
}),
|
|
}),
|
|
],
|
|
}),
|
|
});
|
|
|
|
render(<scene.Component model={scene} />);
|
|
}
|
|
|
|
describe('NestedScene', () => {
|
|
it('Renders heading and layout', () => {
|
|
setup();
|
|
expect(screen.getByRole('heading', { name: 'Nested title' })).toBeInTheDocument();
|
|
expect(screen.getByText('SceneCanvasText')).toBeInTheDocument();
|
|
});
|
|
|
|
it('Can remove', async () => {
|
|
setup();
|
|
screen.getByRole('button', { name: 'Remove scene' }).click();
|
|
expect(screen.queryByRole('heading', { name: 'Nested title' })).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('Can collapse and expand', async () => {
|
|
setup();
|
|
|
|
screen.getByRole('button', { name: 'Collapse scene' }).click();
|
|
expect(screen.queryByText('SceneCanvasText')).not.toBeInTheDocument();
|
|
|
|
screen.getByRole('button', { name: 'Expand scene' }).click();
|
|
expect(screen.getByText('SceneCanvasText')).toBeInTheDocument();
|
|
});
|
|
});
|