Skip to content

Commit 32449e4

Browse files
authored
Merge pull request #42 from session-foundation/fix-localiser-with-latest-string
fix: use latest strings and localiser
2 parents 51fe434 + 12959d1 commit 32449e4

9 files changed

Lines changed: 2353 additions & 1516 deletions

File tree

.github/workflows/pull.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- run: git config --global core.autocrlf false
20+
21+
- name: Checkout git repo
22+
uses: actions/checkout@v4
23+
with:
24+
lfs: true
25+
26+
- name: Install node
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version-file: '.nvmrc'
30+
31+
- uses: actions/cache/restore@v4
32+
id: cache-playwright-modules
33+
with:
34+
path: node_modules
35+
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json', 'yarn.lock', 'patches/**') }}
36+
37+
- name: Install dependencies
38+
shell: bash
39+
if: steps.cache-playwright-modules.outputs.cache-hit != 'true'
40+
run: yarn install --immutable
41+
42+
- uses: actions/cache/save@v4
43+
id: cache-playwright-modules-save
44+
with:
45+
path: node_modules
46+
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json', 'yarn.lock', 'patches/**') }}
47+
48+
- name: Lint Files
49+
run: yarn lint-check
50+
51+
- name: Compile typescript files
52+
shell: bash
53+
run: yarn tsc
54+
55+
- name: Run the only test we can without a browser
56+
shell: bash
57+
run: PRINT_FAILED_TEST_LOGS=1 npx playwright test -g "Enforce localized strings return expected values"

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.prettierrc.json
22
.eslintrc.js
33
README.md
4-
tests/localization/*.ts
4+
tests/localization/*.ts
5+
tests/localization/*

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default tseslint.config(
1313
'eslint.config.mjs',
1414
'run/**/*.js',
1515
'avd/',
16+
'tests/localization/*',
1617
],
1718
},
1819
eslint.configs.recommended,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"scripts": {
3333
"build": "yarn tsc --watch",
3434
"lint": "yarn prettier . --write --cache && yarn eslint .",
35+
"lint-check": "yarn prettier . --check && yarn eslint .",
3536
"dev": "yarn tsc --watch",
3637
"test": "npx playwright test",
3738
"watch": "tsc -w",

tests/automation/enforce_localized_str.spec.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { test } from '@playwright/test';
22
import * as fs from 'fs';
33
import * as path from 'path';
4+
5+
import type {
6+
TokenPluralWithArgs,
7+
TokenSimpleNoArgs,
8+
TokenSimpleWithArgs,
9+
} from '../localization/locales';
10+
411
import { englishStrippedStr } from '../localization/englishStrippedStr';
512
import {
613
isPluralToken,
714
type MergedLocalizerTokens,
8-
type PluralLocalizerTokens,
9-
type SimpleLocalizerTokens,
1015
} from '../localization/Localizer';
1116

1217
function readTsFiles(dir: string): Record<string, string> {
@@ -46,8 +51,8 @@ function extractAllTokens(text: string) {
4651

4752
function getExpectedStringFromKey(
4853
args:
49-
| { key: SimpleLocalizerTokens }
50-
| { key: PluralLocalizerTokens; count: number },
54+
| { key: TokenPluralWithArgs; count: number }
55+
| { key: TokenSimpleNoArgs | TokenSimpleWithArgs },
5156
) {
5257
if (isPluralToken(args.key)) {
5358
if (!('count' in args)) {
@@ -126,9 +131,9 @@ function getExpectedStringFromKey(
126131
return 'Message Requests';
127132
case 'done':
128133
return 'Done';
129-
case 'passwordSetDescription':
134+
case 'passwordSetDescriptionToast':
130135
return 'Your password has been set. Please keep it safe.';
131-
case 'passwordChangedDescription':
136+
case 'passwordChangedDescriptionToast':
132137
return 'Your password has been changed. Please keep it safe.';
133138
case 'sessionPrivacy':
134139
return 'Privacy';
@@ -245,7 +250,7 @@ function getExpectedStringFromKey(
245250
case 'recoveryPasswordHidePermanentlyDescription2':
246251
return 'Are you sure you want to permanently hide your recovery password on this device? This cannot be undone.';
247252
default:
248-
// returning nul means we don't have an expected string yet for this key.
253+
// returning null means we don't have an expected string yet for this key.
249254
// This will make the test fail
250255
return null;
251256
}

tests/automation/password.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test_Alice_1W_no_network('Set Password', async ({ alice, aliceWindow1 }) => {
4646
await waitForTestIdWithText(
4747
aliceWindow1,
4848
'session-toast',
49-
englishStrippedStr('passwordSetDescription').toString(),
49+
englishStrippedStr('passwordSetDescriptionToast').toString(),
5050
);
5151
// Click on settings tab
5252
await sleepFor(300, true);
@@ -88,7 +88,7 @@ test_Alice_1W_no_network('Set Password', async ({ alice, aliceWindow1 }) => {
8888
await waitForTestIdWithText(
8989
aliceWindow1,
9090
'session-toast',
91-
englishStrippedStr('passwordChangedDescription').toString(),
91+
englishStrippedStr('passwordChangedDescriptionToast').toString(),
9292
);
9393
});
9494

0 commit comments

Comments
 (0)