Automatically adjust history visibility when making a room private (#30713)
* Refactor StyledRadioButton to provide proper labels. * Automatically change history settings to members only if room is made private * Add tests * lint * lint further * Fix clickable buttons * Revert functional component-ing * text tweaks * update snapshots * Add unit test for history vis changes * lint * Update snapshots * Fix flakes * lint
This commit is contained in:
@@ -19,7 +19,16 @@ test.describe("Roles & Permissions room settings tab", () => {
|
||||
let settings: Locator;
|
||||
|
||||
test.beforeEach(async ({ user, app }) => {
|
||||
await app.client.createRoom({ name: roomName });
|
||||
await app.client.createRoom({
|
||||
name: roomName,
|
||||
power_level_content_override: {
|
||||
events: {
|
||||
// Set the join rules as lower than the history vis to test an edge case.
|
||||
["m.room.join_rules"]: 80,
|
||||
["m.room.history_visibility"]: 100,
|
||||
},
|
||||
},
|
||||
});
|
||||
await app.viewRoomByName(roomName);
|
||||
settings = await app.settings.openRoomSettings("Security & Privacy");
|
||||
});
|
||||
@@ -45,4 +54,68 @@ test.describe("Roles & Permissions room settings tab", () => {
|
||||
await expect(settings).toMatchScreenshot("room-security-settings.png");
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
"should automatically adjust history visibility when a room is changed from public to private",
|
||||
{ tag: "@screenshot" },
|
||||
async ({ page, app, user, axe }) => {
|
||||
await page.setViewportSize({ width: 1024, height: 1400 });
|
||||
|
||||
const settingsGroupAccess = page.getByRole("group", { name: "Access" });
|
||||
const settingsGroupHistory = page.getByRole("group", { name: "Who can read history?" });
|
||||
|
||||
await settingsGroupAccess.getByText("Public").click();
|
||||
await settingsGroupHistory.getByText("Anyone").click();
|
||||
|
||||
// Test that we have the warning appear.
|
||||
axe.disableRules("color-contrast"); // XXX: Inheriting colour contrast issues from room view.
|
||||
await expect(axe).toHaveNoViolations();
|
||||
await expect(settings).toMatchScreenshot("room-security-settings-world-readable.png");
|
||||
|
||||
await settingsGroupAccess.getByText("Private (invite only)").click();
|
||||
// Element should have automatically set the room to "sharing" history visibility
|
||||
await expect(
|
||||
settingsGroupHistory.getByText("Members only (since the point in time of selecting this option)"),
|
||||
).toBeChecked();
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
"should disallow changing from public to private if the user cannot alter history",
|
||||
{ tag: "@screenshot" },
|
||||
async ({ page, app, user, bot }) => {
|
||||
await page.setViewportSize({ width: 1024, height: 1400 });
|
||||
|
||||
const settingsGroupAccess = page.getByRole("group", { name: "Access" });
|
||||
const settingsGroupHistory = page.getByRole("group", { name: "Who can read history?" });
|
||||
|
||||
await settingsGroupAccess.getByText("Public").click();
|
||||
await settingsGroupHistory.getByText("Anyone").click();
|
||||
|
||||
// De-op ourselves
|
||||
await app.settings.switchTab("Roles & Permissions");
|
||||
|
||||
// Wait for the permissions list to be visible
|
||||
await expect(settings.getByRole("heading", { name: "Permissions" })).toBeVisible();
|
||||
|
||||
const ourComboBox = settings.getByRole("combobox", { name: user.userId });
|
||||
await ourComboBox.selectOption("Custom level");
|
||||
const ourPl = settings.getByRole("spinbutton", { name: user.userId });
|
||||
await ourPl.fill("80");
|
||||
await ourPl.blur(); // Shows a warning on
|
||||
|
||||
// Accept the de-op
|
||||
await page.getByRole("button", { name: "Continue" }).click();
|
||||
await settings.getByRole("button", { name: "Apply", disabled: false }).click();
|
||||
|
||||
await app.settings.switchTab("Security & Privacy");
|
||||
|
||||
await settingsGroupAccess.getByText("Private (invite only)").click();
|
||||
// Element should have automatically set the room to "sharing" history visibility
|
||||
const errorDialog = page.getByRole("heading", { name: "Cannot make room private" });
|
||||
await expect(errorDialog).toBeVisible();
|
||||
await errorDialog.getByLabel("OK");
|
||||
await expect(settingsGroupHistory.getByText("Anyone")).toBeChecked();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user