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

Commit e246c6a

Browse files
author
Kerry
authored
Merge branch 'psg-906/poll-history-active-filter' into psg-1030/poll-history-extract-poll-option
2 parents 4a41ee4 + eeffebc commit e246c6a

File tree

13 files changed

+97
-111
lines changed

13 files changed

+97
-111
lines changed

.github/workflows/static_analysis.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ jobs:
5252
- "--noImplicitAny"
5353
steps:
5454
- uses: actions/checkout@v3
55+
with:
56+
ref: ${{ github.event.pull_request.head.sha }}
5557

5658
- name: Install Deps
5759
run: "scripts/ci/layered.sh"

src/components/views/location/ZoomButtons.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ const ZoomButtons: React.FC<Props> = ({ map }) => {
3939
<div className="mx_ZoomButtons">
4040
<AccessibleButton
4141
onClick={onZoomIn}
42-
data-test-id="map-zoom-in-button"
42+
data-testid="map-zoom-in-button"
4343
title={_t("Zoom in")}
4444
className="mx_ZoomButtons_button"
4545
>
4646
<PlusIcon className="mx_ZoomButtons_icon" />
4747
</AccessibleButton>
4848
<AccessibleButton
4949
onClick={onZoomOut}
50-
data-test-id="map-zoom-out-button"
50+
data-testid="map-zoom-out-button"
5151
title={_t("Zoom out")}
5252
className="mx_ZoomButtons_button"
5353
>

src/components/views/rooms/BasicMessageComposer.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,19 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
191191
public replaceEmoticon(caretPosition: DocumentPosition, regex: RegExp): number {
192192
const { model } = this.props;
193193
const range = model.startRange(caretPosition);
194-
// expand range max 8 characters backwards from caretPosition,
194+
// expand range max 9 characters backwards from caretPosition,
195195
// as a space to look for an emoticon
196-
let n = 8;
196+
let n = 9;
197197
range.expandBackwardsWhile((index, offset) => {
198198
const part = model.parts[index];
199199
n -= 1;
200200
return n >= 0 && [Type.Plain, Type.PillCandidate, Type.Newline].includes(part.type);
201201
});
202202
const emoticonMatch = regex.exec(range.text);
203-
if (emoticonMatch) {
203+
// ignore matches at start of proper substrings
204+
// so xd will not match if the string was "mixd 123456"
205+
// and we are lookinh at xd 123456 part of the string
206+
if (emoticonMatch && (n >= 0 || emoticonMatch.index !== 0)) {
204207
const query = emoticonMatch[1].replace("-", "");
205208
// try both exact match and lower-case, this means that xd won't match xD but :P will match :p
206209
const data = EMOTICON_TO_EMOJI.get(query) || EMOTICON_TO_EMOJI.get(query.toLowerCase());

src/effects/confetti/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
Copyright 2020 Nurjin Jafar
33
Copyright 2020 Nordeck IT + Consulting GmbH.
4+
Copyright 2023 The Matrix.org Foundation C.I.C.
45
56
Licensed under the Apache License, Version 2.0 (the "License");
67
you may not use this file except in compliance with the License.
@@ -86,7 +87,7 @@ export default class Confetti implements ICanvasEffect {
8687
private particles: Array<ConfettiParticle> = [];
8788
private waveAngle = 0;
8889

89-
public isRunning: boolean;
90+
public isRunning = false;
9091

9192
public start = async (canvas: HTMLCanvasElement, timeout = 3000): Promise<void> => {
9293
if (!canvas) {

src/effects/fireworks/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
Copyright 2020 Nurjin Jafar
33
Copyright 2020 Nordeck IT + Consulting GmbH.
4+
Copyright 2023 The Matrix.org Foundation C.I.C.
45
56
Licensed under the Apache License, Version 2.0 (the "License");
67
you may not use this file except in compliance with the License.
@@ -69,7 +70,7 @@ export default class Fireworks implements ICanvasEffect {
6970
private context: CanvasRenderingContext2D | null = null;
7071
private supportsAnimationFrame = window.requestAnimationFrame;
7172
private particles: Array<FireworksParticle> = [];
72-
public isRunning: boolean;
73+
public isRunning = false;
7374

7475
public start = async (canvas: HTMLCanvasElement, timeout = 3000): Promise<void> => {
7576
if (!canvas) {
@@ -94,7 +95,7 @@ export default class Fireworks implements ICanvasEffect {
9495
if (this.particles.length < this.options.maxCount && this.isRunning) {
9596
this.createFirework();
9697
}
97-
const alive = [];
98+
const alive: FireworksParticle[] = [];
9899
for (let i = 0; i < this.particles.length; i++) {
99100
if (this.move(this.particles[i])) {
100101
alive.push(this.particles[i]);

src/effects/hearts/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2021 The Matrix.org Foundation C.I.C.
2+
Copyright 2021 - 2023 The Matrix.org Foundation C.I.C.
33
Copyright 2022 Arseny Uskov
44
55
Licensed under the Apache License, Version 2.0 (the "License");
@@ -65,7 +65,7 @@ export default class Hearts implements ICanvasEffect {
6565

6666
private context: CanvasRenderingContext2D | null = null;
6767
private particles: Array<Heart> = [];
68-
private lastAnimationTime: number;
68+
private lastAnimationTime = 0;
6969

7070
private colours = [
7171
"rgba(194,210,224,1)",
@@ -82,7 +82,7 @@ export default class Hearts implements ICanvasEffect {
8282
"rgba(252,116,183,1)",
8383
];
8484

85-
public isRunning: boolean;
85+
public isRunning = false;
8686

8787
public start = async (canvas: HTMLCanvasElement, timeout = 3000): Promise<void> => {
8888
if (!canvas) {

src/effects/rainfall/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2020 The Matrix.org Foundation C.I.C.
2+
Copyright 2020 - 2023 The Matrix.org Foundation C.I.C.
33
Copyright 2021 Josias Allestad
44
55
Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,9 +52,9 @@ export default class Rainfall implements ICanvasEffect {
5252

5353
private context: CanvasRenderingContext2D | null = null;
5454
private particles: Array<Raindrop> = [];
55-
private lastAnimationTime: number;
55+
private lastAnimationTime = 0;
5656

57-
public isRunning: boolean;
57+
public isRunning = false;
5858

5959
public start = async (canvas: HTMLCanvasElement, timeout = 3000): Promise<void> => {
6060
if (!canvas) {

src/effects/snowfall/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2020 The Matrix.org Foundation C.I.C.
2+
Copyright 2020 - 2023 The Matrix.org Foundation C.I.C.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -57,9 +57,9 @@ export default class Snowfall implements ICanvasEffect {
5757

5858
private context: CanvasRenderingContext2D | null = null;
5959
private particles: Array<Snowflake> = [];
60-
private lastAnimationTime: number;
60+
private lastAnimationTime = 0;
6161

62-
public isRunning: boolean;
62+
public isRunning = false;
6363

6464
public start = async (canvas: HTMLCanvasElement, timeout = 3000): Promise<void> => {
6565
if (!canvas) {

src/effects/spaceinvaders/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2021 The Matrix.org Foundation C.I.C.
2+
Copyright 2021 - 2023 The Matrix.org Foundation C.I.C.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -51,9 +51,9 @@ export default class SpaceInvaders implements ICanvasEffect {
5151

5252
private context: CanvasRenderingContext2D | null = null;
5353
private particles: Array<Invader> = [];
54-
private lastAnimationTime: number;
54+
private lastAnimationTime = 0;
5555

56-
public isRunning: boolean;
56+
public isRunning = false;
5757

5858
public start = async (canvas: HTMLCanvasElement, timeout = 3000): Promise<void> => {
5959
if (!canvas) {

test/components/views/location/ZoomButtons-test.tsx

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Matrix.org Foundation C.I.C.
2+
Copyright 2022, 2023 The Matrix.org Foundation C.I.C.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -15,48 +15,39 @@ limitations under the License.
1515
*/
1616

1717
import React from "react";
18-
// eslint-disable-next-line deprecate/import
19-
import { mount } from "enzyme";
2018
import * as maplibregl from "maplibre-gl";
21-
import { act } from "react-dom/test-utils";
19+
import { render, screen } from "@testing-library/react";
2220

2321
import ZoomButtons from "../../../../src/components/views/location/ZoomButtons";
24-
import { findByTestId } from "../../../test-utils";
2522

2623
describe("<ZoomButtons />", () => {
2724
const mapOptions = { container: {} as unknown as HTMLElement, style: "" };
2825
const mockMap = new maplibregl.Map(mapOptions);
2926
const defaultProps = {
3027
map: mockMap,
3128
};
32-
const getComponent = (props = {}) => mount(<ZoomButtons {...defaultProps} {...props} />);
29+
const getComponent = (props = {}) => render(<ZoomButtons {...defaultProps} {...props} />);
3330

3431
beforeEach(() => {
3532
jest.clearAllMocks();
3633
});
3734

3835
it("renders buttons", () => {
3936
const component = getComponent();
40-
expect(component).toMatchSnapshot();
37+
expect(component.asFragment()).toMatchSnapshot();
4138
});
4239

4340
it("calls map zoom in on zoom in click", () => {
4441
const component = getComponent();
45-
46-
act(() => {
47-
findByTestId(component, "map-zoom-in-button").at(0).simulate("click");
48-
});
42+
screen.getByTestId("map-zoom-in-button").click();
4943

5044
expect(mockMap.zoomIn).toHaveBeenCalled();
5145
expect(component).toBeTruthy();
5246
});
5347

5448
it("calls map zoom out on zoom out click", () => {
5549
const component = getComponent();
56-
57-
act(() => {
58-
findByTestId(component, "map-zoom-out-button").at(0).simulate("click");
59-
});
50+
screen.getByTestId("map-zoom-out-button").click();
6051

6152
expect(mockMap.zoomOut).toHaveBeenCalled();
6253
expect(component).toBeTruthy();

test/components/views/location/__snapshots__/LocationViewDialog-test.tsx.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
135135
>
136136
<AccessibleButton
137137
className="mx_ZoomButtons_button"
138-
data-test-id="map-zoom-in-button"
138+
data-testid="map-zoom-in-button"
139139
element="div"
140140
onClick={[Function]}
141141
role="button"
@@ -144,7 +144,7 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
144144
>
145145
<div
146146
className="mx_AccessibleButton mx_ZoomButtons_button"
147-
data-test-id="map-zoom-in-button"
147+
data-testid="map-zoom-in-button"
148148
onClick={[Function]}
149149
onKeyDown={[Function]}
150150
onKeyUp={[Function]}
@@ -159,7 +159,7 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
159159
</AccessibleButton>
160160
<AccessibleButton
161161
className="mx_ZoomButtons_button"
162-
data-test-id="map-zoom-out-button"
162+
data-testid="map-zoom-out-button"
163163
element="div"
164164
onClick={[Function]}
165165
role="button"
@@ -168,7 +168,7 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
168168
>
169169
<div
170170
className="mx_AccessibleButton mx_ZoomButtons_button"
171-
data-test-id="map-zoom-out-button"
171+
data-testid="map-zoom-out-button"
172172
onClick={[Function]}
173173
onKeyDown={[Function]}
174174
onKeyUp={[Function]}
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,32 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`<ZoomButtons /> renders buttons 1`] = `
4-
<ZoomButtons
5-
map={
6-
MockMap {
7-
"_events": {},
8-
"_eventsCount": 0,
9-
"_maxListeners": undefined,
10-
"addControl": [MockFunction],
11-
"fitBounds": [MockFunction],
12-
"removeControl": [MockFunction],
13-
"setCenter": [MockFunction],
14-
"setStyle": [MockFunction],
15-
"zoomIn": [MockFunction],
16-
"zoomOut": [MockFunction],
17-
Symbol(kCapture): false,
18-
}
19-
}
20-
>
4+
<DocumentFragment>
215
<div
22-
className="mx_ZoomButtons"
6+
class="mx_ZoomButtons"
237
>
24-
<AccessibleButton
25-
className="mx_ZoomButtons_button"
26-
data-test-id="map-zoom-in-button"
27-
element="div"
28-
onClick={[Function]}
8+
<div
9+
class="mx_AccessibleButton mx_ZoomButtons_button"
10+
data-testid="map-zoom-in-button"
2911
role="button"
30-
tabIndex={0}
12+
tabindex="0"
3113
title="Zoom in"
3214
>
3315
<div
34-
className="mx_AccessibleButton mx_ZoomButtons_button"
35-
data-test-id="map-zoom-in-button"
36-
onClick={[Function]}
37-
onKeyDown={[Function]}
38-
onKeyUp={[Function]}
39-
role="button"
40-
tabIndex={0}
41-
title="Zoom in"
42-
>
43-
<div
44-
className="mx_ZoomButtons_icon"
45-
/>
46-
</div>
47-
</AccessibleButton>
48-
<AccessibleButton
49-
className="mx_ZoomButtons_button"
50-
data-test-id="map-zoom-out-button"
51-
element="div"
52-
onClick={[Function]}
16+
class="mx_ZoomButtons_icon"
17+
/>
18+
</div>
19+
<div
20+
class="mx_AccessibleButton mx_ZoomButtons_button"
21+
data-testid="map-zoom-out-button"
5322
role="button"
54-
tabIndex={0}
23+
tabindex="0"
5524
title="Zoom out"
5625
>
5726
<div
58-
className="mx_AccessibleButton mx_ZoomButtons_button"
59-
data-test-id="map-zoom-out-button"
60-
onClick={[Function]}
61-
onKeyDown={[Function]}
62-
onKeyUp={[Function]}
63-
role="button"
64-
tabIndex={0}
65-
title="Zoom out"
66-
>
67-
<div
68-
className="mx_ZoomButtons_icon"
69-
/>
70-
</div>
71-
</AccessibleButton>
27+
class="mx_ZoomButtons_icon"
28+
/>
29+
</div>
7230
</div>
73-
</ZoomButtons>
31+
</DocumentFragment>
7432
`;

0 commit comments

Comments
 (0)