Skip to content

Commit f3fb021

Browse files
committed
fix: test failed on ci
1 parent b41f6dd commit f3fb021

8 files changed

Lines changed: 160 additions & 325 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,7 @@ concurrency:
2222

2323
jobs:
2424
test:
25-
runs-on: ubuntu-latest
26-
steps:
27-
- name: Checkout repository
28-
uses: actions/checkout@v4
29-
30-
- name: Install Node.js
31-
uses: actions/setup-node@v4
32-
with:
33-
node-version: lts/*
34-
35-
- name: Setup pnpm
36-
uses: pnpm/action-setup@v4
37-
with:
38-
version: 'latest'
39-
run_install: false
40-
41-
- name: Cache dependencies
42-
uses: actions/cache@v3
43-
with:
44-
path: |
45-
**/node_modules
46-
~/.pnpm-store
47-
~/.npm
48-
key: test-${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
49-
restore-keys: |
50-
test-${{ runner.os }}-node-
51-
52-
- name: Install dependencies
53-
run: pnpm install
54-
55-
- name: Run unit tests
56-
run: pnpm run test:unit
57-
58-
- name: Build plugins
59-
run: pnpm run build:plugin
60-
61-
- name: Package for testing
62-
run: pnpm run package:dev
63-
64-
- name: Run e2e tests
65-
run: pnpm run test:e2e
25+
uses: ./.github/workflows/test.yml
6626

6727
build:
6828
needs: test

.github/workflows/test.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
push:
6+
branches:
7+
- master
8+
- develop
9+
paths-ignore:
10+
- 'README.md'
11+
- 'docs/**'
12+
- '.vscode'
13+
pull_request:
14+
branches:
15+
- master
16+
paths-ignore:
17+
- 'docs/**'
18+
- 'README.md'
19+
- '.vscode'
20+
21+
jobs:
22+
test:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
- name: Install Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: lts/*
31+
- name: Setup pnpm
32+
uses: pnpm/action-setup@v4
33+
with:
34+
version: 'latest'
35+
run_install: false
36+
- name: Cache dependencies
37+
uses: actions/cache@v3
38+
with:
39+
path: |
40+
**/node_modules
41+
~/.pnpm-store
42+
~/.npm
43+
key: test-${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
44+
restore-keys: |
45+
test-${{ runner.os }}-node-
46+
- name: Install dependencies
47+
run: pnpm install
48+
49+
- name: Run linting
50+
run: pnpm run lint
51+
continue-on-error: true
52+
53+
- name: Run unit tests
54+
run: pnpm run test:unit
55+
56+
- name: Build plugins
57+
run: pnpm run build:plugin
58+
59+
- name: Package for testing
60+
run: pnpm run package:dev
61+
62+
- name: Run e2e tests
63+
run: pnpm run test:e2e

eslint.config.mjs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,5 @@ export default [
1616
tsconfigRootDir: __dirname,
1717
},
1818
},
19-
},
20-
{
21-
rules: {
22-
// allow Defensive programming
23-
"@typescript-eslint/no-unnecessary-condition": "warn",
24-
"@typescript-eslint/require-await": "off"
25-
}
2619
}
2720
];

features/stepDefinitions/application.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { After, Before, setWorldConstructor, Then, When } from '@cucumber/cucumber';
2-
import fs from 'fs';
3-
import path from 'path';
42
import { _electron as electron } from 'playwright';
53
import type { ElectronApplication, Page } from 'playwright';
4+
import { getPackedAppPath } from '../supports/paths';
65

