Skip to content

Commit 9086af1

Browse files
authored
Merge branch 'master' into feature/renove_lodash_omit
2 parents 88ff423 + 1bf03e8 commit 9086af1

39 files changed

+569
-381
lines changed

docs/SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ We take the security and integrity of Monkeytype very seriously. If you have fou
44

55
### Reporting a Vulnerability
66

7-
For vulnerabilities that impact the confidentiality, integrity, and availability of Monkeytype services, please send your disclosure via [email]([email protected]). For non-security related platform bugs, follow the bug submission [guidelines](https://github.com/monkeytypegame/monkeytype#bug-report-or-feature-request). Include as much detail as possible to ensure reproducibility. At a minimum, vulnerability disclosures should include:
7+
For vulnerabilities that impact the confidentiality, integrity, and availability of Monkeytype services, please send your disclosure via [email](mailto:[email protected]). For non-security related platform bugs, follow the bug submission [guidelines](https://github.com/monkeytypegame/monkeytype#bug-report-or-feature-request). Include as much detail as possible to ensure reproducibility. At a minimum, vulnerability disclosures should include:
88

99
- Vulnerability Description
1010
- Proof of Concept

frontend/__tests__/utils/strings.spec.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ describe("string utils", () => {
270270
);
271271
});
272272

273-
describe("getWordDirection", () => {
273+
describe("isWordRightToLeft", () => {
274274
beforeEach(() => {
275275
Strings.clearWordDirectionCache();
276276
});
@@ -321,13 +321,27 @@ describe("string utils", () => {
321321
languageRTL: boolean,
322322
_description: string
323323
) => {
324-
expect(Strings.getWordDirection(word, languageRTL)).toBe(expected);
324+
expect(Strings.isWordRightToLeft(word, languageRTL)).toBe(expected);
325325
}
326326
);
327327

328328
it("should return languageRTL for undefined word", () => {
329-
expect(Strings.getWordDirection(undefined, false)).toBe(false);
330-
expect(Strings.getWordDirection(undefined, true)).toBe(true);
329+
expect(Strings.isWordRightToLeft(undefined, false)).toBe(false);
330+
expect(Strings.isWordRightToLeft(undefined, true)).toBe(true);
331+
});
332+
333+
// testing reverseDirection
334+
it("should return true for LTR word with reversed direction", () => {
335+
expect(Strings.isWordRightToLeft("hello", false, true)).toBe(true);
336+
expect(Strings.isWordRightToLeft("hello", true, true)).toBe(true);
337+
});
338+
it("should return false for RTL word with reversed direction", () => {
339+
expect(Strings.isWordRightToLeft("مرحبا", true, true)).toBe(false);
340+
expect(Strings.isWordRightToLeft("مرحبا", false, true)).toBe(false);
341+
});
342+
it("should return reverse of languageRTL for undefined word with reversed direction", () => {
343+
expect(Strings.isWordRightToLeft(undefined, false, true)).toBe(true);
344+
expect(Strings.isWordRightToLeft(undefined, true, true)).toBe(false);
331345
});
332346

333347
describe("caching", () => {
@@ -349,7 +363,7 @@ describe("string utils", () => {
349363

350364
it("should use cache for repeated calls", () => {
351365
// First call should cache the result (cache miss)
352-
const result1 = Strings.getWordDirection("hello", false);
366+
const result1 = Strings.isWordRightToLeft("hello", false);
353367
expect(result1).toBe(false);
354368
expect(mapSetSpy).toHaveBeenCalledWith("hello", false);
355369

@@ -358,7 +372,7 @@ describe("string utils", () => {
358372
mapSetSpy.mockClear();
359373

360374
// Second call should use cache (cache hit)
361-
const result2 = Strings.getWordDirection("hello", false);
375+
const result2 = Strings.isWordRightToLeft("hello", false);
362376
expect(result2).toBe(false);
363377
expect(mapGetSpy).toHaveBeenCalledWith("hello");
364378
expect(mapSetSpy).not.toHaveBeenCalled(); // Should not set again
@@ -367,47 +381,47 @@ describe("string utils", () => {
367381
mapGetSpy.mockClear();
368382
mapSetSpy.mockClear();
369383

370-
const result3 = Strings.getWordDirection("hello", true);
384+
const result3 = Strings.isWordRightToLeft("hello", true);
371385
expect(result3).toBe(false); // Still false because "hello" is LTR regardless of language
372386
expect(mapGetSpy).toHaveBeenCalledWith("hello");
373387
expect(mapSetSpy).not.toHaveBeenCalled(); // Should not set again
374388
});
375389

376390
it("should cache based on core word without punctuation", () => {
377391
// First call should cache the result for core "hello"
378-
const result1 = Strings.getWordDirection("hello", false);
392+
const result1 = Strings.isWordRightToLeft("hello", false);
379393
expect(result1).toBe(false);
380394
expect(mapSetSpy).toHaveBeenCalledWith("hello", false);
381395

382396
mapGetSpy.mockClear();
383397
mapSetSpy.mockClear();
384398

385399
// These should all use the same cache entry since they have the same core
386-
const result2 = Strings.getWordDirection("hello!", false);
400+
const result2 = Strings.isWordRightToLeft("hello!", false);
387401
expect(result2).toBe(false);
388402
expect(mapGetSpy).toHaveBeenCalledWith("hello");
389403
expect(mapSetSpy).not.toHaveBeenCalled();
390404

391405
mapGetSpy.mockClear();
392406
mapSetSpy.mockClear();
393407

394-
const result3 = Strings.getWordDirection("!hello", false);
408+
const result3 = Strings.isWordRightToLeft("!hello", false);
395409
expect(result3).toBe(false);
396410
expect(mapGetSpy).toHaveBeenCalledWith("hello");
397411
expect(mapSetSpy).not.toHaveBeenCalled();
398412

399413
mapGetSpy.mockClear();
400414
mapSetSpy.mockClear();
401415

402-
const result4 = Strings.getWordDirection("!hello!", false);
416+
const result4 = Strings.isWordRightToLeft("!hello!", false);
403417
expect(result4).toBe(false);
404418
expect(mapGetSpy).toHaveBeenCalledWith("hello");
405419
expect(mapSetSpy).not.toHaveBeenCalled();
406420
});
407421

408422
it("should handle cache clearing", () => {
409423
// Cache a result
410-
Strings.getWordDirection("test", false);
424+
Strings.isWordRightToLeft("test", false);
411425
expect(mapSetSpy).toHaveBeenCalledWith("test", false);
412426

413427
// Clear cache
@@ -419,14 +433,14 @@ describe("string utils", () => {
419433
mapClearSpy.mockClear();
420434

421435
// Should work normally after cache clear (cache miss again)
422-
const result = Strings.getWordDirection("test", false);
436+
const result = Strings.isWordRightToLeft("test", false);
423437
expect(result).toBe(false);
424438
expect(mapSetSpy).toHaveBeenCalledWith("test", false);
425439
});
426440

427441
it("should demonstrate cache miss vs cache hit behavior", () => {
428442
// Test cache miss - first time seeing this word
429-
const result1 = Strings.getWordDirection("unique", false);
443+
const result1 = Strings.isWordRightToLeft("unique", false);
430444
expect(result1).toBe(false);
431445
expect(mapGetSpy).toHaveBeenCalledWith("unique");
432446
expect(mapSetSpy).toHaveBeenCalledWith("unique", false);
@@ -435,7 +449,7 @@ describe("string utils", () => {
435449
mapSetSpy.mockClear();
436450

437451
// Test cache hit - same word again
438-
const result2 = Strings.getWordDirection("unique", false);
452+
const result2 = Strings.isWordRightToLeft("unique", false);
439453
expect(result2).toBe(false);
440454
expect(mapGetSpy).toHaveBeenCalledWith("unique");
441455
expect(mapSetSpy).not.toHaveBeenCalled(); // No cache set on hit
@@ -444,7 +458,7 @@ describe("string utils", () => {
444458
mapSetSpy.mockClear();
445459

446460
// Test cache miss - different word
447-
const result3 = Strings.getWordDirection("different", false);
461+
const result3 = Strings.isWordRightToLeft("different", false);
448462
expect(result3).toBe(false);
449463
expect(mapGetSpy).toHaveBeenCalledWith("different");
450464
expect(mapSetSpy).toHaveBeenCalledWith("different", false);

frontend/src/html/popups.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
<div class="title">sentry</div>
179179
<div class="description">
180180
We use Sentry to track errors and performance issues on our site, as
181-
well as record annonymized user sessions to help us debug issues and
181+
well as record anonymized user sessions to help us debug issues and
182182
improve our product.
183183
</div>
184184
<input type="checkbox" />

frontend/src/privacy-policy.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ <h1 id="Sentry">Sentry</h1>
307307
Sentry is a crash reporting service that helps us track errors and
308308
crashes on the website. It collects information about your device,
309309
browser, and the error that occurred. Sometimes it might also include
310-
an annonymized replay of your session. This information is used to
310+
an anonymized replay of your session. This information is used to
311311
track down bugs faster and improve our website.
312312
</p>
313313
<p>

frontend/src/styles/fonts.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
@use "sass:map";
22

3+
@font-face {
4+
font-family: "Vazirmatn";
5+
font-style: normal;
6+
font-weight: 400;
7+
font-display: block;
8+
src: url("/webfonts/Vazirmatn-Regular.woff2") format("woff2");
9+
}
10+
311
@each $font, $config in $fonts {
412
$dir: "webfonts";
513
$previewDir: "webfonts-preview";

frontend/src/styles/test.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,6 @@
307307
&.rightToLeftTest {
308308
//flex-direction: row-reverse; // no need for hacking 😉, CSS fully support right-to-left languages
309309
direction: rtl;
310-
.word {
311-
//flex-direction: row-reverse;
312-
direction: rtl;
313-
}
314310
}
315311
&.withLigatures {
316312
.word {
@@ -749,10 +745,6 @@
749745
&.rightToLeftTest {
750746
//flex-direction: row-reverse; // no need for hacking 😉, CSS fully support right-to-left languages
751747
direction: rtl;
752-
.word {
753-
//flex-direction: row-reverse;
754-
direction: rtl;
755-
}
756748
}
757749
&.withLigatures {
758750
.word {

frontend/src/ts/commandline/lists/result-screen.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as TestUI from "../../test/test-ui";
33
import * as PractiseWordsModal from "../../modals/practise-words";
44
import * as Notifications from "../../elements/notifications";
55
import * as TestInput from "../../test/test-input";
6+
import * as TestState from "../../test/test-state";
67
import * as TestWords from "../../test/test-words";
78
import Config from "../../config";
89
import * as PractiseWords from "../../test/practise-words";
@@ -53,7 +54,7 @@ const commands: Command[] = [
5354
alias: "restart start begin type test typing",
5455
icon: "fa-chevron-right",
5556
available: (): boolean => {
56-
return TestUI.resultVisible;
57+
return TestState.resultVisible;
5758
},
5859
exec: (): void => {
5960
TestLogic.restart();
@@ -69,7 +70,7 @@ const commands: Command[] = [
6970
});
7071
},
7172
available: (): boolean => {
72-
return TestUI.resultVisible;
73+
return TestState.resultVisible;
7374
},
7475
},
7576
{
@@ -78,7 +79,7 @@ const commands: Command[] = [
7879
icon: "fa-exclamation-triangle",
7980
subgroup: practiceSubgroup,
8081
available: (): boolean => {
81-
return TestUI.resultVisible;
82+
return TestState.resultVisible;
8283
},
8384
},
8485
{
@@ -89,7 +90,7 @@ const commands: Command[] = [
8990
TestUI.toggleResultWords();
9091
},
9192
available: (): boolean => {
92-
return TestUI.resultVisible;
93+
return TestState.resultVisible;
9394
},
9495
},
9596
{
@@ -103,7 +104,7 @@ const commands: Command[] = [
103104
}, 500);
104105
},
105106
available: (): boolean => {
106-
return TestUI.resultVisible;
107+
return TestState.resultVisible;
107108
},
108109
},
109110
{
@@ -117,7 +118,7 @@ const commands: Command[] = [
117118
}, 500);
118119
},
119120
available: (): boolean => {
120-
return TestUI.resultVisible;
121+
return TestState.resultVisible;
121122
},
122123
},
123124
{
@@ -141,7 +142,7 @@ const commands: Command[] = [
141142
);
142143
},
143144
available: (): boolean => {
144-
return TestUI.resultVisible;
145+
return TestState.resultVisible;
145146
},
146147
},
147148
];

frontend/src/ts/controllers/challenge-controller.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as ManualRestart from "../test/manual-restart-tracker";
55
import * as CustomText from "../test/custom-text";
66
import * as Funbox from "../test/funbox/funbox";
77
import Config, * as UpdateConfig from "../config";
8-
import * as TestUI from "../test/test-ui";
98
import * as ConfigEvent from "../observables/config-event";
109
import * as TestState from "../test/test-state";
1110
import * as Loader from "../elements/loader";
@@ -28,7 +27,7 @@ export function clearActive(): void {
2827
if (
2928
TestState.activeChallenge &&
3029
!challengeLoading &&
31-
!TestUI.testRestarting
30+
!TestState.testRestarting
3231
) {
3332
Notifications.add("Challenge cleared", 0);
3433
TestState.setActiveChallenge(null);

0 commit comments

Comments
 (0)