PromucFlow_constructor/app/client/src/widgets/Tabs/TabsWidget.test.tsx
Ashok Kumar M 8c8141650a
Feature: Widget grouping Phase I (Multi select and Bulk Delete) + Canvas Enhancements. (#4219)
* Feature: Canvas layer enhancements(DIP)

* feedback fixes

* fixing build

* dip

* dip

* dip

* fixing build

* dip

* dev fixes

* dip

* Fixing top bottom resize handles

* dip

* reposition widget name on top edges.

* dip

* dip

* dip

* dip

* renaming selectedWidget to lastSelectedWidget

* code clean up

* Fixing list widget as per grid scale.

* Fixing existing specs.

* Adding migration test cases.

* dip

* FIxing proppane in modal.

* fixing modal z-indedx.

* fix for modal name.

* dip

* dip

* dip

* adding test cases for hotkeys.

* dip

* dip

* fixing build

* Trying some performance improvements for jests.

* 17 mins with runinband lets try without it.

* minor bug fixes.

* code clean up

* save migrated app on fetch.

* fixing few cypress tests

* fixing cypress tests

* fixing cypress tests.

* fixing cypress

* updated DSL

* Addressing code review comments.

* test fails

* dip

* eslint fixes.

* fixing debugger cypress tests.

* updating latest page version.

* updating migration changes to cypress dsl's.

* updating chart data fixes for cypress tests.

Co-authored-by: Apple <nandan@thinkify.io>
2021-05-18 23:59:39 +05:30

70 lines
2.4 KiB
TypeScript

import {
buildChildren,
widgetCanvasFactory,
} from "test/factories/WidgetFactoryUtils";
import { render, fireEvent } from "test/testUtils";
import Canvas from "pages/Editor/Canvas";
import React from "react";
import { MockPageDSL } from "test/testCommon";
describe("Tabs widget functional cases", () => {
it("Should render 2 tabs by default", () => {
const children: any = buildChildren([{ type: "TABS_WIDGET" }]);
const dsl: any = widgetCanvasFactory.build({
children,
});
const component = render(
<MockPageDSL dsl={dsl}>
<Canvas dsl={dsl} />
</MockPageDSL>,
);
const tab1 = component.queryByText("Tab 1");
const tab2 = component.queryByText("Tab 2");
expect(tab1).toBeDefined();
expect(tab2).toBeDefined();
});
it("Should render components inside tabs by default", () => {
const tab1Children = buildChildren([
{ type: "SWITCH_WIDGET", label: "Tab1 Switch" },
{ type: "CHECKBOX_WIDGET", label: "Tab1 Checkbox" },
]);
const tab2Children = buildChildren([
{ type: "INPUT_WIDGET", text: "Tab2 Text" },
{ type: "BUTTON_WIDGET", label: "Tab2 Button" },
]);
const children: any = buildChildren([{ type: "TABS_WIDGET" }]);
children[0].children[0].children = tab1Children;
children[0].children[1].children = tab2Children;
const dsl: any = widgetCanvasFactory.build({
children,
});
const component = render(
<MockPageDSL dsl={dsl}>
<Canvas dsl={dsl} />
</MockPageDSL>,
);
const tab1 = component.queryByText("Tab 1");
const tab2: any = component.queryByText("Tab 2");
expect(tab1).toBeDefined();
expect(tab2).toBeDefined();
let tab1Switch = component.queryByText("Tab1 Switch");
let tab1Checkbox = component.queryByText("Tab1 Checkbox");
let tab2Input = component.queryByText("Tab2 Text");
let tab2Button = component.queryByText("Tab2 Button");
expect(tab1Switch).toBeDefined();
expect(tab1Checkbox).toBeDefined();
expect(tab2Input).toBeNull();
expect(tab2Button).toBeNull();
fireEvent.click(tab2);
tab1Switch = component.queryByText("Tab1 Switch");
tab1Checkbox = component.queryByText("Tab1 Checkbox");
tab2Input = component.queryByText("Tab2 Text");
tab2Button = component.queryByText("Tab2 Button");
expect(tab1Switch).toBeNull();
expect(tab1Checkbox).toBeNull();
expect(tab2Input).toBeDefined();
expect(tab2Button).toBeDefined();
});
});