76
class ApplicationWorld {
87
app: ElectronApplication | undefined;
@@ -29,16 +28,11 @@ After(async function(this: ApplicationWorld) {
2928
});
3029

3130
When('I launch the TidGi application', async function(this: ApplicationWorld) {
32-
// For E2E tests on dev mode, use the packaged test version with NODE_ENV environment variable baked in, otherwise this will bring up existing production tidgi app on user's computer.
33-
const packedAppPath = path.join(process.cwd(), 'out', 'TidGi-win32-x64', 'tidgi.exe');
31+
// For E2E tests on dev mode, use the packaged test version with NODE_ENV environment variable baked in
3432

33+
const packedAppPath = getPackedAppPath();
3534
console.log('Launching packaged test app at:', packedAppPath);
3635

37-
// Check if the executable exists before trying to launch
38-
if (!fs.existsSync(packedAppPath)) {
39-
throw new Error(`TidGi executable not found at ${packedAppPath}. You should run \`pnpm run package:test\` before running the tests to ensure the app is built.`);
40-
}
41-
4236
try {
4337
this.app = await electron.launch({
4438
executablePath: packedAppPath,
@@ -51,7 +45,7 @@ When('I launch the TidGi application', async function(this: ApplicationWorld) {
5145
});
5246
this.mainWindow = await this.app.firstWindow();
5347
} catch (error) {
54-
throw new Error(`Failed to launch TidGi application: ${error as Error}. You should run \`pnpm run package:test\` before running the tests to ensure the app is built.`);
48+
throw new Error(`Failed to launch TidGi application: ${error as Error}. You should run \`pnpm run package:dev\` before running the tests to ensure the app is built.`);
5549
}
5650
});
5751

features/supports/paths.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
4+
export function getPackedAppPath(): string {
5+
const platform = process.platform;
6+
const outputDirectory = path.join(process.cwd(), 'out');
7+
8+
// Define possible app paths based on platform
9+
const possiblePaths: string[] = [];
10+
11+
switch (platform) {
12+
case 'win32':
13+
possiblePaths.push(
14+
path.join(outputDirectory, 'TidGi-win32-x64', 'tidgi.exe'),
15+
path.join(outputDirectory, 'TidGi-win32-arm64', 'tidgi.exe'),
16+
path.join(outputDirectory, 'TidGi-win32-ia32', 'tidgi.exe'),
17+
);
18+
break;
19+
case 'darwin':
20+
possiblePaths.push(
21+
path.join(outputDirectory, 'TidGi-darwin-x64', 'TidGi.app', 'Contents', 'MacOS', 'TidGi'),
22+
path.join(outputDirectory, 'TidGi-darwin-arm64', 'TidGi.app', 'Contents', 'MacOS', 'TidGi'),
23+
);
24+
break;
25+
case 'linux':
26+
possiblePaths.push(
27+
path.join(outputDirectory, 'TidGi-linux-x64', 'tidgi'),
28+
path.join(outputDirectory, 'TidGi-linux-arm64', 'tidgi'),
29+
);
30+
break;
31+
default:
32+
throw new Error(`Unsupported platform: ${platform}`);
33+
}
34+
35+
// Find the first existing executable
36+
for (const appPath of possiblePaths) {
37+
if (fs.existsSync(appPath)) {
38+
return appPath;
39+
}
40+
}
41+
42+
throw new Error(
43+
`TidGi executable not found. Checked paths:\n${possiblePaths.join('\n')}\n\nYou should run \`pnpm run package:dev\` before running the tests to ensure the app is built.`,
44+
);
45+
}

features/tsconfig.json

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
{
2+
"extends": "../tsconfig.json",
23
"compilerOptions": {
3-
"target": "ES2020",
4-
"module": "commonjs",
5-
"lib": ["ES2020", "dom"],
6-
"outDir": "./stepDefinitions/compiled",
7-
"rootDir": "./stepDefinitions",
8-
"strict": true,
9-
"esModuleInterop": true,
4+
"rootDir": ".",
5+
"outDir": "../out/features",
6+
"noEmit": true,
107
"skipLibCheck": true,
11-
"forceConsistentCasingInFileNames": true,
12-
"declaration": false,
13-
"sourceMap": false,
14-
"experimentalDecorators": true,
15-
"emitDecoratorMetadata": true,
16-
"moduleResolution": "node"
8+
"allowSyntheticDefaultImports": true,
9+
"esModuleInterop": true,
10+
"moduleResolution": "node",
11+
"resolveJsonModule": true
1712
},
18-
"include": ["stepDefinitions/*.ts"],
19-
"exclude": ["stepDefinitions/compiled"]
13+
"include": [
14+
"**/*.ts",
15+
"**/*.js"
16+
],
17+
"exclude": [
18+
"node_modules",
19+
"**/*.d.ts"
20+
]
2021
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
"electron-playwright-helpers": "^1.7.1",
171171
"esbuild": "^0.25.2",
172172
"esbuild-loader": "^4.3.0",
173-
"eslint-config-tidgi": "2.1.0",
173+
"eslint-config-tidgi": "^2.2.0",
174174
"fork-ts-checker-webpack-plugin": "9.1.0",
175175
"identity-obj-proxy": "^3.0.0",
176176
"jest": "^30.0.0",

0 commit comments

Comments
 (0)