Skip to content

Commit 8ca73b7

Browse files
committedNov 10, 2024
[BREAKS TESTS] "Corrupt" the bookmarks DB fixture
Make the big_stash folder have inconsistent indexes, so we can see how Tab Stash behaves when a user's bookmarks DB has similar inconsistencies.
1 parent 6c72e10 commit 8ca73b7

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed
 

‎src/model/fixtures.testlib.ts

+15-11
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,18 @@ const BOOKMARKS = {
107107
id: "big_stash",
108108
title: "Big Stash",
109109
children: [
110-
{id: "one", title: "One", url: `${B}#1`},
111-
{id: "two", title: "Two", url: `${B}#2`},
112-
{id: "three", title: "Three", url: `${B}#3`},
113-
{id: "four", title: "Four", url: `${B}#4`},
114-
{id: "five", title: "Five", url: `${B}#5`},
115-
{id: "six", title: "Six", url: `${B}#6`},
116-
{id: "seven", title: "Seven", url: `${B}#7`},
117-
{id: "eight", title: "Eight", url: `${B}#8`},
110+
// The indexes in big_stash are intentionally corrupt/inconsistent
111+
// with their actual positions in the folder, to simulate some
112+
// common corruptions I've seen in Firefox's bookmarks DB (both
113+
// duplicate indexes and negative indexes).
114+
{_index: -2, id: "one", title: "One", url: `${B}#1`},
115+
{_index: -1, id: "two", title: "Two", url: `${B}#2`},
116+
{_index: 0, id: "three", title: "Three", url: `${B}#3`},
117+
{_index: 2, id: "four", title: "Four", url: `${B}#4`},
118+
{_index: 2, id: "five", title: "Five", url: `${B}#5`},
119+
{_index: 5, id: "six", title: "Six", url: `${B}#6`},
120+
{_index: 6, id: "seven", title: "Seven", url: `${B}#7`},
121+
{_index: 7, id: "eight", title: "Eight", url: `${B}#8`},
118122
],
119123
},
120124
{
@@ -227,10 +231,12 @@ type BookmarkNamesHere<B extends NamedBookmark> =
227231
? BookmarkNamesHere<B["children"][any]>
228232
: never);
229233
interface NamedBookmark {
234+
readonly index?: number;
230235
readonly id: string;
231236
readonly children?: readonly NamedBookmark[];
232237
}
233238
interface NamedBookmarkFolder {
239+
readonly index?: number;
234240
readonly id: string;
235241
readonly children: readonly NamedBookmark[];
236242
}
@@ -253,7 +259,7 @@ export async function make_bookmarks(): Promise<BookmarkFixture> {
253259

254260
async function gen(
255261
id: BookmarkName,
256-
bm: any,
262+
bm: NamedBookmark | NamedBookmarkFolder,
257263
parentId: string | undefined,
258264
): Promise<Bookmarks.BookmarkTreeNode> {
259265
/* c8 ignore next -- bug-checking */
@@ -266,8 +272,6 @@ export async function make_bookmarks(): Promise<BookmarkFixture> {
266272
const new_kids: Bookmarks.BookmarkTreeNode[] = [];
267273
res[id]!.children = new_kids;
268274
for (const c of bm.children) {
269-
c.parentId = res[id]!.id;
270-
c.index = i;
271275
new_kids.push(await gen(c.id as BookmarkName, c, res[id]!.id));
272276
++i;
273277
}

0 commit comments

Comments
 (0)