Make Git a native feature with an off switch
- Add the native feature runtime in src/lib/features/: the catalog, the switches, the first-start migration, the loader, and the feature sessions. - Add Settings → Features and the features settings section. - Add features_legacy. It reads the old plugin packages and changes nothing. - Move Git from the plugin into src/lib/features/git/, on host internals. - Remove api.git, the git contribution key, and the SDK Git types. - Add pnpm check:features. It fails when a feature module loads at start. - Update the tests, the menu inventory, the docs, and UI-055.
This commit is contained in:
@@ -1,24 +1,13 @@
|
||||
// Tree rename undo and redo keep folders expanded; New note templates, Git plug-in navigation, and detached tab layout isolation.
|
||||
// @requires repo:RuneStone_Git/dist
|
||||
// Tree rename undo and redo keep folders expanded; New note templates, native Git navigation, and detached tab layout isolation.
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { mockTauri, openPage, outputDir, pluginRepo, runSmoke, smokeUrl } from '../_harness/index.mjs';
|
||||
|
||||
const gitRoot = path.join(pluginRepo('RuneStone_Git'), 'dist');
|
||||
const git = {
|
||||
manifest: JSON.parse(await readFile(path.join(gitRoot, 'plugin.json'), 'utf8')),
|
||||
code: await readFile(path.join(gitRoot, 'main.js'), 'utf8'),
|
||||
css: (await readFile(path.join(gitRoot, 'style.css'))).toString('base64'),
|
||||
};
|
||||
import { mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
|
||||
|
||||
await runSmoke('tree/renameUndo', async ({ browser }) => {
|
||||
const context = await browser.newContext({ viewport: { width: 1200, height: 850 } });
|
||||
await mockTauri(context, {
|
||||
strict: false,
|
||||
state: git,
|
||||
commands: test => {
|
||||
const git = test.state;
|
||||
const ws = test.workspace({
|
||||
root: 'C:\\host-todo-test',
|
||||
files: {
|
||||
@@ -46,10 +35,8 @@ await runSmoke('tree/renameUndo', async ({ browser }) => {
|
||||
},
|
||||
workspace_delete: ({ rel }) => { files.delete(rel); },
|
||||
workspace_search: () => [],
|
||||
plugins_snapshot: () => ({ root: 'C:/plugins', plugins: [{ manifest: git.manifest, hash: 'navigation-git', enabled: true, installedAt: 1, path: 'C:/plugins/runestone.git', error: null, removal: false }] }),
|
||||
plugins_load: () => git.code,
|
||||
plugins_asset: () => git.css,
|
||||
plugins_data: () => 'null',
|
||||
plugins_snapshot: () => ({ root: 'C:/plugins', plugins: [] }),
|
||||
git_status: () => ({ available: true, repository: true, branch: 'main', changes: [] }),
|
||||
'plugin:window|is_maximized': () => false,
|
||||
'plugin:dialog|message': () => 'Ok',
|
||||
};
|
||||
@@ -116,13 +103,15 @@ await runSmoke('tree/renameUndo', async ({ browser }) => {
|
||||
await page.waitForFunction(count => window.__TEST__.calls.filter(call => call.command === 'workspace_create').length === count + 1, creations);
|
||||
await page.getByRole('button', { name: 'Source control', exact: true }).waitFor();
|
||||
assert.equal(await page.locator('.header-left').getByRole('button', { name: 'Source control', exact: true }).count(), 1);
|
||||
await page.getByRole('button', { name: 'Plug-in views', exact: true }).click();
|
||||
const graph = page.getByRole('menuitem', { name: /Show Git graph/ });
|
||||
// Git is a native feature: no plug-in menu lists it, and its graph command is in the command palette.
|
||||
assert.equal(await page.getByRole('button', { name: 'Plug-in views', exact: true }).count(), 0);
|
||||
// The new note keeps the focus in its name field. Move the focus out of it before the palette shortcut.
|
||||
await page.evaluate(() => (document.activeElement instanceof HTMLElement) && document.activeElement.blur());
|
||||
await page.keyboard.press('Control+Shift+P');
|
||||
await page.getByRole('textbox', { name: 'Find a command', exact: true }).fill('Git graph');
|
||||
const graph = page.locator('#command-results .rs-picker-row', { hasText: 'Show Git graph' });
|
||||
await graph.waitFor();
|
||||
assert.equal(await page.getByRole('menuitem', { name: /source control/i }).count(), 0);
|
||||
const graphIcon = await graph.locator('.action-icon').innerHTML();
|
||||
const expectedIcon = await page.evaluate(async () => (await import('/src/lib/ui/actionIcons.ts')).actionIcon('git').innerHTML);
|
||||
assert.equal(graphIcon, expectedIcon, 'The real Git graph command uses the shared Git icon');
|
||||
assert.match(await graph.innerText(), /Git/);
|
||||
await shot(page, 'real-git-command-dark.png');
|
||||
await page.keyboard.press('Escape');
|
||||
await page.evaluate(async () => {
|
||||
|
||||
Reference in New Issue
Block a user