perf: merge scenarios + split CI steps for faster E2E

- Merge 3 defaultWiki scenarios into 1 (save 2 app launches)
- Merge 2 scheduledTask scenarios into 1 (save 1 app launch)
- Split CI test step into unit/prepare/e2e for visibility
- Add pnpm store cache to CI
- Fix viteEntry.ts: remove UTF-8 BOM, update stale JSDoc comment
- Set E2E timeout to 22min (was 25min in single step)
This commit is contained in:
linonetwo 2026-04-02 18:05:23 +08:00
parent 9b17736424
commit c82bded055
4 changed files with 38 additions and 53 deletions

View file

@ -20,6 +20,7 @@ jobs:
uses: actions/setup-node@v5
with:
node-version: lts/*
cache: 'pnpm'
# Install C++ build tools for native modules (nsfw, better-sqlite3)
- name: Install build dependencies
@ -43,16 +44,26 @@ jobs:
# Install Chinese fonts and locale support for i18n testing
sudo apt-get install -y fonts-noto-cjk fonts-wqy-zenhei language-pack-zh-hans
sudo locale-gen zh_CN.UTF-8
- name: Run tests
- name: Run unit tests
run: pnpm run test:unit
env:
CI: true
timeout-minutes: 5
- name: Prepare E2E
run: pnpm run test:prepare-e2e
env:
CI: true
timeout-minutes: 5
- name: Run E2E tests
# E2E GUI tests with Electron on Linux require a virtual framebuffer, upgrade screen size from time to time.
run: xvfb-run --auto-servernum --server-args="-screen 0 2560x1440x24" pnpm run test
run: xvfb-run --auto-servernum --server-args="-screen 0 2560x1440x24" pnpm run test:e2e
env:
CI: true
DISPLAY: :99
# Set Chinese locale for i18n testing
LANG: zh_CN.UTF-8
LC_ALL: zh_CN.UTF-8
timeout-minutes: 25
timeout-minutes: 22
# Upload test artifacts (screenshots, logs)
- name: Upload test artifacts

View file

@ -3,15 +3,13 @@ Feature: TidGi Default Wiki
I want app auto create a default wiki workspace for me
So that I can start using wiki immediately
Background:
# Note: tests expect the test wiki parent folder to exist. Run the preparation step before E2E:
# cross-env NODE_ENV=test pnpm dlx tsx scripts/developmentMkdir.ts
@wiki @create-main-workspace @root-tiddler
Scenario: Default wiki content, create new workspace, and configure root tiddler
Given I cleanup test wiki so it could create a new one on start
When I launch the TidGi application
And I wait for the page to load completely
@wiki
Scenario: Application has default wiki workspace with TiddlyWiki content
# --- Part 1: Verify default wiki workspace with TiddlyWiki content ---
Then I should see "page body and wiki workspace" elements with selectors:
| element description | selector |
| page body | body |
@ -20,70 +18,49 @@ Feature: TidGi Default Wiki
And the browser view should be loaded and visible
And I should see " TiddlyWiki" in the browser view content
@wiki @create-main-workspace
Scenario: Create new main workspace via UI from top sidebar
# Prerequisite: app starts with default wiki workspace
Then I should see a "default wiki workspace" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
# Clear previous log markers before waiting for new ones
# --- Part 2: Create new main workspace via UI from top sidebar ---
And I clear log lines containing "[test-id-WORKSPACE_CREATED]"
And I clear log lines containing "[test-id-VIEW_LOADED]"
# Step 1: Click add workspace button in top sidebar
When I click on an "add workspace button" element with selector "#add-workspace-button"
And I switch to "addWorkspace" window
And I wait for the page to load completely
# Step 2: Verify we're on "Create New Wiki" tab and main workspace mode
Then I should see "create new wiki tab and main/sub workspace switch" elements with selectors:
| element description | selector |
| create new wiki tab | button:has-text('') |
| main/sub workspace switch | [data-testid='main-sub-workspace-switch'] |
# Step 4: Enter a different wiki folder name (default "wiki" already exists)
# First clear any existing value in the input field
When I clear text in "wiki folder name input" element with selector "label:has-text('') + div input"
# Then type the new folder name
When I type "wiki2" in "wiki folder name input" element with selector "label:has-text('') + div input"
# Step 5: Click the create button to create the workspace
When I click on a "create wiki button" element with selector "button:has-text('')"
# Wait for workspace to be created using log marker
Then I wait for "workspace created" log marker "[test-id-WORKSPACE_CREATED]"
# Switch back to main window
When I switch to "main" window
# Wait for wiki view to fully load
Then I wait for "view loaded" log marker "[test-id-VIEW_LOADED]"
# Step 7: Verify the new workspace appears in the sidebar
Then I should see a "wiki2 workspace" element with selector "div[data-testid^='workspace-']:has-text('wiki2')"
# Step 8: Verify workspace is functional - click it and check browser view loads
When I click on a "wiki2 workspace button" element with selector "div[data-testid^='workspace-']:has-text('wiki2')"
And the browser view should be loaded and visible
# Verify TiddlyWiki content is displayed in the new workspace
Then I should see " TiddlyWiki" in the browser view content
@wiki @root-tiddler
Scenario: Configure root tiddler to use lazy-load and verify content still loads
# Wait for browser view to be fully loaded first
# --- Part 3: Configure root tiddler to use lazy-load ---
# Switch back to default wiki workspace (exclude wiki2 match)
When I click on a "default wiki workspace button" element with selector "div[data-testid^='workspace-']:has-text('wiki'):not(:has-text('wiki2'))"
And the browser view should be loaded and visible
And I should see " TiddlyWiki" in the browser view content
# Now modify Index tiddler with unique test content before configuring root tiddler
When I modify file "wiki-test/wiki/tiddlers/Index.tid" to contain "Test content for lazy-all verification after restart"
# before restart, should not see the new content from fs yet (watch-fs is off by default)
And I should not see "Test content for lazy-all verification after restart" in the browser view content
# Update rootTiddler setting via API to use lazy-all, and ensure watch-fs is disabled
When I update workspace "wiki" settings:
| property | value |
| rootTiddler | $:/core/save/lazy-all |
| enableFileSystemWatch | false |
# Wait for config to be written
Then I wait for "config file written" log marker "[test-id-TIDGI_CONFIG_WRITTEN]"
# Restart the workspace to apply the rootTiddler configuration
When I restart workspace "wiki"
# Verify browser view is loaded and visible after restart
And the browser view should be loaded and visible
# Verify Index tiddler element exists (confirms rootTiddler=lazy-all config is applied)
Then I should see a "Index tiddler" element in browser view with selector "div[data-tiddler-title='Index']"
# Verify the actual content is displayed (confirms lazy-all loaded the file content on restart)
And I should see "Test content for lazy-all verification after restart" in the browser view content
@wiki @move-workspace
Scenario: Move workspace to a new location
Given I cleanup test wiki so it could create a new one on start
When I launch the TidGi application
And I wait for the page to load completely
# Enable file system watch for testing (default is false in production)
When I update workspace "wiki" settings:
| property | value |

View file

@ -3,12 +3,15 @@ Feature: Scheduled Tasks Management
I want to manage scheduled tasks for agents
So that agents can wake up automatically on a schedule and I can see which tabs have active tasks
@scheduled-tasks @preferences
Scenario: Preferences — view, add interval task, and verify cron preview
@scheduled-tasks @preferences @agent-tab
Scenario: Scheduled tasks — preferences UI and agent definition editor
Given I cleanup test wiki so it could create a new one on start
Given I add test ai settings
Given I launch the TidGi application
And I wait for the page to load completely
And I should see a "page body" element with selector "body"
# Part A: View and add a scheduled task
# --- Part A: View and add a scheduled task in preferences ---
When I click on a "settings button" element with selector "#open-preferences-button"
When I switch to "preferences" window
When I click on an "ai-agent section" element with selector "[data-testid='preference-section-aiAgent']"
@ -18,7 +21,7 @@ Feature: Scheduled Tasks Management
When I click on a "cancel button" element with selector "[data-testid='scheduled-task-cancel-button']"
Then I should not see a "dialog" element with selector "[data-testid='scheduled-task-dialog']"
# Part B: Create an interval scheduled task
# --- Part B: Create an interval scheduled task ---
When I click on a "add task button" element with selector "[data-testid='scheduled-task-add-button']"
Then I should see a "scheduled task dialog" element with selector "[data-testid='scheduled-task-dialog']"
Then I should see a "mode select" element with selector "[data-testid='scheduled-task-mode-select']"
@ -26,27 +29,21 @@ Feature: Scheduled Tasks Management
When I type "Periodic check-in for test" in "message input" element with selector "[data-testid='scheduled-task-message-input'] textarea:not([readonly])"
When I click on a "save button" element with selector "[data-testid='scheduled-task-save-button']"
# Part C: Cron mode shows next run preview
# --- Part C: Cron mode shows next run preview ---
When I click on a "add task button" element with selector "[data-testid='scheduled-task-add-button']"
Then I should see a "scheduled task dialog" element with selector "[data-testid='scheduled-task-dialog']"
When I select "cron" from MUI Select with test id "scheduled-task-mode-select"
Then I should see a "cron expression input" element with selector "[data-testid='scheduled-task-cron-input']"
Then I should see a "timezone input" element with selector "[data-testid='scheduled-task-timezone-input']"
When I click on a "cancel button" element with selector "[data-testid='scheduled-task-cancel-button']"
When I close "preferences" window
@scheduled-tasks @agent-tab
Scenario: Agent tab — schedule section in definition editor and tab clock indicator
# Part A: EditAgentDefinition shows schedule section
Given I cleanup test wiki so it could create a new one on start
Given I add test ai settings
Then I launch the TidGi application
And I wait for the page to load completely
And I should see a "page body" element with selector "body"
# --- Part D: Agent tab — schedule section in definition editor ---
Then I switch to "main" window
When I click on "agent workspace button and new tab button" elements with selectors:
| element description | selector |
| agent workspace | [data-testid='workspace-agent'] |
| new tab button | [data-tab-id='new-tab-button'] |
# Right-click on create default agent card to access edit definition
When I right-click on a "create default agent card" element with selector "[data-testid='create-default-agent-button']"
When I click on a "edit definition menu item" element with selector "[data-testid='edit-definition-menu-item']"
Then I should see a "schedule section" element with selector "[data-testid='edit-agent-schedule-section']"

View file

@ -1,4 +1,4 @@
import path from 'path';
import path from 'path';
/**
* Helper to get the main window entry URL
@ -24,8 +24,8 @@ export function getMainWindowEntry(): string {
/**
* Get preload script path
* In Electron Forge Vite plugin:
* - Development: preload is built to .vite/build/index.js (same dir as main)
* - Production: preload is packaged in resources/app/.vite/build/index.js
* - Development: preload is built to .vite/build/preload.js (same dir as main)
* - Production: preload is packaged in resources/app/.vite/build/preload.js
*/
export function getPreloadPath(): string {
// Preload is emitted as preload.js to avoid clashing with main's index.js