fix: review findings — separators are not items, Replace counts what it deletes

An adversarial review of the Firefox port found:

- #edit treated a Firefox separator as an item in three places: a folder's
  count badge, whether a folder can be expanded, and whether it can be
  sorted. A folder of separators and one bookmark offered Sort A-Z.
- Replace's confirmation counted every writable root, so a signed-in
  Chrome's account roots, which Replace never empties, were counted among
  what it would delete. In every release since 1.1.0; it now counts the
  replaceable roots only.
- The store jobs checked their files against the SHA256SUMS.txt that came
  in the same artifact, with --ignore-missing. Each file is now checked by
  name against the published Release's checksums.
- Qodana's publish job ran only after a successful scan, so a scan failing
  on findings never published them.
- getRoots' position fallback had no test. It now has two, with unknown
  ids and a Bookmarks Menu listed first.

Docs follow: the two browser modules and the warning codes (02), where the
landed index is compared (05), the separator markup and folder count (06),
what the Firefox suites are (11), the release staging and environments
limited to v* tags (12, 00), and which loose entries reach the Bookmarks
Menu on Firefox (03, 04, README).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
poli0981andClaude Opus 5.5 committed 2026-11-18 22:10:35 +07:00
1 parent 23f6386d3d
commit ffceb4bd54
17 files changed
+230 -42

No files matched your search

