TidGi-Desktop/features/tiddler.feature
lin onetwo ce332374bc
Fix/misc bug2 (#698)
* fix: hide non-wiki workspaces from menu and disable remove for them (#694)

* fix(workspace): make workspace settings save transactional to prevent data loss

- Move disk write before memory update in Workspace.set()
- Remove error swallowing in writeTidgiConfig() to let errors propagate
- Add error handling in useForm.ts to catch and log save failures
- Add UI error display in EditWorkspace/index.tsx
- Only update Observable after successful persistence

This fixes the issue where save button disappears but changes aren't
persisted to tidgi.config.json, causing data loss when reopening settings.

* feat(i18n): add error messages for workspace save failures

Add SaveError and SaveErrorPrefix translations in English and Chinese
to display error messages when workspace settings fail to save.

* test(e2e): add test for tagNames persistence and missing step definitions

- Add @edit-workspace-save-tagnames scenario to verify tagNames persist
  after save to tidgi.config.json
- Add 'I clear and type' step definition for clearing input before typing
- Add 'I close current window' step definition for closing windows
- This test covers the regression where save button disappears but
  changes aren't persisted

* use 5.4.0

* fix: spaced file in git op

* fix: menu register race condition

* Update pnpm-lock.yaml

* Update wiki

* fix: regenerate lockfile with pnpm 10.33.0 to fix checksum format

* fix: remove unused import and useless constructor

* fix: address Copilot review comments

- Use new path for rename/copy in git operations
- Ensure transactional workspace save (persist before cache update)
- Normalize null label to undefined in menu

* Remove close-window step; simplify UI typing

Remove the Cucumber step that closed the current window and simplify a UI step by calling locator.fill(...) inline (also replace {tmpDir} in the input). Clean up minor whitespace in gitOperations and fix indentation/extra brace around startWiki error handling in the wiki service to correct control flow and prevent accidental scope issues.

* Improve workspace form, git diff, and UI tests

Refactor EditWorkspace form and UI behavior, make git diff/status handling more robust, and update E2E tests.

- Add hasConfigChanges and related effects in useForm to correctly detect config-only changes and control restart requests; fix save button visibility in EditWorkspace and pass currentWorkspace to restart snackbar. Rename workspace section test id from 'workspace-section-search' to 'preference-section-search'.
- Enhance gitOperations.getFileDiff to use porcelain -z and a helper to parse per-path status (getPorcelainStatusForPath) for reliable untracked/deleted detection.
- Add clickBrowserViewElementWithRetry helper with backoff and text-aware selector handling; replace repetitive click logic in browser view step definitions and remove some redundant browser background assertions and a deprecated clear-and-type step.
- Update feature files (gitLog, editWorkspace, vectorSearch) to reflect selector/id/name changes and i18n fallbacks for tab/button text.

* doc

* Use localized draft selector and show e2e window

Update feature tests to target the localized draft tiddler title (data-tiddler-title$='的草稿') instead of the English prefix selector. Applied the change across features/hibernation.feature and features/tiddler.feature to ensure selectors match localized UI. Also enable SHOW_E2E_WINDOW=1 in the test:manual-e2e script in package.json so manual end-to-end runs open a visible window for debugging.
2026-04-21 22:14:43 +08:00

48 lines
4.3 KiB
Gherkin

Feature: Tiddler Creation and Editing
As a user
I want to create and edit tiddlers in the wiki
So that I can manage my content
Background:
Given I cleanup test wiki so it could create a new one on start
And I launch the TidGi application
And I wait for the page to load completely
Then I should see a "default wiki workspace" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
When I click on a "default wiki workspace button" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
Then the browser view should be loaded and visible
And I wait for "SSE backend ready" log marker "[test-id-SSE_READY]"
@tiddler @tiddler-create @tiddler-draft-rapid-save
Scenario: Create tiddler with tag and custom field, then test rapid save
# --- Part 1: Create a new tiddler with tag and custom field via UI ---
And I click on "add tiddler button and title input" elements in browser view with selectors:
| element description | selector |
| add tiddler button | button:has(.tc-image-new-button) |
| title input | div[data-tiddler-title$='稿'] input.tc-titlebar.tc-edit-texteditor |
And I press "Control+a" in browser view
And I press "Delete" in browser view
And I type "MyTestTiddler" in "title input" element in browser view with selector "div[data-tiddler-title$='稿'] input.tc-titlebar.tc-edit-texteditor"
And I click on "tag input" element in browser view with selector "div[data-tiddler-title$='稿'] div.tc-edit-add-tag-ui input.tc-edit-texteditor[placeholder='']"
And I type "MyTestTag" in "tag input" element in browser view with selector "div[data-tiddler-title$='稿'] div.tc-edit-add-tag-ui input.tc-edit-texteditor[placeholder='']"
And I click on "add tag button" element in browser view with selector "div[data-tiddler-title$='稿'] span.tc-add-tag-button button"
And I click on "add field name input" element in browser view with selector "div[data-tiddler-title$='稿'] .tc-edit-field-add-name-wrapper input"
And I type "customfield" in "add field name input" element in browser view with selector "div[data-tiddler-title$='稿'] .tc-edit-field-add-name-wrapper input"
And I click on "add field value input" element in browser view with selector "div[data-tiddler-title$='稿'] .tc-edit-field-add-value input"
And I type "customvalue" in "add field value input" element in browser view with selector "div[data-tiddler-title$='稿'] .tc-edit-field-add-value input"
And I click on "add field button and confirm button" elements in browser view with selectors:
| element description | selector |
| add field button | div[data-tiddler-title$='稿'] .tc-edit-field-add button |
| confirm button | button:has(.tc-image-done-button) |
Then I should see "MyTestTiddler tiddler and MyTestTag tag" elements in browser view with selectors:
| element description | selector |
| MyTestTiddler tiddler | div[data-tiddler-title='MyTestTiddler'] |
| MyTestTag tag | [data-tiddler-title='MyTestTiddler'] [data-tag-title='MyTestTag'] |
Then file "MyTestTiddler.tid" should exist in "{tmpDir}/wiki/tiddlers"
# --- Part 2: Rapid typing and immediate save should not lose characters ---
When I click on "add tiddler button" element in browser view with selector "button:has(.tc-image-new-button)"
And I click on "title input" element in browser view with selector "div[data-tiddler-title$='稿'] input.tc-titlebar.tc-edit-texteditor"
And I type "RapidSaveTiddler" in "title input" element in browser view with selector "div[data-tiddler-title$='稿'] input.tc-titlebar.tc-edit-texteditor"
And I click on "confirm button" element in browser view with selector "button:has(.tc-image-done-button)"
Then I should see a "RapidSaveTiddler tiddler" element in browser view with selector "div[data-tiddler-title='RapidSaveTiddler']"
Then file "RapidSaveTiddler.tid" should exist in "{tmpDir}/wiki/tiddlers"