Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

111 remove public private switch #166

Merged
merged 13 commits into from
Sep 14, 2022
3 changes: 2 additions & 1 deletion customisations.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"src/components/views/messages/OriginalImageBody.tsx": "node_modules/matrix-react-sdk/src/components/views/messages/MImageBody.tsx",
"src/components/views/messages/OriginalStickerBody.tsx": "node_modules/matrix-react-sdk/src/components/views/messages/MStickerBody.tsx",
"src/components/views/messages/OriginalVideoBody.tsx": "node_modules/matrix-react-sdk/src/components/views/messages/MVideoBody.tsx",
"src/components/views/messages/OriginalVoiceMessageBody.tsx": "node_modules/matrix-react-sdk/src/components/views/messages/MVoiceMessageBody.tsx"
"src/components/views/messages/OriginalVoiceMessageBody.tsx": "node_modules/matrix-react-sdk/src/components/views/messages/MVoiceMessageBody.tsx",
"src/components/views/settings/JoinRuleSettings.tsx": "src/components/views/settings/TchapJoinRuleSettings.tsx"
}
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ getVar('E2E_TEST_USER_HOMESERVER_URL');
getVar('E2E_TEST_USER_HOMESERVER_SHORT');

export default defineConfig({
watchForFileChanges : false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On veut ca ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui sinon, a chaque changement, il relance les tests c'est tres penible

videoUploadOnPasses: false,
projectId: 'ppvnzg',
experimentalInteractiveRunEvents: true,
Expand Down
68 changes: 68 additions & 0 deletions cypress/e2e/room-access-settings/room-access-settings.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/// <reference types="cypress" />

import RoomUtils from "../utils/room-utils";
import Chainable = Cypress.Chainable;



describe("Check room access settings", () => {
const homeserverUrl = Cypress.env('E2E_TEST_USER_HOMESERVER_URL');
const email = Cypress.env('E2E_TEST_USER_EMAIL');
const password = Cypress.env('E2E_TEST_USER_PASSWORD');
const homeserverShortname = Cypress.env('E2E_TEST_USER_HOMESERVER_SHORT');
const today = new Date().toISOString().slice(0, 10).replace(/-/g, '');

beforeEach(() => {
cy.loginUser(homeserverUrl, email, password);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai fait une version de cy.loginUser sans arguments, pour eviter d'avoir a specifier les defaults. Dans cette PR : #171
(approuuuuuve ma PRRRRR, viennnnns 🐍 )

});

afterEach(() => {
// todo delete room, otherwise the test user will end up with a million identical rooms after a while.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a PR to add this : #170
(apprrrouuuuuuuuuuuuuuve ma PRRRRRRRRR 🐍 😵‍💫)

});

it("creates a public room and check access settings", () => {
const roomName = "test/"+today+"/public_room_check_access_settings";

RoomUtils.createPublicRoom(roomName);

openRoomAccessSettings();

//assert
cy.get('#joinRule-invite-description').should('not.exist');
cy.get('#joinRule-restricted-description').should('not.exist');
cy.get('#joinRule-public-description').should('exist');
});

it("creates a private room and check access settings", () => {
const roomName = "test/"+today+"/private_room_check_access_settings";

RoomUtils.createPrivateRoom(roomName);

openRoomAccessSettings();

//assert
cy.get('#joinRule-invite-description').should('exist');
cy.get('#joinRule-restricted-description').should('not.exist');
cy.get('#joinRule-public-description').should('not.exist');
});

it("creates a private room with external and check access settings", () => {
const roomName = "test/"+today+"/private_room_check_access_settings";

RoomUtils.createPrivateRoomWithExternal(roomName);

openRoomAccessSettings();

//assert
cy.get('#joinRule-invite-description').should('exist');
cy.get('#joinRule-restricted-description').should('not.exist');
cy.get('#joinRule-public-description').should('not.exist');
});
});


function openRoomAccessSettings(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on met ca dans les utils peut etre ? Chepa

cy.get('.mx_RoomHeader_chevron').click();
cy.get('[aria-label="Paramètres"] > .mx_IconizedContextMenu_label').click();
cy.get('[data-testid="settings-tab-ROOM_SECURITY_TAB"] > .mx_TabbedView_tabLabel_text').click();
}
51 changes: 51 additions & 0 deletions cypress/e2e/utils/room-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import Chainable = Cypress.Chainable;

export default class RoomUtils {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively, you could use cy.createRoom (for better independence between tests) :

createRoom(options: ICreateRoomOpts): Chainable<string>;
/**

But if it works, fine, let's move forward.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention to do this seems to be to add a file in /cypress/support and create cy. functions.
This works too, I guess.
It's just hard to know where things are if they are in two different places... 🤷‍♀️


static openCreateRoomDialog(): Chainable<JQuery<HTMLElement>> {
const addRoomLabel = "Ajouter un salon";
const newRoomLabel = "Nouveau salon";
cy.get(`[aria-label="${addRoomLabel}"]`).click();
cy.get(`.mx_ContextualMenu [aria-label="${newRoomLabel}"]`).click();
return cy.get(".mx_Dialog");
}


static createPrivateRoom(roomName: string) {
RoomUtils.openCreateRoomDialog().within(() => {
// Fill name
const nameLabel = "Nom";
cy.get(`[label="${nameLabel}"]`).type(roomName);
// Submit
cy.startMeasuring("from-submit-to-room");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you start measuring here, but never stop, so I don't think it measures anything. (also I don't really know what this measuring does :) )
I suggest removing it from here because start and stop should be in the same function, otherwise we'll lose them.

cy.get(".mx_Dialog_primary").click();
});
}

static createPublicRoom(roomName: string) {
RoomUtils.openCreateRoomDialog().within(() => {
// Fill name
const nameLabel = "Nom";
cy.get(`[label="${nameLabel}"]`).type(roomName);
// Change room to public
cy.get(".tc_TchapRoomTypeSelector_forum").click();
// Submit
cy.startMeasuring("from-submit-to-room");
cy.get(".mx_Dialog_primary").click();
});
}

static createPrivateRoomWithExternal(roomName: string) {
RoomUtils.openCreateRoomDialog().within(() => {
// Fill name
const nameLabel = "Nom";
cy.get(`[label="${nameLabel}"]`).type(roomName);
// Change room to public
cy.get(".tc_TchapRoomTypeSelector_external").click();
// Submit
cy.startMeasuring("from-submit-to-room");
cy.get(".mx_Dialog_primary").click();
});
}
}

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,12 @@
"FontManager.ts": "<rootDir>/node_modules/matrix-react-sdk/__mocks__/FontManager.js",
"workers/(.+)\\.worker\\.ts": "<rootDir>/node_modules/matrix-react-sdk/__mocks__/workerMock.js",
"^!!raw-loader!.*": "jest-raw-loader",
"RecorderWorklet": "<rootDir>/node_modules/matrix-react-sdk/__mocks__/empty.js"
"RecorderWorklet": "<rootDir>/node_modules/matrix-react-sdk/__mocks__/empty.js",
"MImageBody": "<rootDir>/src/customisations/components/views/messages/ContentScanningImageBody.tsx",
"../../../../../../src/components/views/messages/OriginalFileBody": "<rootDir>/node_modules/matrix-react-sdk/src/components/views/messages/MImageBody.tsx",
"MAudioBody": "<rootDir>/src/customisations/components/views/messages/ContentScanningAudioBody.tsx",
"../../../../../../src/components/views/messages/OriginalAudioBody": "<rootDir>/node_modules/matrix-react-sdk/src/components/views/messages/MAudioBody.tsx",
"MStickerBody": "<rootDir>/src/customisations/components/views/messages/ContentScanningStickerBody.tsx"
},
"transformIgnorePatterns": [
"\/node_modules\/(?!matrix-js-sdk|matrix-react-sdk).+$"
Expand Down
Loading