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

Commit

Permalink
Added cypress test for the implemented milestone
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur12-1610 committed Aug 16, 2022
1 parent dd2191e commit 104d560
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions cypress/e2e/knocking/knocking.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
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 { SynapseInstance } from "../../plugins/synapsedocker";
import { MatrixClient } from "../../global";
import Chainable = Cypress.Chainable;

function openCreateRoomDialog(): Chainable<JQuery<HTMLElement>> {
cy.get('[aria-label="Add room"]').click();
cy.get('.mx_ContextualMenu [aria-label="New room"]').click();
return cy.get(".mx_CreateRoomDialog");
}

describe("Knocking", () => {
let synapse: SynapseInstance;

beforeEach(() => {
cy.startSynapse("default").then(data => {
synapse = data;

cy.initTestUser(synapse, "Tom");
});
});

afterEach(() => {
cy.stopSynapse(synapse);
});

it("should be able to create a room with knock JoinRule", () => {
// Enables labs flag feature
cy.enableLabsFeature("feature_knocking");
const name = "Test room 1";
const topic = "This is a test room";

// Create a room with knock JoinRule
openCreateRoomDialog().within(() => {
cy.get('[label="Name"]').type(name);
cy.get('[label="Topic (optional)"]').type(topic);
cy.get(".mx_JoinRuleDropdown").click();
cy.get(".mx_JoinRuleDropdown_knock").click();
cy.startMeasuring("from-submit-to-room");
cy.get(".mx_Dialog_primary").click();
});

// Change room settings
cy.openRoomSettings("Security & Privacy");
cy.get(".mx_StyledRadioButton_content").contains("Ask to join").click();
cy.closeDialog();

//Check if the room settings are visible if labs flag is disabled
cy.openUserSettings("Labs").within(() => {
//disables labs flag feature
cy.get("[aria-label='Knocking']").click();
});
cy.closeDialog();
//the default joinRule is set to Private (invite only)
cy.openRoomSettings("Security & Privacy");

cy.stopMeasuring("from-submit-to-room");
cy.get(".mx_RoomHeader_nametext").contains(name);
cy.get(".mx_RoomHeader_topic").contains(topic);
});
});

0 comments on commit 104d560

Please sign in to comment.