Skip to content
Merged
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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ The compiled binaries will be generated in the `src-tauri/target/release/bundle`
- **Sound Effects**: Enable or disable interaction sounds.
- **Quit**: Exit the application safely.

### 4. Custom Status & Reminders
- Right-click on any character to open the context menu.
- Click **"⚙️ 自定义状态设置..."** (Custom Status Settings) to open the configuration modal.
- Here you can define your current status (e.g., Working, Break, Lunch) with custom icons and messages.
- You can also set up interval or fixed-time reminders for each status, and the character will notify you via a speech bubble when the time comes!
- **Component Props & Usage:** The `StatusSettingsModal` is globally managed via Zustand (`useStatusSettingsStore`) and does not require props. To trigger it from anywhere:
```tsx
import { useStatusSettingsStore } from '@/store/useStatusSettingsStore';
// ...
const openModal = () => useStatusSettingsStore.getState().open(currentConfig, handleSave);
```

---

## 📂 Structure
Expand Down
102 changes: 102 additions & 0 deletions e2e/status-modal.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { test, expect } from '@playwright/test';

test.describe('StatusSettingsModal Core Scenarios', () => {
test.beforeEach(async ({ page }) => {
// Navigate to the local dev server
await page.goto('http://localhost:1430');

// Wait for the app to load and character widget to appear
await page.waitForSelector('.character-container');

// Open context menu (right click)
await page.locator('.character-container').click({ button: 'right' });

// Click "⚙️ Settings..."
await page.getByText('⚙️ Settings...').click();

// Wait for modal to open
await expect(page.getByText('Custom Status & Reminders')).toBeVisible();
});

test('Scenario 1: Open -> Fill -> Save -> List Update -> Close', async ({ page }) => {
// Add new status
await page.getByRole('button', { name: 'Add Status' }).click();

// Verify new status is added to the sidebar
await expect(page.getByText('New Status').first()).toBeVisible();

// Fill form
await page.getByLabel('Status Name').fill('E2E Test Status');
await page.getByLabel('Icon (Emoji)').fill('🧪');
await page.getByLabel('Message on Entry').fill('Running automated tests');

// Add reminder
await page.getByRole('button', { name: 'Add Rule' }).click();

// Fill reminder message
const reminderInput = page.getByPlaceholder('Reminder Message'); // Need to check if this placeholder was translated
await reminderInput.fill('Are the tests done?');

// Save configuration
await page.getByRole('button', { name: 'Save Settings' }).click();

// Verify saving state
await expect(page.getByText('Saving...')).toBeVisible();

// Verify success toast
await expect(page.getByText('Settings saved successfully')).toBeVisible();

// Verify modal is closed automatically
await expect(page.getByText('Custom Status & Reminders')).not.toBeVisible();

// Verify list update by reopening
await page.locator('.character-container').click({ button: 'right' });

// Check if the new status appears in the context menu
// The exact text depends on how it's rendered in CharacterWidget, assuming it uses the label
await expect(page.getByText('E2E Test Status')).toBeVisible();
});

test('Scenario 2: Validation Error Handling', async ({ page }) => {
// Select first status
await page.getByText('Working').first().click();

// Clear label to trigger validation error
await page.getByLabel('Status Name').fill('');

// Try to save
await page.getByRole('button', { name: 'Save Settings' }).click();

// Verify error message
await expect(page.getByText('Status name cannot be empty')).toBeVisible();

// Verify retry button exists
await expect(page.getByRole('button', { name: 'Retry' })).toBeVisible();

// Modal should stay open
await expect(page.getByText('Custom Status & Reminders')).toBeVisible();
});

test('Scenario 3: Simulated Network Error Handling', async ({ page }) => {
// Add new status
await page.getByRole('button', { name: 'Add Status' }).click();

// Fill specific label to trigger simulated 500 error in store
await page.getByLabel('Status Name').fill('error_500');

// Try to save
await page.getByRole('button', { name: 'Save Settings' }).click();

// Verify error message
await expect(page.getByText('500: Server Internal Error')).toBeVisible();

// Modal should stay open
await expect(page.getByText('Custom Status & Reminders')).toBeVisible();

// Cancel to close
await page.getByRole('button', { name: 'Cancel' }).click();

// Verify modal is closed
await expect(page.getByText('Custom Status & Reminders')).not.toBeVisible();
});
});
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,35 @@
"pnpm": ">=10.0.0"
},
"dependencies": {
"@hookform/resolvers": "^5.2.2",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-label": "^2.1.8",
"@radix-ui/react-scroll-area": "^1.2.10",
"@radix-ui/react-select": "^2.2.6",
"@radix-ui/react-slot": "^1.2.4",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^1.7.0",
"next-themes": "^0.4.6",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-hook-form": "^7.72.1",
"react-markdown": "^10.1.0",
"sonner": "^2.0.7",
"tailwind-merge": "^3.5.0",
"tailwindcss-animate": "^1.0.7"
"tailwindcss-animate": "^1.0.7",
"zod": "^4.3.6",
"zustand": "^5.0.12"
},
"devDependencies": {
"@eslint/js": "^9.39.4",
"@playwright/test": "^1.59.1",
"@tauri-apps/cli": "^2",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@testing-library/user-event": "^14.6.1",
"@types/node": "^25.5.2",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
Expand Down
24 changes: 24 additions & 0 deletions playwright-report/data/42da8fe66bd1f6f715a5a674dca69cbd73975d9f.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Instructions

- Following Playwright test failed.
- Explain why, be concise, respect Playwright best practices.
- Provide a snippet of code with the fix, if possible.

# Test info

- Name: status-modal.spec.ts >> StatusSettingsModal Core Scenarios >> Scenario 3: Simulated Network Error Handling
- Location: e2e/status-modal.spec.ts:80:3

# Error details

```
Error: browserType.launch: Executable doesn't exist at /Users/rain9/Library/Caches/ms-playwright/chromium_headless_shell-1217/chrome-headless-shell-mac-x64/chrome-headless-shell
╔════════════════════════════════════════════════════════════╗
║ Looks like Playwright was just installed or updated. ║
║ Please run the following command to download new browsers: ║
║ ║
║ npx playwright install ║
║ ║
║ <3 Playwright Team ║
╚════════════════════════════════════════════════════════════╝
```
24 changes: 24 additions & 0 deletions playwright-report/data/535c779910db0c7d42d8ea3e43aed90ec8886aad.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Instructions

- Following Playwright test failed.
- Explain why, be concise, respect Playwright best practices.
- Provide a snippet of code with the fix, if possible.

# Test info

- Name: status-modal.spec.ts >> StatusSettingsModal Core Scenarios >> Scenario 2: Validation Error Handling
- Location: e2e/status-modal.spec.ts:60:3

# Error details

```
Error: browserType.launch: Executable doesn't exist at /Users/rain9/Library/Caches/ms-playwright/chromium_headless_shell-1217/chrome-headless-shell-mac-x64/chrome-headless-shell
╔════════════════════════════════════════════════════════════╗
║ Looks like Playwright was just installed or updated. ║
║ Please run the following command to download new browsers: ║
║ ║
║ npx playwright install ║
║ ║
║ <3 Playwright Team ║
╚════════════════════════════════════════════════════════════╝
```
24 changes: 24 additions & 0 deletions playwright-report/data/b54a25724faea0aedf9902ff1efa9ba037cdf328.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Instructions

- Following Playwright test failed.
- Explain why, be concise, respect Playwright best practices.
- Provide a snippet of code with the fix, if possible.

# Test info

- Name: status-modal.spec.ts >> StatusSettingsModal Core Scenarios >> Scenario 1: Open -> Fill -> Save -> List Update -> Close
- Location: e2e/status-modal.spec.ts:21:3

# Error details

```
Error: browserType.launch: Executable doesn't exist at /Users/rain9/Library/Caches/ms-playwright/chromium_headless_shell-1217/chrome-headless-shell-mac-x64/chrome-headless-shell
╔════════════════════════════════════════════════════════════╗
║ Looks like Playwright was just installed or updated. ║
║ Please run the following command to download new browsers: ║
║ ║
║ npx playwright install ║
║ ║
║ <3 Playwright Team ║
╚════════════════════════════════════════════════════════════╝
```
90 changes: 90 additions & 0 deletions playwright-report/index.html

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
testDir: './e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
use: {
baseURL: 'http://localhost:1430',
trace: 'on-first-retry',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
webServer: {
command: 'pnpm dev',
url: 'http://localhost:1430',
reuseExistingServer: !process.env.CI,
},
});
Loading
Loading