-
Notifications
You must be signed in to change notification settings - Fork 2
feat(installed): add search count display setting #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,237 @@ | ||
| import { | ||
| mkdirSync, | ||
| mkdtempSync, | ||
| realpathSync, | ||
| rmSync, | ||
| writeFileSync, | ||
| } from 'node:fs' | ||
| import { tmpdir } from 'node:os' | ||
| import { join } from 'node:path' | ||
|
|
||
| import type { Page } from '@playwright/test' | ||
|
|
||
| import type { Settings } from '@/shared/settings' | ||
|
|
||
| import { test, expect } from '../fixtures/electron-app' | ||
| import { readSettingsFile, writeSettingsFile } from '../helpers/settings-file' | ||
|
|
||
| const SEARCH_COUNT_SKILLS = [ | ||
| { name: 'alpha-count-e2e', source: 'laststance/skills' }, | ||
| { name: 'beta-count-e2e', source: 'laststance/skills' }, | ||
| { name: 'gamma-count-e2e', source: 'pbakaus/impeccable' }, | ||
| ] | ||
|
|
||
| type SearchCountDisplaySetting = Settings['installedSearchCountDisplay'] | ||
| type IsolatedHomeUse = (home: string) => Promise<void> | ||
|
|
||
| /** | ||
| * Write one source skill folder that the real scanner will count after app launch. | ||
| * @param home - Isolated E2E HOME used by the Electron fixture. | ||
| * @param skillName - Folder name and SKILL.md title for the staged skill. | ||
| * @returns void after the source skill exists on disk. | ||
| * @example | ||
| * stageSourceSkill('/tmp/home', 'alpha-count-e2e') | ||
| */ | ||
| function stageSourceSkill(home: string, skillName: string): void { | ||
| const sourcePath = join(home, '.agents', 'skills', skillName) | ||
| mkdirSync(sourcePath, { recursive: true }) | ||
| writeFileSync( | ||
| join(sourcePath, 'SKILL.md'), | ||
| `---\nname: ${skillName}\ndescription: ${skillName} description\n---\n# ${skillName}\n`, | ||
| 'utf8', | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Write the skills CLI lockfile so the real scanner exposes deterministic repo facets. | ||
| * @param home - Isolated E2E HOME used by the Electron fixture. | ||
| * @returns void after `.skill-lock.json` maps each staged skill to its repo. | ||
| * @example | ||
| * stageSkillLock('/tmp/home') | ||
| */ | ||
| function stageSkillLock(home: string): void { | ||
| const lockPath = join(home, '.agents', '.skill-lock.json') | ||
| const skills = Object.fromEntries( | ||
| SEARCH_COUNT_SKILLS.map((skill) => [ | ||
| skill.name, | ||
| { | ||
| source: skill.source, | ||
| sourceType: 'github', | ||
| sourceUrl: `https://github.com/${skill.source}.git`, | ||
| }, | ||
| ]), | ||
| ) | ||
|
|
||
| writeFileSync(lockPath, JSON.stringify({ skills }, null, 2), 'utf8') | ||
| } | ||
|
|
||
| /** | ||
| * Stage the complete Installed-count HOME before Electron starts scanning. | ||
| * @param home - Isolated E2E HOME used by the Electron fixture. | ||
| * @returns void after source skills and repo metadata are on disk. | ||
| * @example | ||
| * stageInstalledCountHome('/tmp/home') | ||
| */ | ||
| function stageInstalledCountHome(home: string): void { | ||
| mkdirSync(join(home, '.agents', 'skills'), { recursive: true }) | ||
| for (const skill of SEARCH_COUNT_SKILLS) { | ||
| stageSourceSkill(home, skill.name) | ||
| } | ||
| stageSkillLock(home) | ||
| } | ||
|
|
||
| /** | ||
| * Provide an isolated HOME with only the three Installed-count skills staged. | ||
| * @param use - Playwright fixture continuation that launches Electron after setup. | ||
| * @param display - Optional persisted count placement to write before launch. | ||
| * @returns Promise that resolves after the fixture HOME is cleaned up. | ||
| * @example | ||
| * await useInstalledCountHome(use, 'inline') | ||
| */ | ||
| async function useInstalledCountHome( | ||
| use: IsolatedHomeUse, | ||
| display?: SearchCountDisplaySetting, | ||
| ): Promise<void> { | ||
| const home = realpathSync.native( | ||
| mkdtempSync(join(tmpdir(), 'skills-desktop-e2e-search-count-')), | ||
| ) | ||
| try { | ||
| stageInstalledCountHome(home) | ||
| if (display) { | ||
| writeSettingsFile(home, { installedSearchCountDisplay: display }) | ||
| } | ||
| await use(home) | ||
| } finally { | ||
| rmSync(home, { recursive: true, force: true }) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Dispatch Installed search and repo filters in one renderer transaction. | ||
| * @param page - Electron renderer page under test. | ||
| * @param filters - Search query and selected repository ids to apply. | ||
| * @returns Promise that resolves once Redux has the requested filter state. | ||
| * @example | ||
| * await applyInstalledFilters(appWindow, { query: 'missing', sources: [] }) | ||
| */ | ||
| async function applyInstalledFilters( | ||
| page: Page, | ||
| filters: { query: string; sources: string[] }, | ||
| ): Promise<void> { | ||
| await page.evaluate(({ query, sources }) => { | ||
| const store = window.__store__ | ||
| if (!store) throw new Error('window.__store__ is not exposed') | ||
| store.dispatch({ | ||
| type: 'ui/setSearchQuery', | ||
| payload: query, | ||
| }) | ||
| store.dispatch({ | ||
| type: 'ui/setSelectedSources', | ||
| payload: sources, | ||
| }) | ||
| }, filters) | ||
| } | ||
|
|
||
| const installedCountTest = test.extend<{ isolatedHome: string }>({ | ||
| // eslint-disable-next-line no-empty-pattern | ||
| isolatedHome: async ({}, use) => { | ||
| await useInstalledCountHome(use) | ||
| }, | ||
| }) | ||
|
|
||
| const inlineInstalledCountTest = test.extend<{ isolatedHome: string }>({ | ||
| // eslint-disable-next-line no-empty-pattern | ||
| isolatedHome: async ({}, use) => { | ||
| await useInstalledCountHome(use, 'inline') | ||
| }, | ||
| }) | ||
|
|
||
| installedCountTest( | ||
| 'Installed tab badge tracks the current visible count and Marketplace stays count-free', | ||
| async ({ appWindow }) => { | ||
| // Arrange / Assert | ||
| await expect( | ||
| appWindow.getByRole('tab', { | ||
| name: /^Installed, 3 skills visible$/, | ||
| }), | ||
| ).toBeVisible() | ||
| await expect( | ||
| appWindow.getByRole('tab', { name: /^Marketplace$/ }), | ||
| ).toBeVisible() | ||
|
|
||
| // Act | ||
| await applyInstalledFilters(appWindow, { | ||
| query: 'alpha-count', | ||
| sources: [], | ||
| }) | ||
|
|
||
| // Assert | ||
| await expect( | ||
| appWindow.getByRole('tab', { | ||
| name: /^Installed, 1 skill visible$/, | ||
| }), | ||
| ).toBeVisible() | ||
|
|
||
| // Act | ||
| await applyInstalledFilters(appWindow, { | ||
| query: '', | ||
| sources: ['pbakaus/impeccable'], | ||
| }) | ||
|
|
||
| // Assert | ||
| await expect( | ||
| appWindow.getByRole('tab', { | ||
| name: /^Installed, 1 skill visible$/, | ||
| }), | ||
| ).toBeVisible() | ||
|
|
||
| // Act | ||
| await applyInstalledFilters(appWindow, { | ||
| query: 'missing-count-e2e', | ||
| sources: [], | ||
| }) | ||
|
|
||
| // Assert | ||
| await expect( | ||
| appWindow.getByRole('tab', { | ||
| name: /^Installed, 0 skills visible$/, | ||
| }), | ||
| ).toBeVisible() | ||
| await expect( | ||
| appWindow.getByRole('tab', { name: /^Marketplace$/ }), | ||
| ).toBeVisible() | ||
| }, | ||
| ) | ||
|
|
||
| inlineInstalledCountTest( | ||
| 'persisted inline mode moves the count into the toolbar and removes the tab badge', | ||
| async ({ appWindow, isolatedHome }) => { | ||
| // Arrange / Assert | ||
| await appWindow.waitForFunction(() => { | ||
| const store = window.__store__ | ||
| if (!store) return false | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| const state = store.getState() as { | ||
| settings?: { installedSearchCountDisplay?: string } | ||
| } | ||
| return state.settings?.installedSearchCountDisplay === 'inline' | ||
| }) | ||
| await expect( | ||
| appWindow.getByRole('tab', { name: /^Installed$/ }), | ||
| ).toBeVisible() | ||
| await expect( | ||
| appWindow.getByRole('tab', { | ||
| name: /^Installed, 3 skills visible$/, | ||
| }), | ||
| ).toHaveCount(0) | ||
| await expect( | ||
| appWindow | ||
| .locator('[aria-live="polite"]') | ||
| .filter({ hasText: /^3 skills$/ }), | ||
| ).toBeVisible() | ||
|
|
||
| const persisted = readSettingsFile(isolatedHome) as { | ||
| installedSearchCountDisplay?: string | ||
| } | null | ||
| expect(persisted?.installedSearchCountDisplay).toBe('inline') | ||
| }, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.