2022-06-15 14:14:05 +00:00
|
|
|
|
/*
|
|
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
|
|
|
|
|
import { MatrixClient } from "../../global";
|
2023-01-10 23:29:56 +00:00
|
|
|
|
import { HomeserverInstance } from "../../plugins/utils/homeserver";
|
2022-06-15 14:14:05 +00:00
|
|
|
|
import Chainable = Cypress.Chainable;
|
|
|
|
|
import Loggable = Cypress.Loggable;
|
|
|
|
|
import Timeoutable = Cypress.Timeoutable;
|
|
|
|
|
import Withinable = Cypress.Withinable;
|
|
|
|
|
import Shadow = Cypress.Shadow;
|
2023-11-07 14:00:24 +00:00
|
|
|
|
import { Filter } from "../../support/settings";
|
2022-06-15 14:14:05 +00:00
|
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
|
|
|
namespace Cypress {
|
|
|
|
|
interface Chainable {
|
|
|
|
|
roomHeaderName(
|
|
|
|
|
options?: Partial<Loggable & Timeoutable & Withinable & Shadow>,
|
|
|
|
|
): Chainable<JQuery<HTMLElement>>;
|
2022-07-06 12:07:10 +00:00
|
|
|
|
startDM(name: string): Chainable<void>;
|
2022-06-15 14:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add(
|
|
|
|
|
"roomHeaderName",
|
|
|
|
|
(options?: Partial<Loggable & Timeoutable & Withinable & Shadow>): Chainable<JQuery<HTMLElement>> => {
|
2023-08-01 07:32:53 +00:00
|
|
|
|
return cy.get(".mx_LegacyRoomHeader_nametext", options);
|
2022-06-15 14:14:05 +00:00
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
2022-07-06 12:07:10 +00:00
|
|
|
|
Cypress.Commands.add("startDM", (name: string) => {
|
|
|
|
|
cy.openSpotlightDialog().within(() => {
|
|
|
|
|
cy.spotlightFilter(Filter.People);
|
|
|
|
|
cy.spotlightSearch().clear().type(name);
|
2022-08-11 22:26:25 +00:00
|
|
|
|
cy.wait(1000); // wait for the dialog code to settle
|
2022-07-06 12:07:10 +00:00
|
|
|
|
cy.get(".mx_Spinner").should("not.exist");
|
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", name);
|
|
|
|
|
cy.spotlightResults().eq(0).click();
|
|
|
|
|
});
|
2022-08-04 06:19:52 +00:00
|
|
|
|
// send first message to start DM
|
2023-04-17 14:06:20 +00:00
|
|
|
|
cy.findByRole("textbox", { name: "Send a message…" }).should("have.focus").type("Hey!{enter}");
|
2022-10-12 17:59:07 +00:00
|
|
|
|
// The DM room is created at this point, this can take a little bit of time
|
2023-04-17 14:06:20 +00:00
|
|
|
|
cy.get(".mx_EventTile_body", { timeout: 30000 }).findByText("Hey!");
|
|
|
|
|
cy.findByRole("group", { name: "People" }).findByText(name);
|
2022-07-06 12:07:10 +00:00
|
|
|
|
});
|
|
|
|
|
|
2022-06-15 14:14:05 +00:00
|
|
|
|
describe("Spotlight", () => {
|
2023-01-10 23:29:56 +00:00
|
|
|
|
let homeserver: HomeserverInstance;
|
2022-06-15 14:14:05 +00:00
|
|
|
|
|
|
|
|
|
const bot1Name = "BotBob";
|
|
|
|
|
let bot1: MatrixClient;
|
|
|
|
|
|
|
|
|
|
const bot2Name = "ByteBot";
|
|
|
|
|
let bot2: MatrixClient;
|
|
|
|
|
|
|
|
|
|
const room1Name = "247";
|
|
|
|
|
let room1Id: string;
|
|
|
|
|
|
|
|
|
|
const room2Name = "Lounge";
|
|
|
|
|
let room2Id: string;
|
|
|
|
|
|
2022-07-20 10:48:31 +00:00
|
|
|
|
const room3Name = "Public";
|
|
|
|
|
let room3Id: string;
|
|
|
|
|
|
2022-06-15 14:14:05 +00:00
|
|
|
|
beforeEach(() => {
|
2023-01-10 23:29:56 +00:00
|
|
|
|
cy.startHomeserver("default").then((data) => {
|
|
|
|
|
homeserver = data;
|
|
|
|
|
cy.initTestUser(homeserver, "Jim")
|
2022-06-15 14:14:05 +00:00
|
|
|
|
.then(() =>
|
2023-01-10 23:29:56 +00:00
|
|
|
|
cy.getBot(homeserver, { displayName: bot1Name }).then((_bot1) => {
|
2022-06-15 14:14:05 +00:00
|
|
|
|
bot1 = _bot1;
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.then(() =>
|
2023-01-10 23:29:56 +00:00
|
|
|
|
cy.getBot(homeserver, { displayName: bot2Name }).then((_bot2) => {
|
2022-06-15 14:14:05 +00:00
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
|
bot2 = _bot2;
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.then(() =>
|
|
|
|
|
cy.window({ log: false }).then(({ matrixcs: { Visibility } }) => {
|
2023-05-15 10:37:24 +00:00
|
|
|
|
cy.createRoom({ name: room1Name, visibility: Visibility.Public }).then(async (_room1Id) => {
|
2022-06-15 14:14:05 +00:00
|
|
|
|
room1Id = _room1Id;
|
2023-05-15 10:37:24 +00:00
|
|
|
|
await bot1.joinRoom(room1Id);
|
2022-06-15 14:14:05 +00:00
|
|
|
|
});
|
2022-07-20 10:48:31 +00:00
|
|
|
|
bot2.createRoom({ name: room2Name, visibility: Visibility.Public }).then(
|
|
|
|
|
({ room_id: _room2Id }) => {
|
2022-06-15 14:14:05 +00:00
|
|
|
|
room2Id = _room2Id;
|
2022-07-20 10:48:31 +00:00
|
|
|
|
bot2.invite(room2Id, bot1.getUserId());
|
|
|
|
|
},
|
2022-12-12 11:24:14 +00:00
|
|
|
|
);
|
2022-07-20 10:48:31 +00:00
|
|
|
|
bot2.createRoom({
|
|
|
|
|
name: room3Name,
|
2022-06-15 14:14:05 +00:00
|
|
|
|
visibility: Visibility.Public,
|
2022-07-20 10:48:31 +00:00
|
|
|
|
initial_state: [
|
2022-12-12 11:24:14 +00:00
|
|
|
|
{
|
2022-07-20 10:48:31 +00:00
|
|
|
|
type: "m.room.history_visibility",
|
|
|
|
|
state_key: "",
|
|
|
|
|
content: {
|
|
|
|
|
history_visibility: "world_readable",
|
|
|
|
|
},
|
2022-12-12 11:24:14 +00:00
|
|
|
|
},
|
2022-07-20 10:48:31 +00:00
|
|
|
|
],
|
|
|
|
|
}).then(({ room_id: _room3Id }) => {
|
|
|
|
|
room3Id = _room3Id;
|
|
|
|
|
bot2.invite(room3Id, bot1.getUserId());
|
|
|
|
|
});
|
2022-06-15 14:14:05 +00:00
|
|
|
|
}),
|
|
|
|
|
)
|
2023-05-15 10:37:24 +00:00
|
|
|
|
.then(() => {
|
|
|
|
|
cy.visit("/#/room/" + room1Id);
|
|
|
|
|
cy.get(".mx_RoomSublist_skeletonUI").should("not.exist");
|
|
|
|
|
});
|
2022-06-15 14:14:05 +00:00
|
|
|
|
});
|
2023-05-18 21:44:37 +00:00
|
|
|
|
// wait for the room to have the right name
|
2023-08-01 07:32:53 +00:00
|
|
|
|
cy.get(".mx_LegacyRoomHeader").within(() => {
|
2023-05-18 21:44:37 +00:00
|
|
|
|
cy.findByText(room1Name);
|
|
|
|
|
});
|
2022-06-15 14:14:05 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
2022-06-30 09:44:56 +00:00
|
|
|
|
cy.visit("/#/home");
|
2023-01-10 23:29:56 +00:00
|
|
|
|
cy.stopHomeserver(homeserver);
|
2022-06-15 14:14:05 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should be able to add and remove filters via keyboard", () => {
|
|
|
|
|
cy.openSpotlightDialog().within(() => {
|
2023-05-18 21:44:37 +00:00
|
|
|
|
cy.wait(1000); // wait for the dialog to settle, otherwise our keypresses might race with an update
|
|
|
|
|
|
2023-08-21 09:39:20 +00:00
|
|
|
|
// initially, public spaces should be highlighted (because there are no other suggestions)
|
|
|
|
|
cy.get("#mx_SpotlightDialog_button_explorePublicSpaces").should("have.attr", "aria-selected", "true");
|
2023-05-18 21:44:37 +00:00
|
|
|
|
|
2023-08-21 09:39:20 +00:00
|
|
|
|
// hitting enter should enable the public rooms filter
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightSearch().type("{enter}");
|
2023-08-21 09:39:20 +00:00
|
|
|
|
cy.get(".mx_SpotlightDialog_filter").should("contain", "Public spaces");
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightSearch().type("{backspace}");
|
|
|
|
|
cy.get(".mx_SpotlightDialog_filter").should("not.exist");
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(200); // Again, wait to settle so keypresses arrive correctly
|
2022-06-15 14:14:05 +00:00
|
|
|
|
|
|
|
|
|
cy.spotlightSearch().type("{downArrow}");
|
2023-08-21 09:39:20 +00:00
|
|
|
|
cy.get("#mx_SpotlightDialog_button_explorePublicRooms").should("have.attr", "aria-selected", "true");
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightSearch().type("{enter}");
|
2023-08-21 09:39:20 +00:00
|
|
|
|
cy.get(".mx_SpotlightDialog_filter").should("contain", "Public rooms");
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightSearch().type("{backspace}");
|
|
|
|
|
cy.get(".mx_SpotlightDialog_filter").should("not.exist");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should find joined rooms", () => {
|
|
|
|
|
cy.openSpotlightDialog()
|
|
|
|
|
.within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightSearch().clear().type(room1Name);
|
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", room1Name);
|
|
|
|
|
cy.spotlightResults().eq(0).click();
|
|
|
|
|
cy.url().should("contain", room1Id);
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.roomHeaderName().should("contain", room1Name);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should find known public rooms", () => {
|
|
|
|
|
cy.openSpotlightDialog()
|
|
|
|
|
.within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightFilter(Filter.PublicRooms);
|
|
|
|
|
cy.spotlightSearch().clear().type(room1Name);
|
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", room1Name);
|
2022-07-20 10:48:31 +00:00
|
|
|
|
cy.spotlightResults().eq(0).should("contain", "View");
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightResults().eq(0).click();
|
|
|
|
|
cy.url().should("contain", room1Id);
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.roomHeaderName().should("contain", room1Name);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should find unknown public rooms", () => {
|
|
|
|
|
cy.openSpotlightDialog()
|
|
|
|
|
.within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightFilter(Filter.PublicRooms);
|
|
|
|
|
cy.spotlightSearch().clear().type(room2Name);
|
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", room2Name);
|
2022-07-20 10:48:31 +00:00
|
|
|
|
cy.spotlightResults().eq(0).should("contain", "Join");
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightResults().eq(0).click();
|
|
|
|
|
cy.url().should("contain", room2Id);
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
2022-07-29 14:25:28 +00:00
|
|
|
|
cy.get(".mx_RoomView_MessageList").should("have.length", 1);
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.roomHeaderName().should("contain", room2Name);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-07-20 10:48:31 +00:00
|
|
|
|
it("should find unknown public world readable rooms", () => {
|
|
|
|
|
cy.openSpotlightDialog()
|
|
|
|
|
.within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-07-20 10:48:31 +00:00
|
|
|
|
cy.spotlightFilter(Filter.PublicRooms);
|
|
|
|
|
cy.spotlightSearch().clear().type(room3Name);
|
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", room3Name);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", "View");
|
|
|
|
|
cy.spotlightResults().eq(0).click();
|
|
|
|
|
cy.url().should("contain", room3Id);
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
2023-04-17 14:06:20 +00:00
|
|
|
|
cy.findByRole("button", { name: "Join the discussion" }).click();
|
2022-07-20 10:48:31 +00:00
|
|
|
|
cy.roomHeaderName().should("contain", room3Name);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-15 14:14:05 +00:00
|
|
|
|
// TODO: We currently can’t test finding rooms on other homeservers/other protocols
|
|
|
|
|
// We obviously don’t have federation or bridges in cypress tests
|
2023-03-01 15:23:35 +00:00
|
|
|
|
it.skip("should find unknown public rooms on other homeservers", () => {
|
|
|
|
|
cy.openSpotlightDialog()
|
|
|
|
|
.within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2023-03-01 15:23:35 +00:00
|
|
|
|
cy.spotlightFilter(Filter.PublicRooms);
|
|
|
|
|
cy.spotlightSearch().clear().type(room3Name);
|
|
|
|
|
cy.get("[aria-haspopup=true][role=button]").click();
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.contains(".mx_GenericDropdownMenu_Option--header", "matrix.org")
|
|
|
|
|
.next("[role=menuitemradio]")
|
|
|
|
|
.click();
|
|
|
|
|
cy.wait(3_600_000);
|
|
|
|
|
})
|
|
|
|
|
.then(() =>
|
|
|
|
|
cy.spotlightDialog().within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2023-03-01 15:23:35 +00:00
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", room3Name);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", room3Id);
|
|
|
|
|
}),
|
|
|
|
|
);
|
2022-06-15 14:14:05 +00:00
|
|
|
|
});
|
2023-03-01 15:23:35 +00:00
|
|
|
|
|
2022-06-15 14:14:05 +00:00
|
|
|
|
it("should find known people", () => {
|
|
|
|
|
cy.openSpotlightDialog()
|
|
|
|
|
.within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightFilter(Filter.People);
|
|
|
|
|
cy.spotlightSearch().clear().type(bot1Name);
|
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", bot1Name);
|
|
|
|
|
cy.spotlightResults().eq(0).click();
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.roomHeaderName().should("contain", bot1Name);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2023-10-13 08:58:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* Search sends the correct query to Synapse.
|
|
|
|
|
* Synapse doesn't return the user in the result list.
|
|
|
|
|
* Waiting for the profile to be available via APIs before the tests didn't help.
|
|
|
|
|
*
|
|
|
|
|
* https://github.com/matrix-org/synapse/issues/16472
|
|
|
|
|
*/
|
|
|
|
|
it.skip("should find unknown people", () => {
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.openSpotlightDialog()
|
|
|
|
|
.within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightFilter(Filter.People);
|
|
|
|
|
cy.spotlightSearch().clear().type(bot2Name);
|
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
2023-07-18 08:26:54 +00:00
|
|
|
|
cy.spotlightResults().eq(0).should("contain", bot2Name);
|
|
|
|
|
cy.spotlightResults().eq(0).click();
|
2022-06-15 14:14:05 +00:00
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.roomHeaderName().should("contain", bot2Name);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-30 09:44:56 +00:00
|
|
|
|
it("should find group DMs by usernames or user ids", () => {
|
|
|
|
|
// First we want to share a room with both bots to ensure we’ve got their usernames cached
|
|
|
|
|
cy.inviteUser(room1Id, bot2.getUserId());
|
|
|
|
|
|
|
|
|
|
// Starting a DM with ByteBot (will be turned into a group dm later)
|
|
|
|
|
cy.openSpotlightDialog().within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-06-30 09:44:56 +00:00
|
|
|
|
cy.spotlightFilter(Filter.People);
|
|
|
|
|
cy.spotlightSearch().clear().type(bot2Name);
|
2023-07-18 08:26:54 +00:00
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", bot2Name);
|
|
|
|
|
cy.spotlightResults().eq(0).click();
|
2022-06-30 09:44:56 +00:00
|
|
|
|
});
|
|
|
|
|
|
2022-08-04 06:19:52 +00:00
|
|
|
|
// Send first message to actually start DM
|
|
|
|
|
cy.roomHeaderName().should("contain", bot2Name);
|
2023-04-17 14:06:20 +00:00
|
|
|
|
cy.findByRole("textbox", { name: "Send a message…" }).type("Hey!{enter}");
|
2022-08-04 06:19:52 +00:00
|
|
|
|
|
|
|
|
|
// Assert DM exists by checking for the first message and the room being in the room list
|
2022-10-12 17:59:07 +00:00
|
|
|
|
cy.contains(".mx_EventTile_body", "Hey!", { timeout: 30000 });
|
2023-04-17 14:06:20 +00:00
|
|
|
|
cy.findByRole("group", { name: "People" }).should("contain", bot2Name);
|
2022-08-04 06:19:52 +00:00
|
|
|
|
|
2022-06-30 09:44:56 +00:00
|
|
|
|
// Invite BotBob into existing DM with ByteBot
|
2022-08-22 10:11:24 +00:00
|
|
|
|
cy.getDmRooms(bot2.getUserId())
|
|
|
|
|
.should("have.length", 1)
|
|
|
|
|
.then((dmRooms) => cy.getClient().then((client) => client.getRoom(dmRooms[0])))
|
|
|
|
|
.then((groupDm) => {
|
|
|
|
|
cy.inviteUser(groupDm.roomId, bot1.getUserId());
|
|
|
|
|
cy.roomHeaderName().should(($element) => expect($element.get(0).innerText).contains(groupDm.name));
|
2023-04-17 14:06:20 +00:00
|
|
|
|
cy.findByRole("group", { name: "People" }).should(($element) =>
|
2022-08-22 10:11:24 +00:00
|
|
|
|
expect($element.get(0).innerText).contains(groupDm.name),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Search for BotBob by id, should return group DM and user
|
|
|
|
|
cy.openSpotlightDialog().within(() => {
|
|
|
|
|
cy.spotlightFilter(Filter.People);
|
|
|
|
|
cy.spotlightSearch().clear().type(bot1.getUserId());
|
|
|
|
|
cy.wait(1000); // wait for the dialog code to settle
|
2023-07-18 08:26:54 +00:00
|
|
|
|
cy.spotlightResults().should("have.length", 2);
|
2022-09-30 08:54:47 +00:00
|
|
|
|
cy.contains(
|
|
|
|
|
".mx_SpotlightDialog_section.mx_SpotlightDialog_results .mx_SpotlightDialog_option",
|
|
|
|
|
groupDm.name,
|
2023-07-18 08:26:54 +00:00
|
|
|
|
);
|
2022-08-22 10:11:24 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Search for ByteBot by id, should return group DM and user
|
|
|
|
|
cy.openSpotlightDialog().within(() => {
|
|
|
|
|
cy.spotlightFilter(Filter.People);
|
|
|
|
|
cy.spotlightSearch().clear().type(bot2.getUserId());
|
|
|
|
|
cy.wait(1000); // wait for the dialog code to settle
|
2023-07-18 08:26:54 +00:00
|
|
|
|
cy.spotlightResults().should("have.length", 2);
|
2022-09-30 08:54:47 +00:00
|
|
|
|
cy.contains(
|
|
|
|
|
".mx_SpotlightDialog_section.mx_SpotlightDialog_results .mx_SpotlightDialog_option",
|
|
|
|
|
groupDm.name,
|
2023-07-18 08:26:54 +00:00
|
|
|
|
);
|
2022-08-22 10:11:24 +00:00
|
|
|
|
});
|
2022-06-30 09:44:56 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-11 22:26:25 +00:00
|
|
|
|
// Test against https://github.com/vector-im/element-web/issues/22851
|
|
|
|
|
it("should show each person result only once", () => {
|
|
|
|
|
cy.openSpotlightDialog().within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-08-11 22:26:25 +00:00
|
|
|
|
cy.spotlightFilter(Filter.People);
|
|
|
|
|
|
|
|
|
|
// 2 rounds of search to simulate the bug conditions. Specifically, the first search
|
|
|
|
|
// should have 1 result (not 2) and the second search should also have 1 result (instead
|
|
|
|
|
// of the super buggy 3 described by https://github.com/vector-im/element-web/issues/22851)
|
|
|
|
|
//
|
|
|
|
|
// We search for user ID to trigger the profile lookup within the dialog.
|
|
|
|
|
for (let i = 0; i < 2; i++) {
|
|
|
|
|
cy.log("Iteration: " + i);
|
|
|
|
|
cy.spotlightSearch().clear().type(bot1.getUserId());
|
|
|
|
|
cy.wait(1000); // wait for the dialog code to settle
|
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", bot1.getUserId());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-15 14:14:05 +00:00
|
|
|
|
it("should allow opening group chat dialog", () => {
|
|
|
|
|
cy.openSpotlightDialog()
|
|
|
|
|
.within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightFilter(Filter.People);
|
|
|
|
|
cy.spotlightSearch().clear().type(bot2Name);
|
2023-07-18 08:26:54 +00:00
|
|
|
|
cy.wait(3000); // wait for the dialog code to settle
|
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
cy.spotlightResults().eq(0).should("contain", bot2Name);
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.get(".mx_SpotlightDialog_startGroupChat").should("contain", "Start a group chat");
|
|
|
|
|
cy.get(".mx_SpotlightDialog_startGroupChat").click();
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
2023-04-17 14:06:20 +00:00
|
|
|
|
cy.findByRole("dialog").should("contain", "Direct Messages");
|
2022-06-15 14:14:05 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-07-06 12:07:10 +00:00
|
|
|
|
it("should close spotlight after starting a DM", () => {
|
|
|
|
|
cy.startDM(bot1Name);
|
|
|
|
|
cy.get(".mx_SpotlightDialog").should("have.length", 0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("should show the same user only once", () => {
|
|
|
|
|
cy.startDM(bot1Name);
|
|
|
|
|
cy.visit("/#/home");
|
|
|
|
|
|
|
|
|
|
cy.openSpotlightDialog().within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-07-06 12:07:10 +00:00
|
|
|
|
cy.spotlightFilter(Filter.People);
|
|
|
|
|
cy.spotlightSearch().clear().type(bot1Name);
|
2022-10-12 17:59:07 +00:00
|
|
|
|
cy.wait(3000); // wait for the dialog code to settle
|
2022-07-06 12:07:10 +00:00
|
|
|
|
cy.get(".mx_Spinner").should("not.exist");
|
|
|
|
|
cy.spotlightResults().should("have.length", 1);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-15 14:14:05 +00:00
|
|
|
|
it("should be able to navigate results via keyboard", () => {
|
|
|
|
|
cy.openSpotlightDialog().within(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait for dialog to settle
|
2022-06-15 14:14:05 +00:00
|
|
|
|
cy.spotlightFilter(Filter.People);
|
|
|
|
|
cy.spotlightSearch().clear().type("b");
|
2022-06-17 09:08:17 +00:00
|
|
|
|
// our debouncing logic only starts the search after a short timeout,
|
|
|
|
|
// so we wait a few milliseconds.
|
2022-07-13 13:43:44 +00:00
|
|
|
|
cy.wait(1000);
|
2022-06-17 09:08:17 +00:00
|
|
|
|
cy.get(".mx_Spinner")
|
|
|
|
|
.should("not.exist")
|
|
|
|
|
.then(() => {
|
2023-09-08 12:08:21 +00:00
|
|
|
|
cy.wait(500); // Wait to settle again
|
2022-06-17 09:08:17 +00:00
|
|
|
|
cy.spotlightResults()
|
|
|
|
|
.should("have.length", 2)
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.spotlightResults().eq(0).should("have.attr", "aria-selected", "true");
|
|
|
|
|
cy.spotlightResults().eq(1).should("have.attr", "aria-selected", "false");
|
|
|
|
|
});
|
|
|
|
|
cy.spotlightSearch()
|
|
|
|
|
.type("{downArrow}")
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.spotlightResults().eq(0).should("have.attr", "aria-selected", "false");
|
|
|
|
|
cy.spotlightResults().eq(1).should("have.attr", "aria-selected", "true");
|
|
|
|
|
});
|
|
|
|
|
cy.spotlightSearch()
|
|
|
|
|
.type("{downArrow}")
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.spotlightResults().eq(0).should("have.attr", "aria-selected", "false");
|
|
|
|
|
cy.spotlightResults().eq(1).should("have.attr", "aria-selected", "false");
|
|
|
|
|
});
|
|
|
|
|
cy.spotlightSearch()
|
|
|
|
|
.type("{upArrow}")
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.spotlightResults().eq(0).should("have.attr", "aria-selected", "false");
|
|
|
|
|
cy.spotlightResults().eq(1).should("have.attr", "aria-selected", "true");
|
|
|
|
|
});
|
|
|
|
|
cy.spotlightSearch()
|
|
|
|
|
.type("{upArrow}")
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.spotlightResults().eq(0).should("have.attr", "aria-selected", "true");
|
|
|
|
|
cy.spotlightResults().eq(1).should("have.attr", "aria-selected", "false");
|
2022-12-12 11:24:14 +00:00
|
|
|
|
});
|
2022-06-17 09:08:17 +00:00
|
|
|
|
});
|
2022-06-15 14:14:05 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|