-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support drag and drop for list items
- Loading branch information
Showing
12 changed files
with
240 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
BUILD_TYPE=development | ||
VITE_ENV="development" |
This file contains 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
VITE_SENTRY_DSN="https://0b9cdcee8d8040edb9cc9586ecb52a14@o1296550.ingest.sentry.io/6556279" | ||
BUILD_TYPE="production" | ||
VITE_ENV="production" |
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
BUILD_TYPE=test | ||
VITE_ENV="test" |
This file contains 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 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,13 @@ | ||
import { vi } from "vitest"; | ||
|
||
export const storage = { | ||
sync: { | ||
get: vi.fn().mockResolvedValue({}), | ||
set: vi.fn().mockResolvedValue(undefined), | ||
}, | ||
}; | ||
|
||
const browser = { | ||
storage, | ||
}; | ||
export default browser; |
This file contains 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,20 @@ | ||
<svg viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<circle cx="13" cy="8" r="2" fill="#000" /> | ||
<circle cx="13" cy="16" r="2" fill="#000" /> | ||
<circle cx="13" cy="24" r="2" fill="#000" /> | ||
<circle cx="20" cy="8" r="2" fill="#000" /> | ||
<circle cx="20" cy="16" r="2" fill="#000" /> | ||
<circle cx="20" cy="24" r="2" fill="#000" /> | ||
</svg> | ||
|
||
<style> | ||
svg { | ||
width: 18px; | ||
height: auto; | ||
pointer-events: none; | ||
} | ||
circle { | ||
fill: var(--body-fg); | ||
} | ||
</style> |
This file contains 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 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 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,93 @@ | ||
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; | ||
import * as browserStorage from "./_pinned-tabs-browser-storage"; | ||
import { PinnedTabsStore } from "./_pinned-tabs-store"; | ||
|
||
vi.mock("./_pinned-tabs-browser-storage"); | ||
|
||
describe("PinnedTabsStore", () => { | ||
let store: PinnedTabsStore; | ||
|
||
beforeEach(() => { | ||
vi.useFakeTimers(); | ||
vi.mocked(browserStorage.getUrlsToPin).mockResolvedValue([]); | ||
store = new PinnedTabsStore(); | ||
}); | ||
|
||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
vi.useRealTimers(); | ||
}); | ||
|
||
test("initializes with empty array", async () => { | ||
const subscriber = vi.fn(); | ||
store.subscribe(subscriber); | ||
|
||
await vi.runAllTimersAsync(); | ||
|
||
expect(subscriber).toHaveBeenCalledWith({ | ||
urls: [""], | ||
pendingChanges: false, | ||
}); | ||
}); | ||
|
||
test("saves URLs and notifies subscribers", async () => { | ||
const subscriber = vi.fn(); | ||
store.subscribe(subscriber); | ||
|
||
store.saveURLs(["https://example.com"]); | ||
|
||
expect(subscriber).toHaveBeenCalledWith({ | ||
urls: ["https://example.com"], | ||
pendingChanges: true, | ||
}); | ||
|
||
await vi.advanceTimersByTimeAsync(1000); | ||
|
||
expect(browserStorage.setUrlsToPin).toHaveBeenCalledWith([ | ||
"https://example.com", | ||
]); | ||
expect(subscriber).toHaveBeenCalledWith({ | ||
urls: ["https://example.com"], | ||
pendingChanges: false, | ||
}); | ||
}); | ||
|
||
test("debounces multiple saveURLs calls", async () => { | ||
store.saveURLs(["https://example1.com"]); | ||
store.saveURLs(["https://example2.com"]); | ||
store.saveURLs(["https://example3.com"]); | ||
|
||
await vi.advanceTimersByTimeAsync(1000); | ||
|
||
expect(browserStorage.setUrlsToPin).toHaveBeenCalledTimes(1); | ||
expect(browserStorage.setUrlsToPin).toHaveBeenCalledWith([ | ||
"https://example3.com", | ||
]); | ||
}); | ||
|
||
test("cancels pending save", async () => { | ||
const subscriber = vi.fn(); | ||
store.subscribe(subscriber); | ||
|
||
store.saveURLs(["https://example.com"]); | ||
store.cancelSave(); | ||
|
||
await vi.advanceTimersByTimeAsync(1000); | ||
|
||
expect(browserStorage.setUrlsToPin).not.toHaveBeenCalled(); | ||
expect(subscriber).toHaveBeenCalledWith({ | ||
urls: ["https://example.com"], | ||
pendingChanges: true, | ||
}); | ||
}); | ||
|
||
test("handles unsubscribe correctly", () => { | ||
const subscriber = vi.fn(); | ||
const unsubscribe = store.subscribe(subscriber); | ||
|
||
unsubscribe(); | ||
store.saveURLs(["https://example.com"]); | ||
|
||
expect(subscriber).toHaveBeenCalledTimes(1); // Only the initial call | ||
}); | ||
}); |
This file contains 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 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 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,4 @@ | ||
import { vi } from "vitest"; | ||
|
||
// This will ensure the mock is loaded for all tests | ||
vi.mock("webextension-polyfill"); |