+4 -1
View File
@@ -99,7 +99,10 @@ jobs:
publish:
name: Findings to code scanning
needs: scan
if: needs.scan.outputs.ran == 'true'
# !cancelled(), not the implicit success(): with failureConditions in
# qodana.yaml, a scan that FINDS something fails — and those are exactly
# the findings that must reach code scanning and the pull request.
if: ${{ !cancelled() && needs.scan.outputs.ran == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
+45 -9
View File
@@ -166,9 +166,21 @@ jobs:
with:
name: release-${{ github.ref_name }}
path: dist
- name: Check the file against the published checksums
working-directory: dist
run: sha256sum -c --ignore-missing SHA256SUMS.txt
# Against the SHA256SUMS.txt of the published Release — not the copy that
# travelled in the same artifact — and by exact name, so a missing file
# fails here rather than passing a check that skipped it.
- name: Check against the published checksums
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
gh release download "$GITHUB_REF_NAME" --pattern SHA256SUMS.txt --dir published
cd dist
for file in "bookmarkmagic-${VERSION}-chrome.zip"; do
grep -F " $file" ../published/SHA256SUMS.txt | sha256sum -c -
done
- name: Submit
env:
# API v2: v1.1 was shut down on 2026-10-15. Set explicitly — the tool
@@ -205,9 +217,21 @@ jobs:
with:
name: release-${{ github.ref_name }}
path: dist
- name: Check the files against the published checksums
working-directory: dist
run: sha256sum -c --ignore-missing SHA256SUMS.txt
# Against the SHA256SUMS.txt of the published Release — not the copy that
# travelled in the same artifact — and by exact name, so a missing file
# fails here rather than passing a check that skipped it.
- name: Check against the published checksums
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
gh release download "$GITHUB_REF_NAME" --pattern SHA256SUMS.txt --dir published
cd dist
for file in "bookmarkmagic-${VERSION}-firefox.zip" "bookmarkmagic-${VERSION}-sources.zip"; do
grep -F " $file" ../published/SHA256SUMS.txt | sha256sum -c -
done
- name: Submit
env:
FIREFOX_EXTENSION_ID: ${{ secrets.FIREFOX_EXTENSION_ID }}
@@ -245,9 +269,21 @@ jobs:
with:
name: release-${{ github.ref_name }}
path: dist
- name: Check the file against the published checksums
working-directory: dist
run: sha256sum -c --ignore-missing SHA256SUMS.txt
# Against the SHA256SUMS.txt of the published Release — not the copy that
# travelled in the same artifact — and by exact name, so a missing file
# fails here rather than passing a check that skipped it.
- name: Check against the published checksums
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
gh release download "$GITHUB_REF_NAME" --pattern SHA256SUMS.txt --dir published
cd dist
for file in "bookmarkmagic-${VERSION}-chrome.zip"; do
grep -F " $file" ../published/SHA256SUMS.txt | sha256sum -c -
done
- name: Submit
env:
# API v1.1 keys expire every 72 days (docs/12 §3).
+4
View File
@@ -107,6 +107,10 @@ Full policy: [`legal/PRIVACY.md`](legal/PRIVACY.md).
deletes them with everything else — tells you so before it starts.
- Firefox refuses bookmark addresses longer than 65,536 characters (they are
skipped, and counted) and shortens titles longer than 4,096.
- On Firefox, entries a file leaves loose at its top level go into the
**Bookmarks Menu**, where Firefox's own import puts them. For an HTML file
exported by Chrome itself, that means Chrome's Other and Mobile bookmarks;
BookmarkMagic's own exports name every root and land where they came from.
- CSV is a flattened view: empty folders and "which folder is the toolbar" are
not preserved. Use HTML or JSON for a faithful backup.
- Markdown is share-only — BookmarkMagic cannot read it back.
+14 -4
View File
@@ -103,6 +103,8 @@ bookmarkmagic/
│ │ │ └── limits.ts # MAX_FILE_BYTES, MAX_NODES, MAX_DEPTH, LEGAL_VERSION
│ │ ├── browser/
│ │ │ ├── bookmarks.ts # getTree/create/move/update/remove wrappers
│ │ │ ├── roots.ts # getRoots: which live folders are the roots (§4)
│ │ │ ├── live-tree.ts # live → file model; separators, counts, move index (§4)
│ │ │ ├── write-queue.ts # sequential tree writer + progress + abort
│ │ │ ├── storage.ts # typed settings/legal accessors
│ │ │ ├── download.ts # Blob → <a download>
@@ -234,14 +236,18 @@ one `done` counter for the whole import (`05 §6`). Every node is accounted for:
and it has a fourth root Chromium lacks, the **Bookmarks Menu**. `getRoots()`
tries those GUIDs after the Chromium ids and before position, so the position
fallback (which on Firefox would take the Menu for the bar) is never reached,
and returns the Menu as a fourth destination that Replace also empties.
and returns the Menu as a fourth destination that Replace also empties. The
position fallback itself never takes the Menu either: it is left out of the
candidates, so roots with unknown ids still map the bar, Other and Mobile
(tested with hand-built roots in `bookmarks.test.ts` — neither fake reaches
that path).
**Separators** exist only in Firefox's live tree: `type: "separator"` and, for
historical reasons, `url: "data:"`. They are recognised by `type`, never by
the url; `toBookmarkNodes` drops them, so the file model never holds one, and
`#edit` shows them as lines no command can touch (`03 §3`). Counting helpers
in `browser/bookmarks.ts` keep them out of every bookmark count.
in `browser/live-tree.ts` keep them out of every bookmark count.
Chrome root mapping: `browser/bookmarks.ts` `getRoots()` resolves the three
Chrome root mapping: `browser/roots.ts` `getRoots()` resolves the three
destinations by `folderType` (`bookmarks-bar`, `other`, `mobile`, Chrome
134+), among this device's roots only — a signed-in account's own roots
(`syncing: true`, Chrome 134+) are listed but never written to or emptied.
@@ -335,7 +341,11 @@ the hash for a new tab, or via the broadcast for an open one.
`NEWER_VERSION`, `EMPTY_TITLE`, and since v1.1.0 `INVALID_URL` (an address
`chrome.bookmarks.create` would reject), `PLACE_QUERIES_SKIPPED` (Firefox smart
bookmarks), `EXTRA_ROOTS_SKIPPED` (vendor roots in a browser JSON file) and
`UNREADABLE_ENTRIES` (a `<DT>` with no readable `<A>` or `<H3>`).
`UNREADABLE_ENTRIES` (a `<DT>` with no readable `<A>` or `<H3>`), and since
v1.3.0 `SEPARATORS_SKIPPED` (separators an HTML file or a Firefox backup
holds — no format keeps one) and `URL_TOO_LONG` (an address longer than the
browser accepts, 65 536 characters in Firefox — added by the import from
the browser layer's limit, not by a parser).
- `browser/` adds `BmBackupError { code }` for the forced safety backup
(`03 §1` step 6b) — `BACKUP_SERIALIZE_FAILED`, `BACKUP_EXCEEDS_LIMITS` (since
v1.1.0: the backup would be refused by the import's own caps, so it is no
+8 -2
View File
@@ -50,7 +50,10 @@
**separators** in those roots, and nothing restores them — no format
BookmarkMagic writes keeps one — so the confirmation says how many will go
(`import.replaceSeparators`, shown only when there are any). The counts in
that confirmation never include separators among the bookmarks.
that confirmation never include separators among the bookmarks, and they
cover exactly what Replace deletes: the roots it empties, never a signed-in
Chrome account's own roots (`syncing: true`, `02 §4`), which it leaves
alone (fixed in v1.3.0 — they used to be counted).
- **Root routing** (`core/route.ts`), top-level nodes only — deeper, markers
are data. A folder that *is* a browser root is **unwrapped**: its children go
into that root and the folder itself is never written.
@@ -67,7 +70,10 @@
everywhere else. Firefox's own HTML export leaves the menu's contents loose
at the top level, and Firefox's own import puts loose entries back into
the menu; doing the same is what makes a Firefox file round-trip in
Firefox. New-folder mode is not routing and stays the same on every
Firefox. It also means a **Chrome** HTML export's Other and Mobile
contents, which Chrome writes loose (`04 §1.2`), land in the Menu in
Firefox — as they do with Firefox's own import. BookmarkMagic's exports
mark every root, so they are not affected. New-folder mode is not routing and stays the same on every
browser: `Other Bookmarks/Imported <date>/…`.
The markers come from our own exports and backups (`04 §1.1`, §2), from
+4 -1
View File
@@ -93,7 +93,10 @@ is therefore written to HTML by unwrapping it — its children appear at the
top level, before the marked roots — and reading that file in Firefox puts
them back where they were (`03 §1`). Chromium has no menu root, so in Chrome
or Edge those entries land in Other Bookmarks, as they do from Firefox's own
export.
export. The other way round, Chrome's own export writes Other's and Mobile's
contents loose (§1.2), so in Firefox they land in the Bookmarks Menu, exactly
as Firefox's own import places them; our exports mark both roots and land
where they came from.
### 1.2 Parse tolerance (import)
+4 -3
View File
@@ -343,9 +343,10 @@ after `c` in `[a, b, c]` is `move(a, { index: 3 })`, and `onMoved` then reports
index 2. **Firefox** (since v1.3.0) counts after removal in the call too —
`move(a, { index: 2 })` — as Places stores the final position. A move to the
left is the same number in both. `planDrop` returns both numbers; the adapter
(`browser/bookmarks.ts` `move`) sends `api` to Chromium and `local` to Firefox,
and compares the node's index in the call's reply with `local`, re-reading the
tree on a mismatch (`03 §3`).
(`browser/bookmarks.ts` `move`, through `moveIndexFor` in `live-tree.ts`)
sends `api` to Chromium and `local` to Firefox and returns the index the
browser reports; `moveTo` in `stores/edit-commands.svelte.ts` compares it with
`local` and re-reads the tree on a mismatch (`03 §3`).
**Separators** (Firefox) are children like any other here: they occupy
indices, `planDrop` may place a node before or after one, and Alt+↑/↓ steps
+6 -4
View File
@@ -276,7 +276,8 @@ disabled while a bulk command runs.
fixed-height scroller, mounted 500 rows at a time with a "Show more" row
(`05 §9`); the roots start open. A row: disclosure chevron · glyph (folder,
open folder, link — a lock for a policy-managed node) · title (an untitled
bookmark shows its address, muted, in mono) · host · a child count on folders ·
bookmark shows its address, muted, in mono) · host · a child count on folders
(bookmarks and folders — a Firefox separator is not counted) ·
⚠ on an address Open refuses (`09` T3) · action buttons, shown on hover and on
the focused row: **Open** and **Copy link** (bookmarks), **Sort A→Z**
(sortable folders), **Rename**, **Move to…**, **Delete** (editable nodes only —
@@ -491,9 +492,10 @@ held failures at the head of the one queue instead, and every later toast —
the panel's close button, the delete buttons having gone with the copies.
After a confirmed **Sort A→Z** from the toolbar — whose button is disabled
while the sort runs, which is what dropped it — focus goes to the tree.
- **Separators (Firefox, since v1.3.0)** render as a line inside a
`role="none"`, `aria-hidden` list item between the `treeitem`s, so the tree
still owns only tree items. They take no focus, so ↑/↓, Home/End and
- **Separators (Firefox, since v1.3.0)** render as a line inside an
`aria-hidden` list item between the `treeitem`s — outside the accessibility
tree, so the tree still owns only tree items, and with no `role`, which a
hidden element does not need. They take no focus, so ↑/↓, Home/End and
type-ahead pass over them, and `aria-posinset`/`aria-setsize` count the
items around them, not the separators. Alt+↑/↓ does step past one, one place
at a time, as a drag would — and since the separator is not counted, the
+10 -4
View File
@@ -197,10 +197,16 @@ behaves the way Firefox's source says its API does
all four always present; no `folderType`; separators as
`{ type: 'separator', url: 'data:' }`; a same-folder `move` that takes the
final position; no `onChildrenReordered` or `onImport*`; `get('3')`
rejected; addresses over 65 536 characters refused. The root, separator, move,
Replace and export suites run over both flavours (`describe.each`) — which is
also how the position fallback in `getRoots`, never reached by the Chromium
fake, got its first test. ⚠️ The fake is built from reading Firefox's source;
rejected; addresses over 65 536 characters refused. Firefox has suites of its own rather than
a second pass of the Chromium ones: `firefox-import.test.ts` (roots by GUID;
Merge, New-folder and Replace — all four roots emptied, the backup restored
twice; export), `edit-firefox.test.ts` (the edit model, keyboard positions,
Sort A→Z around separators, drops and Alt+↑/↓ at Firefox's index, the re-read
when the browser reports another landing place), `live-tree.test.ts`
(separators, counts, the Menu marker, each browser's move index) and the pure
`firefox-menu.test.ts`. The position fallback in `getRoots`, which neither
fake reaches — both have known ids — is tested in `bookmarks.test.ts` with
hand-built roots of unknown ids, including a Menu listed first. ⚠️ The fake is built from reading Firefox's source;
a sanitized `getTree()` dump from a real Firefox 140+ profile, committed as a
fixture the fake is checked against, would turn that reading into evidence
(`00 §10`).
+12 -7
View File
@@ -123,9 +123,9 @@ v1.3.0):
| Job | Token | Does |
|---|---|---|
| `build` "Gate + package" | `contents: read` | install, **every CI gate again** (a tag skips the branch triggers, and must never ship what a PR would have blocked), `zip` and (since v1.3.0) `zip:firefox` — the Chrome/Edge package, the Firefox package and its sources archive — `check:manifest` on both packages, the tag ↔ manifest version check on both, `SHA256SUMS.txt` over all three files, each staged by its exact name so a missing one fails the run (a glob would pass with one of three); copies both files into a plain `dist/` and uploads that as the artifact `release-<tag>` — `upload-artifact` skips hidden paths such as `.output/` by default, which failed the first v1.1.0 tag run before any Release existed |
| `build` "Gate + package" | `contents: read` | install, **every CI gate again** (a tag skips the branch triggers, and must never ship what a PR would have blocked), `zip` and (since v1.3.0) `zip:firefox` — the Chrome/Edge package, the Firefox package and its sources archive — `check:manifest` on both packages, the tag ↔ manifest version check on both, `SHA256SUMS.txt` over all three files, each staged by its exact name so a missing one fails the run (a glob would pass with one of three); copies the three files and `SHA256SUMS.txt` into a plain `dist/` and uploads that as the artifact `release-<tag>` — `upload-artifact` skips hidden paths such as `.output/` by default, which failed the first v1.1.0 tag run before any Release existed |
| `publish` "GitHub Release" | `contents: write` | downloads the artifact, `sha256sum -c` it, creates the Release with `--verify-tag` (or re-uploads to an existing one). Installs nothing and runs no repository code — the only job that ever holds a write token |
| `store-chrome`, `store-firefox`, `store-edge` | `contents: read` | since v1.3.0, one job per store, each only when its own repo variable is `'true'` (`CWS_AUTOPUBLISH`, `AMO_AUTOPUBLISH`, `EDGE_AUTOPUBLISH`) and each in its own GitHub **Environment** holding only that store's secrets (§3). They install `tools/publish/` — `publish-browser-extension` and its three dependencies, from their own lockfile, scripts off — instead of the whole dev toolchain, check the downloaded files against `SHA256SUMS.txt`, and run its `publish-extension` binary. Before v1.3.0 a single `store` job ran `wxt submit` after a full `npm ci`: four Chrome secrets shared a runner with ~320 packages |
| `store-chrome`, `store-firefox`, `store-edge` | `contents: read` | since v1.3.0, one job per store, each only when its own repo variable is `'true'` (`CWS_AUTOPUBLISH`, `AMO_AUTOPUBLISH`, `EDGE_AUTOPUBLISH`) and each in its own GitHub **Environment** holding only that store's secrets (§3). They install `tools/publish/` — `publish-browser-extension` and its three dependencies, from their own lockfile, scripts off — instead of the whole dev toolchain, check the downloaded files by exact name against the `SHA256SUMS.txt` of the **published Release** (not the artifact's own copy), and run its `publish-extension` binary. Before v1.3.0 a single `store` job ran `wxt submit` after a full `npm ci`: four Chrome secrets shared a runner with ~320 packages |
| `announce` | `contents: read` | Discord, only when `DISCORD_ANNOUNCE` is `'true'` |
Before the split, one job ran `npm ci` — every dependency's install script plus
@@ -320,8 +320,12 @@ review.
- **One job per store**, so a store's credentials never share a runner with
another's, and one store refusing an upload does not stop the others.
- **Environments** carry the secrets, not the repository, so nothing else in
any workflow can read them; give each one a required reviewer (the owner) to
approve every upload.
any workflow can read them. Give each one a required reviewer (the owner) to
approve every upload, **and** restrict its deployment branches and tags to
the tag pattern `v*`: an environment GitHub creates on first use has no
rule at all, so any branch with a workflow that names it — a pushed branch,
not only a release — could reach its secrets. The reviewer is the second
lock, not the only one.
- **Chrome Web Store API v2.** v1.1 — what the old `store` job's
client-id/secret/refresh-token secrets used — was shut down on 2026-10-15;
that job would have failed the day `CWS_AUTOPUBLISH` was set. v2 takes a
@@ -391,13 +395,14 @@ means "unknown", not "not done".
- [x] CodeQL **Default setup DISABLED** (Settings → Advanced Security) —
confirmed 2026-07-26; `codeql.yml` uploads SARIF cleanly, which is only
possible with it off (§2.2).
- [ ] ⚠️ Store environments (§3), each with the owner as required reviewer and
only its own secrets: `chrome-web-store` (the four API v2 values;
- [ ] ⚠️ Store environments (§3), each with the owner as required reviewer,
deployments limited to tags matching `v*`, and only its own secrets: `chrome-web-store` (the four API v2 values;
`CHROME_EXTENSION_ID` is the item id in `00 §9`), `firefox-add-ons`
(`FIREFOX_EXTENSION_ID` = `bookmarkmagic@poli0981.dev` and the AMO JWT
pair), `edge-add-ons` (product id, Client ID, API key — rotate every 72
days). GitHub creates an environment the first time a job names it, with
no protection; add the reviewer and secrets in Settings → Environments.
no protection; add the reviewer, the `v*` tag rule and the secrets in
Settings → Environments.
- [x] Actions secrets for Discord notifications — **present as of 2026-10-28:**
`DISCORD_CI_WEBHOOK`, `RELEASES_WEBHOOK`, `REPO_WEBHOOK` (the last two under
names the reusable does not read; `release.yml` maps them, §2.3).
+3 -1
View File
@@ -28,6 +28,8 @@
const focused = $derived(session.focusedId === node.id);
const renaming = $derived(session.renamingId === node.id && editable);
const domain = $derived(hostOf(node.url));
// Bookmarks and folders only: a Firefox separator is not an item (docs/03 §3).
const itemCount = $derived((node.children ?? []).filter((c) => c.separator !== true).length);
const blocked = $derived(!isFolder && isBlockedUrl(node.url));
/** Which part of this row a drag is over, when the drop there is legal. */
@@ -118,7 +120,7 @@
{:else}
<span class="title" class:untitled={node.title === ''}>{node.title === '' ? (node.url ?? '') : node.title}</span>
{#if domain !== ''}<span class="domain">{domain}</span>{/if}
{#if isFolder}<span class="count">{node.children?.length ?? 0}</span>{/if}
{#if isFolder}<span class="count">{itemCount}</span>{/if}
{#if blocked}
<!-- docs/09 T3: a javascript:/data: bookmark must not look like an
ordinary link that merely does nothing when clicked. -->
+2 -1
View File
@@ -56,7 +56,8 @@ export function visibleRows(
node,
depth,
parentId,
expandable: node.url === undefined && children.length > 0,
// A folder holding only separators has nothing to step into.
expandable: node.url === undefined && children.some((child) => child.separator !== true),
expanded: isOpen,
posInSet: position,
setSize,
+3 -3
View File
@@ -59,8 +59,8 @@ export interface PreparedImport {
/** The live roots at preview time — what the Start button's preview plan is built against. */
destinations: PlanDestinations;
/**
* Everything inside the writable roots: what Replace would delete (docs/09
* T4). Separators (Firefox) are counted apart — never as bookmarks — so the
* Everything inside the roots Replace empties — exactly what it would
* delete (docs/09 T4); a signed-in Chrome's account roots are not among them. Separators (Firefox) are counted apart — never as bookmarks — so the
* confirmation can say they will not come back (docs/03 §1).
*/
current: { bookmarks: number; folders: number; separators: number };
@@ -106,7 +106,7 @@ export async function prepareImport(
const roots = await getRoots();
const browserIndex = buildUrlIndex(withoutSeparators(roots.all));
const { existsCount, status } = diffAgainstBrowser(result.roots, browserIndex);
const inside = countLive(roots.writable.flatMap((root) => root.children ?? []));
const inside = countLive(roots.replaceable.flatMap((root) => root.children ?? []));
return {
format,
+7 -2
View File
@@ -51,9 +51,14 @@ export class EditSession extends EditCommands {
: [],
);
/** Any folder with two or more children that is not policy-managed, roots included. */
/**
* Any folder with two or more items that is not policy-managed, roots
* included. Separators (Firefox) are not items: they never move in a sort.
*/
canSort = (node: EditNode): boolean =>
node.url === undefined && node.unmodifiable === undefined && (node.children?.length ?? 0) > 1;
node.url === undefined &&
node.unmodifiable === undefined &&
(node.children ?? []).filter((child) => child.separator !== true).length > 1;
keepFirst = async (): Promise<void> => {
this.pendingKeepFirst = false;
+43
View File
@@ -141,6 +141,49 @@ describe('getRoots', () => {
expect(roots.replaceable.map((r) => r.id)).toEqual(['1', '2', '3']);
expect(roots.writable.map((r) => r.id)).toEqual(['50', '51', '1', '2']);
});
it('falls back to position for roots with neither folderType nor a known id', async () => {
// The path that mapped Firefox's roots wrongly before v1.3.0: nothing
// else in the suite reaches it, since both fakes have known ids.
const folder = (id: string, title: string) => ({ id, parentId: 'r', title, children: [] });
current.getTree = async () => [
{
id: 'r',
title: '',
children: [folder('a', 'Bar'), folder('b', 'Other'), folder('c', 'Mobile')],
},
];
const roots = await getRoots();
expect([roots.toolbarId, roots.otherId, roots.mobileId, roots.menuId]).toEqual([
'a',
'b',
'c',
undefined,
]);
});
it('never takes a Bookmarks Menu by position, even when it is listed first', async () => {
const folder = (id: string, title: string) => ({ id, parentId: 'r', title, children: [] });
current.getTree = async () => [
{
id: 'r',
title: '',
children: [
folder('menu________', 'Bookmarks Menu'),
folder('x', 'Bar'),
folder('y', 'Other'),
folder('z', 'Mobile'),
],
},
];
const roots = await getRoots();
expect([roots.toolbarId, roots.otherId, roots.mobileId, roots.menuId]).toEqual([
'x',
'y',
'z',
'menu________',
]);
});
});
describe('clearRoots', () => {
+27
View File
@@ -277,3 +277,30 @@ describe('Firefox backups', () => {
]);
});
});
describe('the Replace confirmation counts what Replace deletes', () => {
it('leaves out a signed-in account’s roots, which Replace never empties', async () => {
current.seed('1', { title: 'mine', url: 'https://mine.example/' });
const tree = await current.getTree();
const account = {
id: '50',
title: 'Bookmarks bar',
folderType: 'bookmarks-bar',
syncing: true,
children: [
{ id: '60', parentId: '50', title: 'theirs', url: 'https://theirs.example/' },
{ id: '61', parentId: '50', title: 'theirs too', url: 'https://theirs-too.example/' },
],
};
current.getTree = async () => [
{ ...tree[0], id: '0', title: '', children: [account, ...(tree[0]?.children ?? [])] },
];
const prepared = await prepareImport(
new File(
['<!DOCTYPE NETSCAPE-Bookmark-file-1><DL><DT><A HREF="https://x.example/">x</A></DL>'],
'f',
),
);
expect(prepared.current).toEqual({ bookmarks: 1, folders: 0, separators: 0 });
});
});
+34
View File
@@ -111,6 +111,40 @@ describe('keyboard and positions', () => {
});
});
describe('a folder of separators is not a folder of items', () => {
const onlySeparators: EditNode = {
id: 'f',
title: 'F',
children: [
{ id: 's1', title: '', url: 'data:', separator: true, parentId: 'f' },
{ id: 'x', title: 'x', url: 'https://x/', parentId: 'f' },
{ id: 's2', title: '', url: 'data:', separator: true, parentId: 'f' },
],
};
it('is not expandable when it holds nothing but separators', () => {
const empty: EditNode = {
...onlySeparators,
children: [onlySeparators.children?.[0] as EditNode],
};
expect(visibleRows([empty], new Set())[0]?.expandable).toBe(false);
expect(visibleRows([onlySeparators], new Set())[0]?.expandable).toBe(true);
});
it('cannot be sorted with a single item between separators', async () => {
await session.load();
expect(session.canSort(onlySeparators)).toBe(false);
const two: EditNode = {
...onlySeparators,
children: [
...(onlySeparators.children ?? []),
{ id: 'y', title: 'y', url: 'https://y/', parentId: 'f' },
],
};
expect(session.canSort(two)).toBe(true);
});
});
describe('Sort A→Z with separators', () => {
const node = (id: string, separator = false): EditNode =>
separator