Room list: scroll to newly creation section (#33210)
* feat(rls): emit tag when section is created * feat(vm): scroll to newly section tag * feat(view): scroll to new section
This commit is contained in:
@@ -1015,7 +1015,7 @@ describe("RoomListStoreV3", () => {
|
||||
it("emits SECTION_CREATED_EVENT and LISTS_UPDATE_EVENT when section is created", async () => {
|
||||
enableSections();
|
||||
getClientAndRooms();
|
||||
jest.spyOn(sectionModule, "createSection").mockResolvedValue(true);
|
||||
jest.spyOn(sectionModule, "createSection").mockResolvedValue("element.io.section.test-tag");
|
||||
|
||||
const store = new RoomListStoreV3Class(dispatcher);
|
||||
await store.start();
|
||||
@@ -1027,14 +1027,13 @@ describe("RoomListStoreV3", () => {
|
||||
|
||||
await store.createSection();
|
||||
|
||||
expect(sectionCreatedListener).toHaveBeenCalled();
|
||||
expect(listsUpdateListener).toHaveBeenCalled();
|
||||
expect(sectionCreatedListener).toHaveBeenCalledWith("element.io.section.test-tag");
|
||||
});
|
||||
|
||||
it("does not emit when section creation is cancelled", async () => {
|
||||
enableSections();
|
||||
getClientAndRooms();
|
||||
jest.spyOn(sectionModule, "createSection").mockResolvedValue(false);
|
||||
jest.spyOn(sectionModule, "createSection").mockResolvedValue(undefined);
|
||||
|
||||
const store = new RoomListStoreV3Class(dispatcher);
|
||||
await store.start();
|
||||
|
||||
@@ -21,10 +21,9 @@ describe("createSection", () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[false, "", false],
|
||||
[true, "", false],
|
||||
[true, "My Section", true],
|
||||
])("returns %s when shouldCreate=%s and name='%s'", async (shouldCreate, name, expected) => {
|
||||
[false, "", undefined],
|
||||
[true, "", undefined],
|
||||
])("returns undefined when shouldCreate=%s and name='%s'", async (shouldCreate, name, expected) => {
|
||||
jest.spyOn(Modal, "createDialog").mockReturnValue({
|
||||
finished: Promise.resolve([shouldCreate, name]),
|
||||
close: jest.fn(),
|
||||
@@ -34,6 +33,16 @@ describe("createSection", () => {
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
|
||||
it("returns the new tag when section is created", async () => {
|
||||
jest.spyOn(Modal, "createDialog").mockReturnValue({
|
||||
finished: Promise.resolve([true, "My Section"]),
|
||||
close: jest.fn(),
|
||||
} as any);
|
||||
|
||||
const result = await createSection();
|
||||
expect(result).toMatch(/^element\.io\.section\./);
|
||||
});
|
||||
|
||||
it("opens the CreateSectionDialog", async () => {
|
||||
const createDialogSpy = jest.spyOn(Modal, "createDialog").mockReturnValue({
|
||||
finished: Promise.resolve([false, ""]),
|
||||
|
||||
Reference in New Issue
Block a user