You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-09 08:42:50 +03:00
Apply prettier formatting
This commit is contained in:
@@ -12,7 +12,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
import {
|
||||
IPushRule,
|
||||
IPushRules,
|
||||
@@ -22,15 +22,15 @@ import {
|
||||
MatrixEvent,
|
||||
Room,
|
||||
NotificationCountType,
|
||||
} from 'matrix-js-sdk/src/matrix';
|
||||
import { IThreepid, ThreepidMedium } from 'matrix-js-sdk/src/@types/threepids';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { fireEvent, getByTestId, render, screen, waitFor } from '@testing-library/react';
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
|
||||
import { act } from "react-dom/test-utils";
|
||||
import { fireEvent, getByTestId, render, screen, waitFor } from "@testing-library/react";
|
||||
|
||||
import Notifications from '../../../../src/components/views/settings/Notifications';
|
||||
import Notifications from "../../../../src/components/views/settings/Notifications";
|
||||
import SettingsStore from "../../../../src/settings/SettingsStore";
|
||||
import { StandardActions } from '../../../../src/notifications/StandardActions';
|
||||
import { getMockClientWithEventEmitter, mkMessage } from '../../../test-utils';
|
||||
import { StandardActions } from "../../../../src/notifications/StandardActions";
|
||||
import { getMockClientWithEventEmitter, mkMessage } from "../../../test-utils";
|
||||
|
||||
// don't pollute test output with error logs from mock rejections
|
||||
jest.mock("matrix-js-sdk/src/logger");
|
||||
@@ -46,17 +46,155 @@ const masterRule = {
|
||||
rule_id: RuleId.Master,
|
||||
};
|
||||
// eslint-disable-next-line max-len
|
||||
const oneToOneRule = { "conditions": [{ "kind": "room_member_count", "is": "2" }, { "kind": "event_match", "key": "type", "pattern": "m.room.message" }], "actions": ["notify", { "set_tweak": "highlight", "value": false }], "rule_id": ".m.rule.room_one_to_one", "default": true, "enabled": true } as IPushRule;
|
||||
const oneToOneRule = {
|
||||
conditions: [
|
||||
{ kind: "room_member_count", is: "2" },
|
||||
{ kind: "event_match", key: "type", pattern: "m.room.message" },
|
||||
],
|
||||
actions: ["notify", { set_tweak: "highlight", value: false }],
|
||||
rule_id: ".m.rule.room_one_to_one",
|
||||
default: true,
|
||||
enabled: true,
|
||||
} as IPushRule;
|
||||
// eslint-disable-next-line max-len
|
||||
const encryptedOneToOneRule = { "conditions": [{ "kind": "room_member_count", "is": "2" }, { "kind": "event_match", "key": "type", "pattern": "m.room.encrypted" }], "actions": ["notify", { "set_tweak": "sound", "value": "default" }, { "set_tweak": "highlight", "value": false }], "rule_id": ".m.rule.encrypted_room_one_to_one", "default": true, "enabled": true } as IPushRule;
|
||||
const encryptedOneToOneRule = {
|
||||
conditions: [
|
||||
{ kind: "room_member_count", is: "2" },
|
||||
{ kind: "event_match", key: "type", pattern: "m.room.encrypted" },
|
||||
],
|
||||
actions: ["notify", { set_tweak: "sound", value: "default" }, { set_tweak: "highlight", value: false }],
|
||||
rule_id: ".m.rule.encrypted_room_one_to_one",
|
||||
default: true,
|
||||
enabled: true,
|
||||
} as IPushRule;
|
||||
// eslint-disable-next-line max-len
|
||||
const encryptedGroupRule = { "conditions": [{ "kind": "event_match", "key": "type", "pattern": "m.room.encrypted" }], "actions": ["dont_notify"], "rule_id": ".m.rule.encrypted", "default": true, "enabled": true } as IPushRule;
|
||||
const encryptedGroupRule = {
|
||||
conditions: [{ kind: "event_match", key: "type", pattern: "m.room.encrypted" }],
|
||||
actions: ["dont_notify"],
|
||||
rule_id: ".m.rule.encrypted",
|
||||
default: true,
|
||||
enabled: true,
|
||||
} as IPushRule;
|
||||
// eslint-disable-next-line max-len
|
||||
const pushRules: IPushRules = { "global": { "underride": [{ "conditions": [{ "kind": "event_match", "key": "type", "pattern": "m.call.invite" }], "actions": ["notify", { "set_tweak": "sound", "value": "ring" }, { "set_tweak": "highlight", "value": false }], "rule_id": ".m.rule.call", "default": true, "enabled": true }, oneToOneRule, encryptedOneToOneRule, { "conditions": [{ "kind": "event_match", "key": "type", "pattern": "m.room.message" }], "actions": ["notify", { "set_tweak": "sound", "value": "default" }, { "set_tweak": "highlight", "value": false }], "rule_id": ".m.rule.message", "default": true, "enabled": true }, encryptedGroupRule, { "conditions": [{ "kind": "event_match", "key": "type", "pattern": "im.vector.modular.widgets" }, { "kind": "event_match", "key": "content.type", "pattern": "jitsi" }, { "kind": "event_match", "key": "state_key", "pattern": "*" }], "actions": ["notify", { "set_tweak": "highlight", "value": false }], "rule_id": ".im.vector.jitsi", "default": true, "enabled": true }], "sender": [], "room": [{ "actions": ["dont_notify"], "rule_id": "!zJPyWqpMorfCcWObge:matrix.org", "default": false, "enabled": true }], "content": [{ "actions": ["notify", { "set_tweak": "highlight", "value": false }], "pattern": "banana", "rule_id": "banana", "default": false, "enabled": true }, { "actions": ["notify", { "set_tweak": "sound", "value": "default" }, { "set_tweak": "highlight" }], "pattern": "kadev1", "rule_id": ".m.rule.contains_user_name", "default": true, "enabled": true }], "override": [{ "conditions": [], "actions": ["dont_notify"], "rule_id": ".m.rule.master", "default": true, "enabled": false }, { "conditions": [{ "kind": "event_match", "key": "content.msgtype", "pattern": "m.notice" }], "actions": ["dont_notify"], "rule_id": ".m.rule.suppress_notices", "default": true, "enabled": true }, { "conditions": [{ "kind": "event_match", "key": "type", "pattern": "m.room.member" }, { "kind": "event_match", "key": "content.membership", "pattern": "invite" }, { "kind": "event_match", "key": "state_key", "pattern": "@kadev1:matrix.org" }], "actions": ["notify", { "set_tweak": "sound", "value": "default" }, { "set_tweak": "highlight", "value": false }], "rule_id": ".m.rule.invite_for_me", "default": true, "enabled": true }, { "conditions": [{ "kind": "event_match", "key": "type", "pattern": "m.room.member" }], "actions": ["dont_notify"], "rule_id": ".m.rule.member_event", "default": true, "enabled": true }, { "conditions": [{ "kind": "contains_display_name" }], "actions": ["notify", { "set_tweak": "sound", "value": "default" }, { "set_tweak": "highlight" }], "rule_id": ".m.rule.contains_display_name", "default": true, "enabled": true }, { "conditions": [{ "kind": "event_match", "key": "content.body", "pattern": "@room" }, { "kind": "sender_notification_permission", "key": "room" }], "actions": ["notify", { "set_tweak": "highlight", "value": true }], "rule_id": ".m.rule.roomnotif", "default": true, "enabled": true }, { "conditions": [{ "kind": "event_match", "key": "type", "pattern": "m.room.tombstone" }, { "kind": "event_match", "key": "state_key", "pattern": "" }], "actions": ["notify", { "set_tweak": "highlight", "value": true }], "rule_id": ".m.rule.tombstone", "default": true, "enabled": true }, { "conditions": [{ "kind": "event_match", "key": "type", "pattern": "m.reaction" }], "actions": ["dont_notify"], "rule_id": ".m.rule.reaction", "default": true, "enabled": true }] }, "device": {} } as IPushRules;
|
||||
const pushRules: IPushRules = {
|
||||
global: {
|
||||
underride: [
|
||||
{
|
||||
conditions: [{ kind: "event_match", key: "type", pattern: "m.call.invite" }],
|
||||
actions: ["notify", { set_tweak: "sound", value: "ring" }, { set_tweak: "highlight", value: false }],
|
||||
rule_id: ".m.rule.call",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
oneToOneRule,
|
||||
encryptedOneToOneRule,
|
||||
{
|
||||
conditions: [{ kind: "event_match", key: "type", pattern: "m.room.message" }],
|
||||
actions: ["notify", { set_tweak: "sound", value: "default" }, { set_tweak: "highlight", value: false }],
|
||||
rule_id: ".m.rule.message",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
encryptedGroupRule,
|
||||
{
|
||||
conditions: [
|
||||
{ kind: "event_match", key: "type", pattern: "im.vector.modular.widgets" },
|
||||
{ kind: "event_match", key: "content.type", pattern: "jitsi" },
|
||||
{ kind: "event_match", key: "state_key", pattern: "*" },
|
||||
],
|
||||
actions: ["notify", { set_tweak: "highlight", value: false }],
|
||||
rule_id: ".im.vector.jitsi",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
],
|
||||
sender: [],
|
||||
room: [{ actions: ["dont_notify"], rule_id: "!zJPyWqpMorfCcWObge:matrix.org", default: false, enabled: true }],
|
||||
content: [
|
||||
{
|
||||
actions: ["notify", { set_tweak: "highlight", value: false }],
|
||||
pattern: "banana",
|
||||
rule_id: "banana",
|
||||
default: false,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
actions: ["notify", { set_tweak: "sound", value: "default" }, { set_tweak: "highlight" }],
|
||||
pattern: "kadev1",
|
||||
rule_id: ".m.rule.contains_user_name",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
],
|
||||
override: [
|
||||
{ conditions: [], actions: ["dont_notify"], rule_id: ".m.rule.master", default: true, enabled: false },
|
||||
{
|
||||
conditions: [{ kind: "event_match", key: "content.msgtype", pattern: "m.notice" }],
|
||||
actions: ["dont_notify"],
|
||||
rule_id: ".m.rule.suppress_notices",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
conditions: [
|
||||
{ kind: "event_match", key: "type", pattern: "m.room.member" },
|
||||
{ kind: "event_match", key: "content.membership", pattern: "invite" },
|
||||
{ kind: "event_match", key: "state_key", pattern: "@kadev1:matrix.org" },
|
||||
],
|
||||
actions: ["notify", { set_tweak: "sound", value: "default" }, { set_tweak: "highlight", value: false }],
|
||||
rule_id: ".m.rule.invite_for_me",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
conditions: [{ kind: "event_match", key: "type", pattern: "m.room.member" }],
|
||||
actions: ["dont_notify"],
|
||||
rule_id: ".m.rule.member_event",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
conditions: [{ kind: "contains_display_name" }],
|
||||
actions: ["notify", { set_tweak: "sound", value: "default" }, { set_tweak: "highlight" }],
|
||||
rule_id: ".m.rule.contains_display_name",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
conditions: [
|
||||
{ kind: "event_match", key: "content.body", pattern: "@room" },
|
||||
{ kind: "sender_notification_permission", key: "room" },
|
||||
],
|
||||
actions: ["notify", { set_tweak: "highlight", value: true }],
|
||||
rule_id: ".m.rule.roomnotif",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
conditions: [
|
||||
{ kind: "event_match", key: "type", pattern: "m.room.tombstone" },
|
||||
{ kind: "event_match", key: "state_key", pattern: "" },
|
||||
],
|
||||
actions: ["notify", { set_tweak: "highlight", value: true }],
|
||||
rule_id: ".m.rule.tombstone",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
conditions: [{ kind: "event_match", key: "type", pattern: "m.reaction" }],
|
||||
actions: ["dont_notify"],
|
||||
rule_id: ".m.rule.reaction",
|
||||
default: true,
|
||||
enabled: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
device: {},
|
||||
} as IPushRules;
|
||||
|
||||
const flushPromises = async () => await new Promise(resolve => window.setTimeout(resolve));
|
||||
const flushPromises = async () => await new Promise((resolve) => window.setTimeout(resolve));
|
||||
|
||||
describe('<Notifications />', () => {
|
||||
describe("<Notifications />", () => {
|
||||
const getComponent = () => render(<Notifications />);
|
||||
|
||||
// get component, wait for async data and force a render
|
||||
@@ -74,7 +212,7 @@ describe('<Notifications />', () => {
|
||||
setPushRuleEnabled: jest.fn(),
|
||||
setPushRuleActions: jest.fn(),
|
||||
getRooms: jest.fn().mockReturnValue([]),
|
||||
getAccountData: jest.fn().mockImplementation(eventType => {
|
||||
getAccountData: jest.fn().mockImplementation((eventType) => {
|
||||
if (eventType.startsWith(LOCAL_NOTIFICATION_SETTINGS_PREFIX.name)) {
|
||||
return new MatrixEvent({
|
||||
type: eventType,
|
||||
@@ -97,29 +235,29 @@ describe('<Notifications />', () => {
|
||||
mockClient.setPusher.mockClear().mockResolvedValue({});
|
||||
});
|
||||
|
||||
it('renders spinner while loading', async () => {
|
||||
it("renders spinner while loading", async () => {
|
||||
getComponent();
|
||||
expect(screen.getByTestId('spinner')).toBeInTheDocument();
|
||||
expect(screen.getByTestId("spinner")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders error message when fetching push rules fails', async () => {
|
||||
it("renders error message when fetching push rules fails", async () => {
|
||||
mockClient.getPushRules.mockRejectedValue({});
|
||||
await getComponentAndWait();
|
||||
expect(screen.getByTestId('error-message')).toBeInTheDocument();
|
||||
expect(screen.getByTestId("error-message")).toBeInTheDocument();
|
||||
});
|
||||
it('renders error message when fetching pushers fails', async () => {
|
||||
it("renders error message when fetching pushers fails", async () => {
|
||||
mockClient.getPushers.mockRejectedValue({});
|
||||
await getComponentAndWait();
|
||||
expect(screen.getByTestId('error-message')).toBeInTheDocument();
|
||||
expect(screen.getByTestId("error-message")).toBeInTheDocument();
|
||||
});
|
||||
it('renders error message when fetching threepids fails', async () => {
|
||||
it("renders error message when fetching threepids fails", async () => {
|
||||
mockClient.getThreePids.mockRejectedValue({});
|
||||
await getComponentAndWait();
|
||||
expect(screen.getByTestId('error-message')).toBeInTheDocument();
|
||||
expect(screen.getByTestId("error-message")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('main notification switches', () => {
|
||||
it('renders only enable notifications switch when notifications are disabled', async () => {
|
||||
describe("main notification switches", () => {
|
||||
it("renders only enable notifications switch when notifications are disabled", async () => {
|
||||
const disableNotificationsPushRules = {
|
||||
global: {
|
||||
...pushRules.global,
|
||||
@@ -131,18 +269,18 @@ describe('<Notifications />', () => {
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
it('renders switches correctly', async () => {
|
||||
it("renders switches correctly", async () => {
|
||||
await getComponentAndWait();
|
||||
|
||||
expect(screen.getByTestId('notif-master-switch')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('notif-device-switch')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('notif-setting-notificationsEnabled')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('notif-setting-notificationBodyEnabled')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('notif-setting-audioNotificationsEnabled')).toBeInTheDocument();
|
||||
expect(screen.getByTestId("notif-master-switch")).toBeInTheDocument();
|
||||
expect(screen.getByTestId("notif-device-switch")).toBeInTheDocument();
|
||||
expect(screen.getByTestId("notif-setting-notificationsEnabled")).toBeInTheDocument();
|
||||
expect(screen.getByTestId("notif-setting-notificationBodyEnabled")).toBeInTheDocument();
|
||||
expect(screen.getByTestId("notif-setting-audioNotificationsEnabled")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
describe('email switches', () => {
|
||||
const testEmail = 'tester@test.com';
|
||||
describe("email switches", () => {
|
||||
const testEmail = "tester@test.com";
|
||||
beforeEach(() => {
|
||||
mockClient.getThreePids.mockResolvedValue({
|
||||
threepids: [
|
||||
@@ -155,49 +293,47 @@ describe('<Notifications />', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('renders email switches correctly when email 3pids exist', async () => {
|
||||
it("renders email switches correctly when email 3pids exist", async () => {
|
||||
await getComponentAndWait();
|
||||
expect(screen.getByTestId('notif-email-switch')).toBeInTheDocument();
|
||||
expect(screen.getByTestId("notif-email-switch")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders email switches correctly when notifications are on for email', async () => {
|
||||
it("renders email switches correctly when notifications are on for email", async () => {
|
||||
mockClient.getPushers.mockResolvedValue({
|
||||
pushers: [
|
||||
{ kind: 'email', pushkey: testEmail } as unknown as IPusher,
|
||||
],
|
||||
pushers: [{ kind: "email", pushkey: testEmail } as unknown as IPusher],
|
||||
});
|
||||
await getComponentAndWait();
|
||||
|
||||
const emailSwitch = screen.getByTestId('notif-email-switch');
|
||||
const emailSwitch = screen.getByTestId("notif-email-switch");
|
||||
expect(emailSwitch.querySelector('[aria-checked="true"]')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('enables email notification when toggling on', async () => {
|
||||
it("enables email notification when toggling on", async () => {
|
||||
await getComponentAndWait();
|
||||
|
||||
const emailToggle = screen.getByTestId('notif-email-switch')
|
||||
.querySelector('div[role="switch"]');
|
||||
const emailToggle = screen.getByTestId("notif-email-switch").querySelector('div[role="switch"]');
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(emailToggle);
|
||||
});
|
||||
|
||||
expect(mockClient.setPusher).toHaveBeenCalledWith(expect.objectContaining({
|
||||
kind: "email",
|
||||
app_id: "m.email",
|
||||
pushkey: testEmail,
|
||||
app_display_name: "Email Notifications",
|
||||
device_display_name: testEmail,
|
||||
append: true,
|
||||
}));
|
||||
expect(mockClient.setPusher).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
kind: "email",
|
||||
app_id: "m.email",
|
||||
pushkey: testEmail,
|
||||
app_display_name: "Email Notifications",
|
||||
device_display_name: testEmail,
|
||||
append: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('displays error when pusher update fails', async () => {
|
||||
it("displays error when pusher update fails", async () => {
|
||||
mockClient.setPusher.mockRejectedValue({});
|
||||
await getComponentAndWait();
|
||||
|
||||
const emailToggle = screen.getByTestId('notif-email-switch')
|
||||
.querySelector('div[role="switch"]');
|
||||
const emailToggle = screen.getByTestId("notif-email-switch").querySelector('div[role="switch"]');
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(emailToggle);
|
||||
@@ -206,33 +342,34 @@ describe('<Notifications />', () => {
|
||||
// force render
|
||||
await flushPromises();
|
||||
|
||||
expect(screen.getByTestId('error-message')).toBeInTheDocument();
|
||||
expect(screen.getByTestId("error-message")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('enables email notification when toggling off', async () => {
|
||||
const testPusher = { kind: 'email', pushkey: 'tester@test.com' } as unknown as IPusher;
|
||||
it("enables email notification when toggling off", async () => {
|
||||
const testPusher = { kind: "email", pushkey: "tester@test.com" } as unknown as IPusher;
|
||||
mockClient.getPushers.mockResolvedValue({ pushers: [testPusher] });
|
||||
await getComponentAndWait();
|
||||
|
||||
const emailToggle = screen.getByTestId('notif-email-switch')
|
||||
.querySelector('div[role="switch"]');
|
||||
const emailToggle = screen.getByTestId("notif-email-switch").querySelector('div[role="switch"]');
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(emailToggle);
|
||||
});
|
||||
|
||||
expect(mockClient.setPusher).toHaveBeenCalledWith({
|
||||
...testPusher, kind: null,
|
||||
...testPusher,
|
||||
kind: null,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('toggles and sets settings correctly', async () => {
|
||||
it("toggles and sets settings correctly", async () => {
|
||||
await getComponentAndWait();
|
||||
let audioNotifsToggle;
|
||||
|
||||
const update = () => {
|
||||
audioNotifsToggle = screen.getByTestId('notif-setting-audioNotificationsEnabled')
|
||||
audioNotifsToggle = screen
|
||||
.getByTestId("notif-setting-audioNotificationsEnabled")
|
||||
.querySelector('div[role="switch"]');
|
||||
};
|
||||
update();
|
||||
@@ -240,7 +377,9 @@ describe('<Notifications />', () => {
|
||||
expect(audioNotifsToggle.getAttribute("aria-checked")).toEqual("true");
|
||||
expect(SettingsStore.getValue("audioNotificationsEnabled")).toEqual(true);
|
||||
|
||||
act(() => { fireEvent.click(audioNotifsToggle); });
|
||||
act(() => {
|
||||
fireEvent.click(audioNotifsToggle);
|
||||
});
|
||||
update();
|
||||
|
||||
expect(audioNotifsToggle.getAttribute("aria-checked")).toEqual("false");
|
||||
@@ -248,22 +387,22 @@ describe('<Notifications />', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('individual notification level settings', () => {
|
||||
it('renders categories correctly', async () => {
|
||||
describe("individual notification level settings", () => {
|
||||
it("renders categories correctly", async () => {
|
||||
await getComponentAndWait();
|
||||
|
||||
expect(screen.getByTestId('notif-section-vector_global')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('notif-section-vector_mentions')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('notif-section-vector_other')).toBeInTheDocument();
|
||||
expect(screen.getByTestId("notif-section-vector_global")).toBeInTheDocument();
|
||||
expect(screen.getByTestId("notif-section-vector_mentions")).toBeInTheDocument();
|
||||
expect(screen.getByTestId("notif-section-vector_other")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders radios correctly', async () => {
|
||||
it("renders radios correctly", async () => {
|
||||
await getComponentAndWait();
|
||||
const section = 'vector_global';
|
||||
const section = "vector_global";
|
||||
|
||||
const globalSection = screen.getByTestId(`notif-section-${section}`);
|
||||
// 4 notification rules with class 'global'
|
||||
expect(globalSection.querySelectorAll('fieldset').length).toEqual(4);
|
||||
expect(globalSection.querySelectorAll("fieldset").length).toEqual(4);
|
||||
// oneToOneRule is set to 'on'
|
||||
const oneToOneRuleElement = screen.getByTestId(section + oneToOneRule.rule_id);
|
||||
expect(oneToOneRuleElement.querySelector("[aria-label='On']")).toBeInTheDocument();
|
||||
@@ -275,9 +414,9 @@ describe('<Notifications />', () => {
|
||||
expect(encryptedGroupElement.querySelector("[aria-label='Off']")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('updates notification level when changed', async () => {
|
||||
it("updates notification level when changed", async () => {
|
||||
await getComponentAndWait();
|
||||
const section = 'vector_global';
|
||||
const section = "vector_global";
|
||||
|
||||
// oneToOneRule is set to 'on'
|
||||
// and is kind: 'underride'
|
||||
@@ -289,11 +428,19 @@ describe('<Notifications />', () => {
|
||||
});
|
||||
|
||||
expect(mockClient.setPushRuleEnabled).toHaveBeenCalledWith(
|
||||
'global', 'underride', oneToOneRule.rule_id, true);
|
||||
"global",
|
||||
"underride",
|
||||
oneToOneRule.rule_id,
|
||||
true,
|
||||
);
|
||||
|
||||
// actions for '.m.rule.room_one_to_one' state is ACTION_DONT_NOTIFY
|
||||
expect(mockClient.setPushRuleActions).toHaveBeenCalledWith(
|
||||
'global', 'underride', oneToOneRule.rule_id, StandardActions.ACTION_DONT_NOTIFY);
|
||||
"global",
|
||||
"underride",
|
||||
oneToOneRule.rule_id,
|
||||
StandardActions.ACTION_DONT_NOTIFY,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user