Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: create triggers after resetting database

Abdullah Attaf719bebe5ab3
diff --git a/packages/core/__e2e__/__snapshots__/pricing.test.js.snap b/packages/core/__e2e__/__snapshots__/pricing.test.js.snap
index b92262c58..1ace5ae40 100644
--- a/packages/core/__e2e__/__snapshots__/pricing.test.js.snap
+++ b/packages/core/__e2e__/__snapshots__/pricing.test.js.snap
@@ -63,6 +63,15 @@ exports[`get web pricing tier > get monthly web tier > monthly-web-pricing 1`] =
}
`;
+exports[`get web pricing tier > get monthly web tier > yearly-ios-pricing 1`] = `
+{
+ "country": Any<String>,
+ "countryCode": Any<String>,
+ "discount": Any<Number>,
+ "sku": Any<String>,
+}
+`;
+
exports[`get web pricing tier > get yearly web tier > yearly-web-pricing 1`] = `
{
"country": Any<String>,
diff --git a/packages/core/__e2e__/sync.test.js b/packages/core/__e2e__/sync.test.js
index 1a214bf6f..72818930b 100644
--- a/packages/core/__e2e__/sync.test.js
+++ b/packages/core/__e2e__/sync.test.js
@@ -536,7 +536,6 @@ async function cleanup(...devices) {
await device.syncer.stop();
await device.user.logout();
device.eventManager.unsubscribeAll();
- await device.reset();
}
EV.unsubscribeAll();
}
diff --git a/packages/core/src/api/index.ts b/packages/core/src/api/index.ts
index a8e9017d4..685f514a1 100644
--- a/packages/core/src/api/index.ts
+++ b/packages/core/src/api/index.ts
@@ -250,6 +250,7 @@ class Database {
this.sql().withTables(),
new NNMigrationProvider()
);
+ await this.onInit(this.sql() as Kysely<RawDatabaseSchema>);
await this.initCollections();
return true;
}
@@ -282,7 +283,7 @@ class Database {
this._sql = (await createDatabase<RawDatabaseSchema>("notesnook", {
...this.options.sqliteOptions,
migrationProvider: new NNMigrationProvider(),
- onInit: (db) => createTriggers(db)
+ onInit: (db) => this.onInit(db)
})) as unknown as Kysely<DatabaseSchema>;
await this.sanitizer.init();
@@ -296,6 +297,10 @@ class Database {
}
}
+ private async onInit(db: Kysely<RawDatabaseSchema>) {
+ await createTriggers(db);
+ }
+
async initCollections() {
await this.legacySettings.init();
// collections
diff --git a/packages/core/vitest.config.ts b/packages/core/vitest.config.ts
index c804772e6..644191c47 100644
--- a/packages/core/vitest.config.ts
+++ b/packages/core/vitest.config.ts
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { defineConfig } from "vitest/config";
const IS_E2E = process.env.IS_E2E === "true";
+const IS_CI = !!process.env.CI;
export default defineConfig({
test: {
@@ -30,7 +31,7 @@ export default defineConfig({
exclude: ["src/utils/templates/html/languages/*.js"],
include: ["src/**/*.ts"]
},
- retry: 1,
+ retry: IS_CI ? 1 : 0,
exclude: ["__benches__/**/*.bench.ts"],
include: [
...(IS_E2E ? ["__e2e__/**/*.test.{js,ts}"] : []),