19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:32:02 +01:00
parent 62d197ac8b
commit 184bb0e321
667 changed files with 691406 additions and 239886 deletions

View file

@ -0,0 +1,53 @@
// @ts-check
import { stores } from "@odoo/o-spreadsheet";
import { createModelWithDataSource } from "@spreadsheet/../tests/helpers/model";
const { ModelStore, NotificationStore, DependencyContainer } = stores;
/**
* @template T
* @typedef {import("@odoo/o-spreadsheet").StoreConstructor<T>} StoreConstructor<T>
*/
/**
* @typedef {import("@spreadsheet").OdooSpreadsheetModel} OdooSpreadsheetModel
*/
/**
* @template T
* @param {StoreConstructor<T>} Store
* @param {any[]} args
* @return {Promise<{ store: T, container: InstanceType<DependencyContainer>, model: OdooSpreadsheetModel }>}
*/
export async function makeStore(Store, ...args) {
const { model } = await createModelWithDataSource();
return makeStoreWithModel(model, Store, ...args);
}
/**
* @template T
* @param {import("@odoo/o-spreadsheet").Model} model
* @param {StoreConstructor<T>} Store
* @param {any[]} args
* @return {{ store: T, container: InstanceType<DependencyContainer>, model: OdooSpreadsheetModel }}
*/
export function makeStoreWithModel(model, Store, ...args) {
const container = new DependencyContainer();
container.inject(ModelStore, model);
container.inject(NotificationStore, makeTestNotificationStore());
return {
store: container.instantiate(Store, ...args),
container,
// @ts-ignore
model: container.get(ModelStore),
};
}
function makeTestNotificationStore() {
return {
notifyUser: () => {},
raiseError: () => {},
askConfirmation: () => {},
};
}