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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 3 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 6 additions & 15 deletions
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();

0 commit comments

Comments
 (0)