Skip to content
Open

yyyy #305

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
extends: 'erb',
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'react/react-in-jsx-scope': 'off',
'react-hooks/exhaustive-deps': 'warn',
'import/prefer-default-export': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'import/extensions': 'off',
'import/no-extraneous-dependencies': 'off',
},
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
settings: {
'import/resolver': {
node: {},
webpack: {
config: require.resolve(
'./scripts/configs/webpack.config.eslint.ts',
),
},
typescript: {},
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
},
};
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
continue-on-error: true
Comment thread
5hy7xz92nd-oss marked this conversation as resolved.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run linter
run: npm run lint

typecheck:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run TypeScript type check
run: npx tsc --noEmit
Comment thread
5hy7xz92nd-oss marked this conversation as resolved.

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run tests
run: npm test
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
coverage/
if-no-files-found: ignore
49 changes: 46 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"start:main": "cross-env NODE_ENV=development electronmon -r ts-node/register/transpile-only .",
"start:preload": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./scripts/configs/webpack.config.preload.dev.ts",
"start:renderer": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack serve --config ./scripts/configs/webpack.config.renderer.dev.ts",
"format": "prettier '**/*.{js,jsx,ts,tsx}' --write"
"format": "prettier '**/*.{js,jsx,ts,tsx}' --write",
"test": "jest"
},
"config": {
"forge": "./forge.config.js"
Expand Down Expand Up @@ -210,14 +211,56 @@
}
},
"devEngines": {
"node": ">=18.x",
"npm": ">=7.x"
"runtime": {
"name": "node",
"version": ">=18.x"
},
"packageManager": {
"name": "npm",
"version": ">=7.x"
}
},
"electronmon": {
"patterns": [
"!**/**",
"src/main/**"
],
"logLevel": "verbose"
},
"jest": {
"testEnvironment": "jsdom",
"testMatch": [
"**/__tests__/**/*.test.[jt]s?(x)",
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"transform": {
"\\.(ts|tsx|js|jsx)$": [
"ts-jest",
{
"tsconfig": {
"jsx": "react-jsx",
"module": "commonjs"
},
"diagnostics": false
}
]
},
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|svg|ico|eot|ttf|woff|woff2)$": "<rootDir>/src/__tests__/__mocks__/fileMock.js",
"tailwindcss/tailwind\\.css": "identity-obj-proxy",
"\\.(css|less|sass|scss)$": "identity-obj-proxy",
"^/lib/(.*)$": "<rootDir>/src/lib/$1"
},
"setupFilesAfterEnv": [
"<rootDir>/src/__tests__/setupTests.ts"
],
"moduleDirectories": [
"node_modules",
"src"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/release/"
]
}
}
1 change: 1 addition & 0 deletions src/__tests__/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'test-file-stub';
42 changes: 42 additions & 0 deletions src/__tests__/setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import '@testing-library/jest-dom';

// Mock window.electron to simulate Electron IPC bridge in tests
Object.defineProperty(window, 'electron', {
value: {
Comment thread
5hy7xz92nd-oss marked this conversation as resolved.
ipcRenderer: {
sendMessage: jest.fn(),
on: jest.fn().mockReturnValue(() => {}),
once: jest.fn(),
},
electronStore: {
get: jest
.fn()
.mockImplementation(
(_key: string, defaultValue: unknown) => defaultValue,
),
set: jest.fn(),
},
browserWindow: {
reload: jest.fn(),
getAlwaysOnTop: jest.fn().mockReturnValue(false),
setAlwaysOnTop: jest.fn(),
promptHiddenChat: jest.fn(),
enableOpenAtLogin: jest.fn(),
disableOpenAtLogin: jest.fn(),
},
},
writable: true,
});

// Mock window.settings to simulate settings IPC bridge in tests
Object.defineProperty(window, 'settings', {
value: {
getGlobalShortcut: jest.fn().mockResolvedValue('CommandOrControl+Shift+G'),
setGlobalShortcut: jest.fn().mockResolvedValue(undefined),
getFocusSuperprompt: jest.fn().mockResolvedValue(false),
setFocusSuperprompt: jest.fn().mockResolvedValue(undefined),
getPlatform: jest.fn().mockResolvedValue('darwin'),
getOpenAtLogin: jest.fn().mockResolvedValue(false),
},
writable: true,
});
Loading