Improve widget buttons behaviour and layout (#8734)
* Improve widet buttons behaviour and layout Relates to vector-im/element-web#20506 See PSC-79 Signed-off-by: Michael Weimann <michaelw@matrix.org> * Add AppTile tests
This commit is contained in:
parent
91cbd4dc8a
commit
3174cf2606
4 changed files with 95 additions and 46 deletions
|
@ -19,6 +19,8 @@ import TestRenderer from "react-test-renderer";
|
|||
import { jest } from "@jest/globals";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { MatrixWidgetType } from "matrix-widget-api";
|
||||
import { mount, ReactWrapper } from "enzyme";
|
||||
import { Optional } from "matrix-events-sdk";
|
||||
|
||||
import RightPanel from "../../../../src/components/structures/RightPanel";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
|
@ -307,4 +309,51 @@ describe("AppTile", () => {
|
|||
await RightPanelStore.instance.onNotReady();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe("for a pinned widget", () => {
|
||||
let wrapper: ReactWrapper;
|
||||
let moveToContainerSpy;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = mount((
|
||||
<MatrixClientContext.Provider value={cli}>
|
||||
<AppTile
|
||||
key={app1.id}
|
||||
app={app1}
|
||||
room={r1}
|
||||
/>
|
||||
</MatrixClientContext.Provider>
|
||||
));
|
||||
|
||||
moveToContainerSpy = jest.spyOn(WidgetLayoutStore.instance, 'moveToContainer');
|
||||
});
|
||||
|
||||
it("clicking 'minimise' should send the widget to the right", () => {
|
||||
const minimiseButton = wrapper.find('.mx_AppTileMenuBar_iconButton_minimise');
|
||||
minimiseButton.first().simulate('click');
|
||||
expect(moveToContainerSpy).toHaveBeenCalledWith(r1, app1, Container.Right);
|
||||
});
|
||||
|
||||
it("clicking 'maximise' should send the widget to the center", () => {
|
||||
const minimiseButton = wrapper.find('.mx_AppTileMenuBar_iconButton_maximise');
|
||||
minimiseButton.first().simulate('click');
|
||||
expect(moveToContainerSpy).toHaveBeenCalledWith(r1, app1, Container.Center);
|
||||
});
|
||||
|
||||
describe("for a maximised (centered) widget", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(WidgetLayoutStore.instance, 'isInContainer').mockImplementation(
|
||||
(room: Optional<Room>, widget: IApp, container: Container) => {
|
||||
return room === r1 && widget === app1 && container === Container.Center;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("clicking 'un-maximise' should send the widget to the top", () => {
|
||||
const unMaximiseButton = wrapper.find('.mx_AppTileMenuBar_iconButton_collapse');
|
||||
unMaximiseButton.first().simulate('click');
|
||||
expect(moveToContainerSpy).toHaveBeenCalledWith(r1, app1, Container.Top);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue