Skip to content

Fix failing importData tests from PR #678 (IndexedDB support)#685

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/review-pull-request-678
Closed

Fix failing importData tests from PR #678 (IndexedDB support)#685
Copilot wants to merge 2 commits intomainfrom
copilot/review-pull-request-678

Conversation

Copy link

Copilot AI commented Feb 24, 2026

PR #678 refactored importData to require a versioned export format (__meta__ + typed namespaces), but the tests still passed raw chrome.storage data directly, causing two failures: merge rules returning [] and allowDelay being undefined instead of false.

Infrastructure added

  • src/util/guard.tsisRecord, isOptionalInt, isVector2 type guards via typescript-guard
  • src/database/common/migratable.tsisExportData, isLegacyVersion, extractNamespace for versioned import/export logic
  • src/database/types.d.tsBrowserMigratable<N> interface for databases that support import/export
  • types/timer/backup.d.tsExportMeta and ExportData types for the versioned format

Database updates

merge-rule-database and limit-database now route importData based on version:

async importData(data: unknown): Promise<void> {
    if (isLegacyVersion(data)) {       // version.__meta__.major < 4
        return this.importLegacyData(data)
    }
    const rules = extractNamespace(data, this.namespace, createArrayGuard(isMergeRule)) ?? []
    await this.add(...rules)
}

Legacy path preserves the original key-based chrome storage import. Both databases also expose exportData() implementing BrowserMigratable.

Test fix

Added test/database/migratable.ts with mockLegacyData to wrap raw storage snapshots with __meta__: { version: "3.8.15" }, routing them through the legacy import path:

await db.importData(mockLegacyData(data2Import))  // was: db.importData(data2Import)

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…ersioned format

Co-authored-by: sheepzh <19428473+sheepzh@users.noreply.github.com>
@sheepzh sheepzh closed this Feb 24, 2026
Copilot AI changed the title [WIP] Review pull request #678 for changes Fix failing importData tests from PR #678 (IndexedDB support) Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants