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
75 changes: 75 additions & 0 deletions e2e/storage-health.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { test, expect, type Page } from '@playwright/test';
import { waitForAppReady, navClick } from './helpers/navigation';

/**
* Settings → Origin storage panel (issue #1156).
*
* Verifies the storage-health UI end to end in a real Chromium: the estimate
* rows render from `navigator.storage.estimate()`, the persistent-storage
* status renders from `navigator.storage.persisted()`, and the request action
* either gets granted or is declined by the browser — the panel must render
* the outcome either way, never crash, and never claim persistence is a
* backup.
*/
test.describe('Settings origin storage health', () => {
const openSettings = async (page: Page) => {
await page.goto('/');
await waitForAppReady(page);
await navClick(page, /settings/i);
await expect(page.getByRole('heading', { name: 'Origin storage' })).toBeVisible();
await expect(
page.getByText(
/Estimated usage|does not expose origin storage diagnostics|did not return usable storage measurements/i,
),
).toBeVisible();
};

test('renders storage diagnostics or the browser-supported fallback', async ({ page }) => {
await openSettings(page);

const estimate = page.getByText(/Estimated usage/i);
if ((await estimate.count()) > 0) {
await expect(estimate).toBeVisible();
await expect(page.getByText(/Estimated quota/i)).toBeVisible();
// Estimates are labeled as estimates, never exact disk usage.
await expect(page.getByText(/browser estimates, not exact disk usage/i)).toBeVisible();
// The panel is explicit that this is one aggregate browser estimate, not
// per-store byte accounting.
await expect(page.getByText(/everything this site stores here/i)).toBeVisible();
} else {
await expect(
page.getByText(/does not expose origin storage diagnostics|did not return usable storage measurements/i),
).toBeVisible();
}
// This is visible even when storage diagnostics are unsupported.
await expect(page.getByText(/not a backup/i)).toBeVisible();
await expect(page.getByRole('link', { name: /back up your library/i })).toBeVisible();
});

test('allows requesting persistent storage and renders the outcome', async ({ page }) => {
await openSettings(page);

const requestButton = page.getByRole('button', { name: /request persistent storage/i });
if ((await requestButton.count()) > 0) {
// Not protected yet: ask the browser for persistence. The browser either
// grants or declines; the panel must explain either outcome and keep
// working — never crash, never claim a backup was made.
await requestButton.click();
await expect(
page.getByText(/persistent storage granted|declined persistent storage/i),
).toBeVisible();
await expect(page.getByRole('heading', { name: 'Origin storage' })).toBeVisible();
await expect(
page.locator('span').filter({ hasText: /Not granted|Granted/ }),
).toBeVisible();
} else if ((await page.getByText(/^Granted/).count()) > 0) {
// Already protected: the request control is gone and the status says so.
await expect(page.getByText(/^Granted/)).toBeVisible();
} else {
// The browser may lack persistence support or all origin storage diagnostics.
await expect(
page.getByText(/cannot request persistent storage|does not expose origin storage diagnostics/i),
).toBeVisible();
}
});
});
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
},
"scripts": {
"prepare": "./scripts/install-hooks.sh",
"dev": "next dev -p 3000 2>&1 | tee dev.log",
"build": "next build && node scripts/generate-precache-manifest.mjs",
"dev": "pnpm --filter dks-core build && next dev -p 3000 2>&1 | tee dev.log",
"build": "pnpm --filter dks-core build && next build && node scripts/generate-precache-manifest.mjs",
"start": "next start",
"lint": "eslint .",
"docs:check": "node scripts/check-doc-consistency.mjs",
"workflows:check": "./scripts/check-workflow-hygiene.sh",
"typecheck": "next typegen && tsc --noEmit -p tsconfig.app.json && pnpm --filter dks-mcp typecheck",
"typecheck:test": "tsc --noEmit -p tsconfig.test.json",
"typecheck:e2e": "tsc --noEmit -p tsconfig.e2e.json",
"typecheck": "pnpm --filter dks-core build && next typegen && tsc --noEmit -p tsconfig.app.json && pnpm --filter dks-core typecheck && pnpm --filter dks-mcp typecheck",
"typecheck:test": "pnpm --filter dks-core build && tsc --noEmit -p tsconfig.test.json",
"typecheck:e2e": "pnpm --filter dks-core build && tsc --noEmit -p tsconfig.e2e.json",
"propagate:version": "bash scripts/propagate-version.sh",
"test": "vitest run && pnpm --filter dks-mcp test",
"test": "pnpm --filter dks-core build && vitest run && pnpm --filter dks-core test && pnpm --filter dks-mcp test",
"test:mutation": "stryker run && node scripts/check-mutation-score.mjs < reports/mutation.json",
"test:properties:nightly": "FAST_CHECK_PROFILE=nightly vitest run",
"test:coverage": "vitest run --coverage",
Expand Down Expand Up @@ -88,7 +88,8 @@
"yaml": "^2.9.1",
"yjs": "^13.6.33",
"zod": "^4.6.7",
"zustand": "^5.0.15"
"zustand": "^5.0.15",
"dks-core": "workspace:*"
},
"devDependencies": {
"@axe-core/playwright": "^4.13.0",
Expand Down
54 changes: 54 additions & 0 deletions packages/dks-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "dks-core",
"version": "0.1.0",
"private": true,
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./frontmatter": {
"types": "./dist/frontmatter.d.ts",
"import": "./dist/frontmatter.js"
},
"./graph-path": {
"types": "./dist/graph-path.d.ts",
"import": "./dist/graph-path.js"
},
"./markdown": {
"types": "./dist/markdown.d.ts",
"import": "./dist/markdown.js"
},
"./okf-export": {
"types": "./dist/okf-export.d.ts",
"import": "./dist/okf-export.js"
},
"./okf-parse": {
"types": "./dist/okf-parse.d.ts",
"import": "./dist/okf-parse.js"
},
"./pwa-retrieval": {
"types": "./dist/pwa-retrieval.d.ts",
"import": "./dist/pwa-retrieval.js"
}
},
"description": "Framework-neutral Knowledge Studio domain services shared by the dks CLI and the optional MCP adapter. No React/Next/MCP dependencies.",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"typecheck": "tsc --noEmit -p tsconfig.json",
"test": "vitest run"
},
"dependencies": {
"yaml": "^2.9.1"
},
"devDependencies": {
"typescript": "^6",
"vitest": "4.1.11"
},
"engines": {
"node": ">=22.12.0 <27.0.0"
}
}
Loading
Loading