## Description Core features of Auto Layout and mobile responsiveness, hidden under a feature flag. > Add a TL;DR when description is extra long (helps content team) Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video ## Type of change > Please delete options that are not relevant. - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? > Manual regression and sanity tests for all fixed canvas functionality. - Manual - Jest - Cypress ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] PR is being merged under a feature flag --------- Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com> Co-authored-by: Arsalan <arsalanyaldram0211@outlook.com> Co-authored-by: Aswath K <aswath.sana@gmail.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
96 lines
3.0 KiB
TypeScript
96 lines
3.0 KiB
TypeScript
import "@testing-library/jest-dom";
|
|
import { render } from "@testing-library/react";
|
|
import "jest-styled-components";
|
|
import React from "react";
|
|
import renderer from "react-test-renderer";
|
|
import { RenderModes } from "constants/WidgetConstants";
|
|
import AutoHeightContainer from "./AutoHeightContainer";
|
|
|
|
const onHeightUpdate = jest.fn();
|
|
const DUMMY_WIDGET = {
|
|
bottomRow: 0,
|
|
isLoading: false,
|
|
leftColumn: 0,
|
|
parentColumnSpace: 0,
|
|
parentRowSpace: 0,
|
|
renderMode: RenderModes.CANVAS,
|
|
rightColumn: 0,
|
|
topRow: 0,
|
|
type: "SKELETON_WIDGET",
|
|
version: 2,
|
|
widgetId: "",
|
|
widgetName: "",
|
|
};
|
|
|
|
describe("<AutoHeightContainer />", () => {
|
|
it("should wrap the children in a div whose height is auto.", async () => {
|
|
const tree = renderer
|
|
.create(
|
|
<AutoHeightContainer
|
|
isAutoHeightWithLimits={false}
|
|
maxDynamicHeight={0}
|
|
minDynamicHeight={0}
|
|
onHeightUpdate={onHeightUpdate}
|
|
widgetHeightInPixels={200}
|
|
widgetProps={DUMMY_WIDGET}
|
|
>
|
|
<div data-testid="test" />
|
|
</AutoHeightContainer>,
|
|
)
|
|
.toJSON();
|
|
expect(tree).toHaveStyleRule("height", "100%");
|
|
});
|
|
|
|
describe("when isAutoHeightWithLimits is false.", () => {
|
|
it("should wrap the children in a simple div with class auto-height-container", async () => {
|
|
const getTestComponent = () => (
|
|
<AutoHeightContainer
|
|
isAutoHeightWithLimits={false}
|
|
maxDynamicHeight={0}
|
|
minDynamicHeight={0}
|
|
onHeightUpdate={onHeightUpdate}
|
|
widgetHeightInPixels={200}
|
|
widgetProps={DUMMY_WIDGET}
|
|
>
|
|
<div data-testid="test" />
|
|
</AutoHeightContainer>
|
|
);
|
|
const component = getTestComponent();
|
|
const renderResult = render(component);
|
|
const child = await renderResult.findByTestId("test");
|
|
expect(
|
|
child.parentElement?.classList.contains("auto-height-container"),
|
|
).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("when isAutoHeightWithLimits is true", () => {
|
|
it("should wrap the children in a div of class auto-height-container and then a div with class auto-height-scroll-container", async () => {
|
|
const getTestComponent = () => (
|
|
<AutoHeightContainer
|
|
isAutoHeightWithLimits
|
|
maxDynamicHeight={0}
|
|
minDynamicHeight={0}
|
|
onHeightUpdate={onHeightUpdate}
|
|
widgetHeightInPixels={200}
|
|
widgetProps={DUMMY_WIDGET}
|
|
>
|
|
<div data-testid="test" />
|
|
</AutoHeightContainer>
|
|
);
|
|
const component = getTestComponent();
|
|
const renderResult = render(component);
|
|
const child = await renderResult.findByTestId("test");
|
|
expect(child.parentElement?.tagName).toBe("DIV");
|
|
expect(
|
|
child.parentElement?.classList.contains("auto-height-container"),
|
|
).toBe(true);
|
|
expect(
|
|
child.parentElement?.parentElement?.parentElement?.classList.contains(
|
|
"auto-height-scroll-container",
|
|
),
|
|
).toBe(true);
|
|
});
|
|
});
|
|
});
|