Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 79033eb

Browse files
authored
Add dendrite support to cypress tests (#9884)
* Minimum hacks required to run cypress tests with dendrite * Remove wget hack since dendrite containers now have curl * Add basic dendritedocker plugin & hack into login spec for testing * Add generic HomeserverInstance interface * Add env var to configure which homeserver to use * Remove synapse specific homeserver support api * Update the rest of the tests to use HomeserverInstance * Update cypress docs to reference new homeserver abstraction * Fix formatting issues * Change dendrite to use main branch container
1 parent b642df9 commit 79033eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+948
-363
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package-lock.json
2424
/cypress/downloads
2525
/cypress/screenshots
2626
/cypress/synapselogs
27+
/cypress/dendritelogs
2728
# These could have files in them but don't currently
2829
# Cypress will still auto-create them though...
2930
/cypress/performance

cypress.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default defineConfig({
3333
env: {
3434
// Docker tag to use for `ghcr.io/matrix-org/sliding-sync-proxy` image.
3535
SLIDING_SYNC_PROXY_TAG: "v0.6.0",
36+
HOMESERVER: "synapse",
3637
},
3738
retries: {
3839
runMode: 4,

cypress/e2e/composer/composer.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ limitations under the License.
1616

1717
/// <reference types="cypress" />
1818

19-
import { SynapseInstance } from "../../plugins/synapsedocker";
19+
import { HomeserverInstance } from "../../plugins/utils/homeserver";
2020
import { SettingLevel } from "../../../src/settings/SettingLevel";
2121

2222
describe("Composer", () => {
23-
let synapse: SynapseInstance;
23+
let homeserver: HomeserverInstance;
2424

2525
beforeEach(() => {
26-
cy.startSynapse("default").then((data) => {
27-
synapse = data;
26+
cy.startHomeserver("default").then((data) => {
27+
homeserver = data;
2828
});
2929
});
3030

3131
afterEach(() => {
32-
cy.stopSynapse(synapse);
32+
cy.stopHomeserver(homeserver);
3333
});
3434

3535
describe("CIDER", () => {
3636
beforeEach(() => {
37-
cy.initTestUser(synapse, "Janet").then(() => {
37+
cy.initTestUser(homeserver, "Janet").then(() => {
3838
cy.createRoom({ name: "Composing Room" });
3939
});
4040
cy.viewRoomByName("Composing Room");
@@ -101,7 +101,7 @@ describe("Composer", () => {
101101
describe("WYSIWYG", () => {
102102
beforeEach(() => {
103103
cy.enableLabsFeature("feature_wysiwyg_composer");
104-
cy.initTestUser(synapse, "Janet").then(() => {
104+
cy.initTestUser(homeserver, "Janet").then(() => {
105105
cy.createRoom({ name: "Composing Room" });
106106
});
107107
cy.viewRoomByName("Composing Room");

cypress/e2e/create-room/create-room.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
/// <reference types="cypress" />
1818

19-
import { SynapseInstance } from "../../plugins/synapsedocker";
19+
import { HomeserverInstance } from "../../plugins/utils/homeserver";
2020
import Chainable = Cypress.Chainable;
2121

2222
function openCreateRoomDialog(): Chainable<JQuery<HTMLElement>> {
@@ -26,18 +26,18 @@ function openCreateRoomDialog(): Chainable<JQuery<HTMLElement>> {
2626
}
2727

2828
describe("Create Room", () => {
29-
let synapse: SynapseInstance;
29+
let homeserver: HomeserverInstance;
3030

3131
beforeEach(() => {
32-
cy.startSynapse("default").then((data) => {
33-
synapse = data;
32+
cy.startHomeserver("default").then((data) => {
33+
homeserver = data;
3434

35-
cy.initTestUser(synapse, "Jim");
35+
cy.initTestUser(homeserver, "Jim");
3636
});
3737
});
3838

3939
afterEach(() => {
40-
cy.stopSynapse(synapse);
40+
cy.stopHomeserver(homeserver);
4141
});
4242

4343
it("should allow us to create a public room with name, topic & address set", () => {

cypress/e2e/crypto/crypto.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import type { ISendEventResponse, MatrixClient, Room } from "matrix-js-sdk/src/m
1818
import type { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
1919
import type { ISasEvent } from "matrix-js-sdk/src/crypto/verification/SAS";
2020
import type { CypressBot } from "../../support/bot";
21-
import { SynapseInstance } from "../../plugins/synapsedocker";
21+
import { HomeserverInstance } from "../../plugins/utils/homeserver";
2222
import Chainable = Cypress.Chainable;
2323

2424
type EmojiMapping = [emoji: string, name: string];
2525
interface CryptoTestContext extends Mocha.Context {
26-
synapse: SynapseInstance;
26+
homeserver: HomeserverInstance;
2727
bob: CypressBot;
2828
}
2929

@@ -155,16 +155,16 @@ const verify = function (this: CryptoTestContext) {
155155

156156
describe("Cryptography", function () {
157157
beforeEach(function () {
158-
cy.startSynapse("default")
159-
.as("synapse")
160-
.then((synapse: SynapseInstance) => {
161-
cy.initTestUser(synapse, "Alice", undefined, "alice_");
162-
cy.getBot(synapse, { displayName: "Bob", autoAcceptInvites: false, userIdPrefix: "bob_" }).as("bob");
158+
cy.startHomeserver("default")
159+
.as("homeserver")
160+
.then((homeserver: HomeserverInstance) => {
161+
cy.initTestUser(homeserver, "Alice", undefined, "alice_");
162+
cy.getBot(homeserver, { displayName: "Bob", autoAcceptInvites: false, userIdPrefix: "bob_" }).as("bob");
163163
});
164164
});
165165

166166
afterEach(function (this: CryptoTestContext) {
167-
cy.stopSynapse(this.synapse);
167+
cy.stopHomeserver(this.homeserver);
168168
});
169169

170170
it("setting up secure key backup should work", () => {
@@ -215,7 +215,7 @@ describe("Cryptography", function () {
215215
cy.bootstrapCrossSigning();
216216

217217
// bob has a second, not cross-signed, device
218-
cy.loginBot(this.synapse, this.bob.getUserId(), this.bob.__cypress_password, {}).as("bobSecondDevice");
218+
cy.loginBot(this.homeserver, this.bob.getUserId(), this.bob.__cypress_password, {}).as("bobSecondDevice");
219219

220220
autoJoin(this.bob);
221221

cypress/e2e/crypto/decryption-failure.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
import type { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
1818
import type { ISasEvent } from "matrix-js-sdk/src/crypto/verification/SAS";
1919
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
20-
import { SynapseInstance } from "../../plugins/synapsedocker";
20+
import { HomeserverInstance } from "../../plugins/utils/homeserver";
2121
import { UserCredentials } from "../../support/login";
2222
import Chainable = Cypress.Chainable;
2323

@@ -56,20 +56,20 @@ const handleVerificationRequest = (request: VerificationRequest): Chainable<Emoj
5656
};
5757

5858
describe("Decryption Failure Bar", () => {
59-
let synapse: SynapseInstance | undefined;
59+
let homeserver: HomeserverInstance | undefined;
6060
let testUser: UserCredentials | undefined;
6161
let bot: MatrixClient | undefined;
6262
let roomId: string;
6363

6464
beforeEach(function () {
65-
cy.startSynapse("default").then((syn: SynapseInstance) => {
66-
synapse = syn;
67-
cy.initTestUser(synapse, TEST_USER)
65+
cy.startHomeserver("default").then((hs: HomeserverInstance) => {
66+
homeserver = hs;
67+
cy.initTestUser(homeserver, TEST_USER)
6868
.then((creds: UserCredentials) => {
6969
testUser = creds;
7070
})
7171
.then(() => {
72-
cy.getBot(synapse, { displayName: BOT_USER }).then((cli) => {
72+
cy.getBot(homeserver, { displayName: BOT_USER }).then((cli) => {
7373
bot = cli;
7474
});
7575
})
@@ -97,15 +97,15 @@ describe("Decryption Failure Bar", () => {
9797
});
9898

9999
afterEach(() => {
100-
cy.stopSynapse(synapse);
100+
cy.stopHomeserver(homeserver);
101101
});
102102

103103
it(
104104
"should prompt the user to verify, if this device isn't verified " +
105105
"and there are other verified devices or backups",
106106
() => {
107107
let otherDevice: MatrixClient | undefined;
108-
cy.loginBot(synapse, testUser.username, testUser.password, {})
108+
cy.loginBot(homeserver, testUser.username, testUser.password, {})
109109
.then(async (cli) => {
110110
otherDevice = cli;
111111
await otherDevice.bootstrapCrossSigning({
@@ -169,7 +169,7 @@ describe("Decryption Failure Bar", () => {
169169
"should prompt the user to reset keys, if this device isn't verified " +
170170
"and there are no other verified devices or backups",
171171
() => {
172-
cy.loginBot(synapse, testUser.username, testUser.password, {}).then(async (cli) => {
172+
cy.loginBot(homeserver, testUser.username, testUser.password, {}).then(async (cli) => {
173173
await cli.bootstrapCrossSigning({
174174
authUploadDeviceSigningKeys: async (makeRequest) => {
175175
await makeRequest({});

cypress/e2e/editing/editing.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ limitations under the License.
1919
import type { MsgType } from "matrix-js-sdk/src/@types/event";
2020
import type { ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
2121
import type { EventType } from "matrix-js-sdk/src/@types/event";
22-
import { SynapseInstance } from "../../plugins/synapsedocker";
22+
import { HomeserverInstance } from "../../plugins/utils/homeserver";
2323
import Chainable = Cypress.Chainable;
2424

2525
const sendEvent = (roomId: string): Chainable<ISendEventResponse> => {
@@ -30,20 +30,20 @@ const sendEvent = (roomId: string): Chainable<ISendEventResponse> => {
3030
};
3131

3232
describe("Editing", () => {
33-
let synapse: SynapseInstance;
33+
let homeserver: HomeserverInstance;
3434

3535
beforeEach(() => {
36-
cy.startSynapse("default").then((data) => {
37-
synapse = data;
38-
cy.initTestUser(synapse, "Edith").then(() => {
36+
cy.startHomeserver("default").then((data) => {
37+
homeserver = data;
38+
cy.initTestUser(homeserver, "Edith").then(() => {
3939
cy.injectAxe();
4040
return cy.createRoom({ name: "Test room" }).as("roomId");
4141
});
4242
});
4343
});
4444

4545
afterEach(() => {
46-
cy.stopSynapse(synapse);
46+
cy.stopHomeserver(homeserver);
4747
});
4848

4949
it("should close the composer when clicking save after making a change and undoing it", () => {

cypress/e2e/integration-manager/get-openid-token.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
/// <reference types="cypress" />
1818

19-
import { SynapseInstance } from "../../plugins/synapsedocker";
19+
import { HomeserverInstance } from "../../plugins/utils/homeserver";
2020
import { UserCredentials } from "../../support/login";
2121

2222
const ROOM_NAME = "Integration Manager Test";
@@ -73,17 +73,17 @@ function sendActionFromIntegrationManager(integrationManagerUrl: string) {
7373

7474
describe("Integration Manager: Get OpenID Token", () => {
7575
let testUser: UserCredentials;
76-
let synapse: SynapseInstance;
76+
let homeserver: HomeserverInstance;
7777
let integrationManagerUrl: string;
7878

7979
beforeEach(() => {
8080
cy.serveHtmlFile(INTEGRATION_MANAGER_HTML).then((url) => {
8181
integrationManagerUrl = url;
8282
});
83-
cy.startSynapse("default").then((data) => {
84-
synapse = data;
83+
cy.startHomeserver("default").then((data) => {
84+
homeserver = data;
8585

86-
cy.initTestUser(synapse, USER_DISPLAY_NAME, () => {
86+
cy.initTestUser(homeserver, USER_DISPLAY_NAME, () => {
8787
cy.window().then((win) => {
8888
win.localStorage.setItem("mx_scalar_token", INTEGRATION_MANAGER_TOKEN);
8989
win.localStorage.setItem(`mx_scalar_token_at_${integrationManagerUrl}`, INTEGRATION_MANAGER_TOKEN);
@@ -122,7 +122,7 @@ describe("Integration Manager: Get OpenID Token", () => {
122122
});
123123

124124
afterEach(() => {
125-
cy.stopSynapse(synapse);
125+
cy.stopHomeserver(homeserver);
126126
cy.stopWebServers();
127127
});
128128

cypress/e2e/integration-manager/kick.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
/// <reference types="cypress" />
1818

19-
import { SynapseInstance } from "../../plugins/synapsedocker";
19+
import { HomeserverInstance } from "../../plugins/utils/homeserver";
2020
import { MatrixClient } from "../../global";
2121
import { UserCredentials } from "../../support/login";
2222

@@ -94,17 +94,17 @@ function expectKickedMessage(shouldExist: boolean) {
9494

9595
describe("Integration Manager: Kick", () => {
9696
let testUser: UserCredentials;
97-
let synapse: SynapseInstance;
97+
let homeserver: HomeserverInstance;
9898
let integrationManagerUrl: string;
9999

100100
beforeEach(() => {
101101
cy.serveHtmlFile(INTEGRATION_MANAGER_HTML).then((url) => {
102102
integrationManagerUrl = url;
103103
});
104-
cy.startSynapse("default").then((data) => {
105-
synapse = data;
104+
cy.startHomeserver("default").then((data) => {
105+
homeserver = data;
106106

107-
cy.initTestUser(synapse, USER_DISPLAY_NAME, () => {
107+
cy.initTestUser(homeserver, USER_DISPLAY_NAME, () => {
108108
cy.window().then((win) => {
109109
win.localStorage.setItem("mx_scalar_token", INTEGRATION_MANAGER_TOKEN);
110110
win.localStorage.setItem(`mx_scalar_token_at_${integrationManagerUrl}`, INTEGRATION_MANAGER_TOKEN);
@@ -140,12 +140,12 @@ describe("Integration Manager: Kick", () => {
140140
name: ROOM_NAME,
141141
}).as("roomId");
142142

143-
cy.getBot(synapse, { displayName: BOT_DISPLAY_NAME, autoAcceptInvites: true }).as("bob");
143+
cy.getBot(homeserver, { displayName: BOT_DISPLAY_NAME, autoAcceptInvites: true }).as("bob");
144144
});
145145
});
146146

147147
afterEach(() => {
148-
cy.stopSynapse(synapse);
148+
cy.stopHomeserver(homeserver);
149149
cy.stopWebServers();
150150
});
151151

cypress/e2e/integration-manager/read_events.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
/// <reference types="cypress" />
1818

19-
import { SynapseInstance } from "../../plugins/synapsedocker";
19+
import { HomeserverInstance } from "../../plugins/utils/homeserver";
2020
import { UserCredentials } from "../../support/login";
2121

2222
const ROOM_NAME = "Integration Manager Test";
@@ -87,17 +87,17 @@ function sendActionFromIntegrationManager(
8787

8888
describe("Integration Manager: Read Events", () => {
8989
let testUser: UserCredentials;
90-
let synapse: SynapseInstance;
90+
let homeserver: HomeserverInstance;
9191
let integrationManagerUrl: string;
9292

9393
beforeEach(() => {
9494
cy.serveHtmlFile(INTEGRATION_MANAGER_HTML).then((url) => {
9595
integrationManagerUrl = url;
9696
});
97-
cy.startSynapse("default").then((data) => {
98-
synapse = data;
97+
cy.startHomeserver("default").then((data) => {
98+
homeserver = data;
9999

100-
cy.initTestUser(synapse, USER_DISPLAY_NAME, () => {
100+
cy.initTestUser(homeserver, USER_DISPLAY_NAME, () => {
101101
cy.window().then((win) => {
102102
win.localStorage.setItem("mx_scalar_token", INTEGRATION_MANAGER_TOKEN);
103103
win.localStorage.setItem(`mx_scalar_token_at_${integrationManagerUrl}`, INTEGRATION_MANAGER_TOKEN);
@@ -136,7 +136,7 @@ describe("Integration Manager: Read Events", () => {
136136
});
137137

138138
afterEach(() => {
139-
cy.stopSynapse(synapse);
139+
cy.stopHomeserver(homeserver);
140140
cy.stopWebServers();
141141
});
142142

0 commit comments

Comments
 (0)