From 9738ad4b7a86868a1a67fd9ff17975644b4f9f9e Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Fri, 1 Mar 2024 20:31:02 -0600 Subject: [PATCH] Ensure chats pane in settings is visible Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com> --- .storybook/preview.tsx | 1 + package.json | 14 +++++++------- test/setup-test-node.js | 1 + ts/context/environment.ts | 6 +++++- ts/test-mock/playwright.ts | 1 + ts/test-mock/settings/settings_test.ts | 15 ++++++++++++++- ts/util/unicodeBidi.ts | 2 +- ts/windows/context.ts | 1 + ts/windows/minimalContext.ts | 3 ++- 9 files changed, 33 insertions(+), 11 deletions(-) diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 73c277168f6..d567f5ca213 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -93,6 +93,7 @@ window.SignalContext = { unregisterForChange: noop, }, + isTestOrMockEnvironment: () => false, nativeThemeListener: { getSystemTheme: () => 'light', subscribe: noop, diff --git a/package.json b/package.json index 3a6373b7ba7..1aeb61c8f4f 100644 --- a/package.json +++ b/package.json @@ -40,13 +40,13 @@ "prepare-staging-build": "node scripts/prepare_staging_build.js", "prepare-windows-cert": "node scripts/prepare_windows_cert.js", "test": "yarn test-node && yarn test-electron && yarn test-lint-intl && yarn test-eslint", - "test-electron": "cross-env IS_TESTS=1 node ts/scripts/test-electron.js", - "test-release": "cross-env IS_TESTS=1 node ts/scripts/test-release.js", - "test-node": "cross-env IS_TESTS=1 LANG=en-us electron-mocha --timeout 10000 --file test/setup-test-node.js --recursive test/modules ts/test-node ts/test-both", - "test-mock": "cross-env IS_TESTS=1 mocha --require ts/test-mock/setup-ci.js ts/test-mock/**/*_test.js", - "test-eslint": "cross-env IS_TESTS=1 mocha .eslint/rules/**/*.test.js --ignore-leaks", - "test-node-coverage": "cross-env IS_TESTS=1 nyc --reporter=lcov --reporter=text mocha --recursive test/modules ts/test-node ts/test-both", - "test-lint-intl": "cross-env IS_TESTS=1 ts-node ./build/intl-linter/linter.ts --test", + "test-electron": "node ts/scripts/test-electron.js", + "test-release": "node ts/scripts/test-release.js", + "test-node": "cross-env LANG=en-us electron-mocha --timeout 10000 --file test/setup-test-node.js --recursive test/modules ts/test-node ts/test-both", + "test-mock": "mocha --require ts/test-mock/setup-ci.js ts/test-mock/**/*_test.js", + "test-eslint": "mocha .eslint/rules/**/*.test.js --ignore-leaks", + "test-node-coverage": "nyc --reporter=lcov --reporter=text mocha --recursive test/modules ts/test-node ts/test-both", + "test-lint-intl": "ts-node ./build/intl-linter/linter.ts --test", "eslint": "eslint --cache . --cache-strategy content --max-warnings 0", "lint": "run-s --print-label lint-prettier lint-css check:types eslint", "lint-deps": "node ts/util/lint/linter.js", diff --git a/test/setup-test-node.js b/test/setup-test-node.js index a65b9db8e8f..da28f83cd21 100644 --- a/test/setup-test-node.js +++ b/test/setup-test-node.js @@ -32,6 +32,7 @@ global.window = { getHourCyclePreference: () => HourCyclePreference.UnknownPreference, getPreferredSystemLocales: () => ['en'], getLocaleOverride: () => null, + isTestOrMockEnvironment: () => true, }, i18n: key => `i18n(${key})`, storage: { diff --git a/ts/context/environment.ts b/ts/context/environment.ts index 7171edebcaf..5d0c656f237 100644 --- a/ts/context/environment.ts +++ b/ts/context/environment.ts @@ -4,6 +4,7 @@ import { config } from './config'; import { getEnvironment, + isTestEnvironment, parseEnvironment, setEnvironment, } from '../environment'; @@ -12,4 +13,7 @@ setEnvironment(parseEnvironment(config.environment)); const environment = getEnvironment(); -export { environment }; +const isTestOrMockEnvironment = + isTestEnvironment(environment) || Boolean(process.env.MOCK_TEST); + +export { environment, isTestOrMockEnvironment }; diff --git a/ts/test-mock/playwright.ts b/ts/test-mock/playwright.ts index 3fe4edc1044..7294a0de6df 100644 --- a/ts/test-mock/playwright.ts +++ b/ts/test-mock/playwright.ts @@ -59,6 +59,7 @@ export class App extends EventEmitter { args: this.options.args.slice(), env: { ...process.env, + MOCK_TEST: 'true', SIGNAL_CI_CONFIG: this.options.config, }, locale: 'en', diff --git a/ts/test-mock/settings/settings_test.ts b/ts/test-mock/settings/settings_test.ts index ecaaeaef6a4..45f3d74d865 100644 --- a/ts/test-mock/settings/settings_test.ts +++ b/ts/test-mock/settings/settings_test.ts @@ -31,14 +31,27 @@ describe('settings', function (this: Mocha.Suite) { await bootstrap.teardown(); }); - it('settings window loads when opened', async () => { + it('settings window and all panes load when opened', async () => { const window = await app.getWindow(); const newPagePromise = window.context().waitForEvent('page'); await window.locator('.NavTabs__ItemIcon--Settings').click(); const settingsWindow = await newPagePromise; + await settingsWindow.getByText('Device Name').waitFor(); await settingsWindow.getByText('Appearance').click(); await settingsWindow.getByText('Language').first().waitFor(); + + await settingsWindow.getByText('Chats').click(); + await settingsWindow.getByText('Sent media quality').waitFor(); + + await settingsWindow.getByText('Calls').click(); + await settingsWindow.getByText('Enable incoming calls').waitFor(); + + await settingsWindow.getByText('Notifications').click(); + await settingsWindow.getByText('Notification content').waitFor(); + + await settingsWindow.getByText('Privacy').click(); + await settingsWindow.getByText('Read receipts').waitFor(); }); }); diff --git a/ts/util/unicodeBidi.ts b/ts/util/unicodeBidi.ts index d1fb7667caa..0ffd7e2164a 100644 --- a/ts/util/unicodeBidi.ts +++ b/ts/util/unicodeBidi.ts @@ -208,7 +208,7 @@ export function _bidiIsolate(text: string): string { * ``` */ export function bidiIsolate(text: string): string { - if (process.env.IS_TESTS != null) { + if (window.SignalContext.isTestOrMockEnvironment()) { // Turn this off in tests to make it easier to compare strings return text; } diff --git a/ts/windows/context.ts b/ts/windows/context.ts index 5eb4b1f7598..8ffa69d7b68 100644 --- a/ts/windows/context.ts +++ b/ts/windows/context.ts @@ -54,6 +54,7 @@ export type MinimalSignalContextType = { getNodeVersion: () => string; getPath: (name: 'userData' | 'home' | 'install') => string; getVersion: () => string; + isTestOrMockEnvironment: () => boolean; nativeThemeListener: NativeThemeType; restartApp: () => void; Settings: { diff --git a/ts/windows/minimalContext.ts b/ts/windows/minimalContext.ts index 5b1be4e3057..2e3f3e58391 100644 --- a/ts/windows/minimalContext.ts +++ b/ts/windows/minimalContext.ts @@ -10,7 +10,7 @@ import { activeWindowService } from '../context/activeWindowService'; import { config } from '../context/config'; import { createNativeThemeListener } from '../context/createNativeThemeListener'; import { createSetting } from '../util/preload'; -import { environment } from '../context/environment'; +import { environment, isTestOrMockEnvironment } from '../context/environment'; import { localeDisplayNames, countryDisplayNames, @@ -52,6 +52,7 @@ export const MinimalSignalContext: MinimalSignalContextType = { getHourCyclePreference: () => config.hourCyclePreference, getPreferredSystemLocales: () => config.preferredSystemLocales, getLocaleOverride: () => config.localeOverride, + isTestOrMockEnvironment: () => isTestOrMockEnvironment, nativeThemeListener: createNativeThemeListener(ipcRenderer, window), restartApp: () => ipcRenderer.send('restart'), OS: {