Skip to content

Commit a26f98b

Browse files
authored
Merge pull request #4 from 4bdulla/codex/add-tests-for-the-project
Add basic tests
2 parents 5a3cd9f + bbfda90 commit a26f98b

3 files changed

Lines changed: 47 additions & 3 deletions

File tree

.github/workflows/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Node.js
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
- name: Install dependencies
18+
run: npm install
19+
- name: Run tests
20+
run: npm test
21+

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"start": "electron .",
88
"package": "electron-packager . chatgpt-webclient --platform=linux --arch=x64 --icon=assets/icon.png --overwrite",
99
"deb": "npm run package && electron-installer-debian --src chatgpt-webclient-linux-x64/ --dest dist/ --arch amd64",
10-
"dist": "electron-builder"
10+
"dist": "electron-builder",
11+
"test": "node --test"
1112
},
1213
"keywords": [],
1314
"author": "",
@@ -43,8 +44,10 @@
4344
"target": "dmg"
4445
},
4546
"linux": {
46-
"target": ["deb", "AppImage"]
47+
"target": [
48+
"deb",
49+
"AppImage"
50+
]
4751
}
4852
}
49-
5053
}

test/project.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const test = require('node:test');
2+
const assert = require('node:assert');
3+
const fs = require('node:fs');
4+
const path = require('node:path');
5+
6+
test('package.json contains required scripts', async () => {
7+
const pkgPath = path.join(__dirname, '..', 'package.json');
8+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
9+
assert.ok(pkg.scripts && pkg.scripts.start, 'start script missing');
10+
assert.ok(pkg.scripts && pkg.scripts.deb, 'deb script missing');
11+
});
12+
13+
test('settings.html has expected elements', async () => {
14+
const htmlPath = path.join(__dirname, '..', 'src', 'settings.html');
15+
const html = fs.readFileSync(htmlPath, 'utf8');
16+
assert.ok(/id="alwaysOnTop"/.test(html), 'alwaysOnTop checkbox missing');
17+
assert.ok(/id="minimizeToTray"/.test(html), 'minimizeToTray checkbox missing');
18+
assert.ok(/id="autoLaunch"/.test(html), 'autoLaunch checkbox missing');
19+
assert.ok(/id="shortcutPreset"/.test(html), 'shortcutPreset select missing');
20+
});

0 commit comments

Comments
 (0)