From b8a652e2ca3cac7b0cffc4d40bd8ad255f564634 Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Tue, 14 Apr 2020 10:49:10 +0200 Subject: [PATCH] updates tests and method names to getNewModelTemplate method --- .../builder/src/builderStore/store/backend.js | 2 +- packages/core/src/templateApi/createNodes.js | 12 ++--- packages/core/src/templateApi/index.js | 4 +- packages/core/test/indexing.schema.spec.js | 4 +- .../core/test/recordApi.getRecordInfo.spec.js | 6 +-- packages/core/test/specHelpers.js | 14 +++--- .../templateApi.constructHeirarchy.spec.js | 48 +++++++++---------- .../test/templateApi.diffHierarchy.spec.js | 20 ++++---- packages/core/test/templateApi.fields.spec.js | 2 +- .../templateApi.heirarchyValidation.spec.js | 4 +- .../templateApi.loadSaveHeirarchy.spec.js | 2 +- .../core/test/templateApi.upgradeData.spec.js | 24 +++++----- packages/core/test/upgradeDataSetup.js | 6 +-- packages/datastores/tests/setup.js | 6 +-- 14 files changed, 77 insertions(+), 77 deletions(-) diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 2891977119..d583b22947 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -115,7 +115,7 @@ export const newModel = (store, useRoot) => () => { ? shadowHierarchy : getNode(shadowHierarchy, state.currentNode.nodeId) state.errors = [] - state.currentNode = templateApi(shadowHierarchy).getNewRecordTemplate( + state.currentNode = templateApi(shadowHierarchy).getNewModelTemplate( parent, "", true diff --git a/packages/core/src/templateApi/createNodes.js b/packages/core/src/templateApi/createNodes.js index a9a45617a2..46f7c67847 100644 --- a/packages/core/src/templateApi/createNodes.js +++ b/packages/core/src/templateApi/createNodes.js @@ -49,7 +49,7 @@ const nodeKeyMaker = node => () => )(node) const nodeNameMaker = node => () => - isRoot(node) + isRoot(node) ? "/" : joinKey(node.parent().nodeName(), node.name) @@ -165,7 +165,7 @@ export const getNewRootLevel = () => nodeId: 0, }) -const _getNewRecordTemplate = (parent, name, createDefaultIndex, isSingle) => { +const _getNewModelTemplate = (parent, name, createDefaultIndex, isSingle) => { const nodeId = getNodeId(parent) const node = constructNode(parent, { name, @@ -189,14 +189,14 @@ const _getNewRecordTemplate = (parent, name, createDefaultIndex, isSingle) => { return node } -export const getNewRecordTemplate = ( +export const getNewModelTemplate = ( parent, name = "", createDefaultIndex = true -) => _getNewRecordTemplate(parent, name, createDefaultIndex, false) +) => _getNewModelTemplate(parent, name, createDefaultIndex, false) export const getNewSingleRecordTemplate = parent => - _getNewRecordTemplate(parent, "", false, true) + _getNewModelTemplate(parent, "", false, true) export const getNewIndexTemplate = (parent, type = "ancestor") => constructNode(parent, { @@ -233,7 +233,7 @@ export const getNewAggregateTemplate = set => { export default { getNewRootLevel, - getNewRecordTemplate, + getNewModelTemplate, getNewIndexTemplate, createNodeErrors, constructHierarchy, diff --git a/packages/core/src/templateApi/index.js b/packages/core/src/templateApi/index.js index 8bbb27a374..e31109c2e0 100644 --- a/packages/core/src/templateApi/index.js +++ b/packages/core/src/templateApi/index.js @@ -1,6 +1,6 @@ import { getNewRootLevel, - getNewRecordTemplate, + getNewModelTemplate, getNewIndexTemplate, createNodeErrors, constructHierarchy, @@ -38,7 +38,7 @@ const api = app => ({ getNewRootLevel, constructNode, getNewIndexTemplate, - getNewRecordTemplate, + getNewModelTemplate, getNewField, validateField, addField, diff --git a/packages/core/test/indexing.schema.spec.js b/packages/core/test/indexing.schema.spec.js index a74aa6d4c5..22a8027b6f 100644 --- a/packages/core/test/indexing.schema.spec.js +++ b/packages/core/test/indexing.schema.spec.js @@ -76,7 +76,7 @@ const setup = includeFish => setupApphierarchy(createApp(includeFish)) const createApp = includeFish => templateApi => { const root = templateApi.getNewRootLevel() - const dogRecord = templateApi.getNewRecordTemplate(root, "dog") + const dogRecord = templateApi.getNewModelTemplate(root, "dog") const addField = recordNode => (name, type, typeOptions) => { const field = templateApi.getNewField(type) @@ -97,7 +97,7 @@ const createApp = includeFish => templateApi => { let fishStuff = {} if (includeFish) { - const fishRecord = templateApi.getNewRecordTemplate(root, "fish") + const fishRecord = templateApi.getNewModelTemplate(root, "fish") const addFishField = addField(fishRecord) addFishField("name", "string") addFishField("isAlive", "bool") diff --git a/packages/core/test/recordApi.getRecordInfo.spec.js b/packages/core/test/recordApi.getRecordInfo.spec.js index 72bef1bc27..afccbbf0a4 100644 --- a/packages/core/test/recordApi.getRecordInfo.spec.js +++ b/packages/core/test/recordApi.getRecordInfo.spec.js @@ -133,15 +133,15 @@ const setup = ({ parentCount, childCount, grandChildCount }) => return field } - const parent = templateApi.getNewRecordTemplate(root, "parent") + const parent = templateApi.getNewModelTemplate(root, "parent") parent.estimatedRecordCount = parentCount || 1000 parent.collectionName = "parents" addField(parent) - const child = templateApi.getNewRecordTemplate(parent, "child") + const child = templateApi.getNewModelTemplate(parent, "child") child.estimatedRecordCount = childCount || 1000 child.collectionName = "children" addField(child) - const grandchild = templateApi.getNewRecordTemplate(child, "grandchild") + const grandchild = templateApi.getNewModelTemplate(child, "grandchild") grandchild.estimatedRecordCount = grandChildCount || 1000 grandchild.collectionName = "grandchildren" addField(grandchild) diff --git a/packages/core/test/specHelpers.js b/packages/core/test/specHelpers.js index 227280477a..106e754a25 100644 --- a/packages/core/test/specHelpers.js +++ b/packages/core/test/specHelpers.js @@ -42,7 +42,7 @@ export const getMemoryStore = () => setupDatastore(memory({})) export const getMemoryTemplateApi = store => { const app = { datastore: store || getMemoryStore(), - publish: () => {}, + publish: () => { }, getEpochTime: async () => new Date().getTime(), user: { name: "", permissions: [permission.writeTemplates.get()] }, } @@ -78,7 +78,7 @@ export const appFromTempalteApi = async ( const fullPermissions = generateFullPermissions(app) app.user.permissions = fullPermissions - if (disableCleanupTransactions) setCleanupFunc(app, async () => {}) + if (disableCleanupTransactions) setCleanupFunc(app, async () => { }) else setCleanupFunc(app) return app @@ -138,15 +138,15 @@ export const hierarchyFactory = (...additionalFeatures) => templateApi => { const settingsRecord = templateApi.getNewSingleRecordTemplate(root) settingsRecord.name = "settings" - const customerRecord = templateApi.getNewRecordTemplate(root, "customer") + const customerRecord = templateApi.getNewModelTemplate(root, "customer") customerRecord.collectionName = "customers" findCollectionDefaultIndex(customerRecord).map = "return {surname:record.surname, isalive:record.isalive, partner:record.partner};" - const partnerRecord = templateApi.getNewRecordTemplate(root, "partner") + const partnerRecord = templateApi.getNewModelTemplate(root, "partner") partnerRecord.collectionName = "partners" - const partnerInvoiceRecord = templateApi.getNewRecordTemplate( + const partnerInvoiceRecord = templateApi.getNewModelTemplate( partnerRecord, "invoice" ) @@ -154,7 +154,7 @@ export const hierarchyFactory = (...additionalFeatures) => templateApi => { findCollectionDefaultIndex(partnerInvoiceRecord).name = "partnerInvoices_index" - const invoiceRecord = templateApi.getNewRecordTemplate( + const invoiceRecord = templateApi.getNewModelTemplate( customerRecord, "invoice" ) @@ -162,7 +162,7 @@ export const hierarchyFactory = (...additionalFeatures) => templateApi => { findCollectionDefaultIndex(invoiceRecord).map = "return {createdDate: record.createdDate, totalIncVat: record.totalIncVat};" - const chargeRecord = templateApi.getNewRecordTemplate(invoiceRecord, "charge") + const chargeRecord = templateApi.getNewModelTemplate(invoiceRecord, "charge") chargeRecord.collectionName = "charges" const hierarchy = { diff --git a/packages/core/test/templateApi.constructHeirarchy.spec.js b/packages/core/test/templateApi.constructHeirarchy.spec.js index 1bd238e224..d191a3322a 100644 --- a/packages/core/test/templateApi.constructHeirarchy.spec.js +++ b/packages/core/test/templateApi.constructHeirarchy.spec.js @@ -16,10 +16,10 @@ describe("hierarchy node creation", () => { expect(root.nodeName()).toBe("/") }) - it("> getNewRecordTemplate > should be initialise with correct members", async () => { + it("> getNewModelTemplate > should be initialise with correct members", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const record = templateApi.getNewRecordTemplate(root) + const record = templateApi.getNewModelTemplate(root) record.name = "child" expect(record.type).toBe("record") expect(record.children).toEqual([]) @@ -45,7 +45,7 @@ describe("hierarchy node creation", () => { expect(record.isSingle).toBe(true) }) - it("> getNewrecordTemplate > should have static pathRegx if is singlerecord", async () => { + it("> getNewModelTemplate > should have static pathRegx if is singlerecord", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() const record = templateApi.getNewSingleRecordTemplate(root) @@ -53,59 +53,59 @@ describe("hierarchy node creation", () => { expect(record.pathRegx()).toBe("/child") }) - it("> getNewrecordTemplate > should add itself to parent records's children", async () => { + it("> getNewModelTemplate > should add itself to parent records's children", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const parentRecord = templateApi.getNewRecordTemplate(root) - const record = templateApi.getNewRecordTemplate(parentRecord) + const parentRecord = templateApi.getNewModelTemplate(root) + const record = templateApi.getNewModelTemplate(parentRecord) expect(parentRecord.children.length).toBe(1) expect(parentRecord.children[0]).toBe(record) }) - it("> getNewrecordTemplate > child should get correct nodeName ", async () => { + it("> getNewModelTemplate > child should get correct nodeName ", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const parentRecord = templateApi.getNewRecordTemplate(root) + const parentRecord = templateApi.getNewModelTemplate(root) parentRecord.name = "parent" - const record = templateApi.getNewRecordTemplate(parentRecord) + const record = templateApi.getNewModelTemplate(parentRecord) record.name = "child" expect(record.nodeName()).toBe(`/${parentRecord.name}/${record.name}`) }) - it("> getNewrecordTemplate > should add itself to parents's default index allowedNodeIds", async () => { + it("> getNewModelTemplate > should add itself to parents's default index allowedNodeIds", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const parentRecord = templateApi.getNewRecordTemplate(root) - const record = templateApi.getNewRecordTemplate(parentRecord) + const parentRecord = templateApi.getNewModelTemplate(root) + const record = templateApi.getNewModelTemplate(parentRecord) expect(root.indexes[0].allowedRecordNodeIds).toEqual([parentRecord.nodeId]) expect(parentRecord.indexes[0].allowedRecordNodeIds).toEqual([ record.nodeId, ]) }) - it("> getNewrecordTemplate > should add itself to root's children", async () => { + it("> getNewModelTemplate > should add itself to root's children", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const record = templateApi.getNewRecordTemplate(root) + const record = templateApi.getNewModelTemplate(root) expect(root.children.length).toBe(1) expect(root.children[0]).toBe(record) }) - it("> getNewrecordTemplate > should have dynamic pathRegx if parent is record", async () => { + it("> getNewModelTemplate > should have dynamic pathRegx if parent is record", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const parent = templateApi.getNewRecordTemplate(root) + const parent = templateApi.getNewModelTemplate(root) parent.collectionName = "customers" - const record = templateApi.getNewRecordTemplate(parent) + const record = templateApi.getNewModelTemplate(parent) record.name = "child" expect(record.pathRegx().startsWith("/customers")).toBe(true) expect(record.pathRegx().includes("[")).toBe(true) }) - it("> getNewrecordTemplate > should add default index", async () => { + it("> getNewModelTemplate > should add default index", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const record = templateApi.getNewRecordTemplate(root, "rec") + const record = templateApi.getNewModelTemplate(root, "rec") expect(root.indexes.length).toBe(1) expect(root.indexes[0].name).toBe("rec_index") }) @@ -138,7 +138,7 @@ describe("hierarchy node creation", () => { it("> getNewIndexTemplate > should add itself to record indexes", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const record = templateApi.getNewRecordTemplate(root) + const record = templateApi.getNewModelTemplate(root) const index = templateApi.getNewIndexTemplate(record) expect(record.indexes.length).toBe(1) expect(record.indexes[0]).toBe(index) @@ -150,7 +150,7 @@ describe("hierarchy node creation", () => { expect(() => templateApi.getNewIndexTemplate()).toThrow( errors.allNonRootNodesMustHaveParent ) - expect(() => templateApi.getNewRecordTemplate()).toThrow( + expect(() => templateApi.getNewModelTemplate()).toThrow( errors.allNonRootNodesMustHaveParent ) }) @@ -158,8 +158,8 @@ describe("hierarchy node creation", () => { it("> adding node > should just add one (bugfix)", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const parent = templateApi.getNewRecordTemplate(root) - templateApi.getNewRecordTemplate(parent) + const parent = templateApi.getNewModelTemplate(root) + templateApi.getNewModelTemplate(parent) expect(root.children.length).toBe(1) expect(parent.children.length).toBe(1) @@ -174,7 +174,7 @@ describe("hierarchy node creation", () => { it("> getNewAggregateGroupTemplate > should add itself to index aggregateGroups", async () => { const { templateApi } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const record = templateApi.getNewRecordTemplate(root) + const record = templateApi.getNewModelTemplate(root) const index = templateApi.getNewIndexTemplate(record) const aggregateGroup = templateApi.getNewAggregateGroupTemplate(index) expect(index.aggregateGroups.length).toBe(1) diff --git a/packages/core/test/templateApi.diffHierarchy.spec.js b/packages/core/test/templateApi.diffHierarchy.spec.js index 01eb54e69e..a029740eee 100644 --- a/packages/core/test/templateApi.diffHierarchy.spec.js +++ b/packages/core/test/templateApi.diffHierarchy.spec.js @@ -13,7 +13,7 @@ describe("diffHierarchy", () => { it("should detect root record created", async () => { const oldHierarchy = (await setup()).root; const newSetup = await setup() - const opportunity = newSetup.templateApi.getNewRecordTemplate(newSetup.root, "opportunity", false) + const opportunity = newSetup.templateApi.getNewModelTemplate(newSetup.root, "opportunity", false) const diff = diffHierarchy(oldHierarchy, newSetup.root) expect(diff).toEqual([{ newNode: opportunity, @@ -25,8 +25,8 @@ describe("diffHierarchy", () => { it("should only detect root record, when newly created root record has children ", async () => { const oldHierarchy = (await setup()).root; const newSetup = await setup() - const opportunity = newSetup.templateApi.getNewRecordTemplate(newSetup.root, "opportunity", false) - newSetup.templateApi.getNewRecordTemplate(opportunity, "invoice", true) + const opportunity = newSetup.templateApi.getNewModelTemplate(newSetup.root, "opportunity", false) + newSetup.templateApi.getNewModelTemplate(opportunity, "invoice", true) const diff = diffHierarchy(oldHierarchy, newSetup.root) expect(diff).toEqual([{ newNode: opportunity, @@ -38,7 +38,7 @@ describe("diffHierarchy", () => { it("should detect child record created", async () => { const oldHierarchy = (await setup()).root; const newSetup = await setup() - const opportunity = newSetup.templateApi.getNewRecordTemplate(newSetup.contact, "opportunity", false) + const opportunity = newSetup.templateApi.getNewModelTemplate(newSetup.contact, "opportunity", false) const diff = diffHierarchy(oldHierarchy, newSetup.root) expect(diff).toEqual([{ newNode: opportunity, @@ -98,7 +98,7 @@ describe("diffHierarchy", () => { it("should detect root record field removed", async () => { const oldSetup = await setup() const newSetup = await setup() - newSetup.contact.fields = newSetup.contact.fields.filter(f => f.name !== "name") + newSetup.contact.fields = newSetup.contact.fields.filter(f => f.name !== "name") const diff = diffHierarchy(oldSetup.root, newSetup.root) expect(diff).toEqual([{ newNode: newSetup.contact, @@ -110,7 +110,7 @@ describe("diffHierarchy", () => { it("should detect child record field removed", async () => { const oldSetup = await setup() const newSetup = await setup() - newSetup.deal.fields = newSetup.deal.fields.filter(f => f.name !== "name") + newSetup.deal.fields = newSetup.deal.fields.filter(f => f.name !== "name") const diff = diffHierarchy(oldSetup.root, newSetup.root) expect(diff).toEqual([{ newNode: newSetup.deal, @@ -118,7 +118,7 @@ describe("diffHierarchy", () => { type: HierarchyChangeTypes.recordFieldsChanged }]) }) - + it("should detect record field added", async () => { const oldSetup = await setup() const newSetup = await setup() @@ -140,7 +140,7 @@ describe("diffHierarchy", () => { const notesField = newSetup.templateApi.getNewField("string") notesField.name = "notes" newSetup.templateApi.addField(newSetup.contact, notesField) - newSetup.contact.fields = newSetup.contact.fields.filter(f => f.name !== "name") + newSetup.contact.fields = newSetup.contact.fields.filter(f => f.name !== "name") const diff = diffHierarchy(oldSetup.root, newSetup.root) expect(diff).toEqual([{ newNode: newSetup.contact, @@ -152,7 +152,7 @@ describe("diffHierarchy", () => { it("should detect root record estimated record count changed", async () => { const oldSetup = await setup() const newSetup = await setup() - newSetup.contact.estimatedRecordCount = 987 + newSetup.contact.estimatedRecordCount = 987 const diff = diffHierarchy(oldSetup.root, newSetup.root) expect(diff).toEqual([{ newNode: newSetup.contact, @@ -164,7 +164,7 @@ describe("diffHierarchy", () => { it("should detect root record estimated record count changed", async () => { const oldSetup = await setup() const newSetup = await setup() - newSetup.deal.estimatedRecordCount = 987 + newSetup.deal.estimatedRecordCount = 987 const diff = diffHierarchy(oldSetup.root, newSetup.root) expect(diff).toEqual([{ newNode: newSetup.deal, diff --git a/packages/core/test/templateApi.fields.spec.js b/packages/core/test/templateApi.fields.spec.js index fc1a700c30..05612de9ac 100644 --- a/packages/core/test/templateApi.fields.spec.js +++ b/packages/core/test/templateApi.fields.spec.js @@ -3,7 +3,7 @@ import { getMemoryTemplateApi } from "./specHelpers" import { fieldErrors } from "../src/templateApi/fields" const getRecordTemplate = templateApi => - $(templateApi.getNewRootLevel(), [templateApi.getNewRecordTemplate]) + $(templateApi.getNewRootLevel(), [templateApi.getNewModelTemplate]) const getValidField = templateApi => { const field = templateApi.getNewField("string") diff --git a/packages/core/test/templateApi.heirarchyValidation.spec.js b/packages/core/test/templateApi.heirarchyValidation.spec.js index ae535995b9..121ae9aca0 100644 --- a/packages/core/test/templateApi.heirarchyValidation.spec.js +++ b/packages/core/test/templateApi.heirarchyValidation.spec.js @@ -13,7 +13,7 @@ import { findCollectionDefaultIndex } from "./specHelpers" const createValidHierarchy = () => { const root = createNodes.getNewRootLevel() - const customerRecord = createNodes.getNewRecordTemplate(root, "customer") + const customerRecord = createNodes.getNewModelTemplate(root, "customer") customerRecord.collectionName = "customers" const customersDefaultIndex = findCollectionDefaultIndex(customerRecord) @@ -27,7 +27,7 @@ const createValidHierarchy = () => { allCustomersOwedFunctions.aggregatedValue = "return record.owed" allCustomersOwedFunctions.name = "all customers owed amount" - const partnerRecord = createNodes.getNewRecordTemplate(root, "partner") + const partnerRecord = createNodes.getNewModelTemplate(root, "partner") partnerRecord.collectionName = "partners" partnerRecord.name = "partner" const businessName = getNewField("string") diff --git a/packages/core/test/templateApi.loadSaveHeirarchy.spec.js b/packages/core/test/templateApi.loadSaveHeirarchy.spec.js index 6cd99e2908..ca86d95182 100644 --- a/packages/core/test/templateApi.loadSaveHeirarchy.spec.js +++ b/packages/core/test/templateApi.loadSaveHeirarchy.spec.js @@ -3,7 +3,7 @@ import { permission } from "../src/authApi/permissions" const saveThreeLevelHierarchy = async () => { const { templateApi, app } = await getMemoryTemplateApi() const root = templateApi.getNewRootLevel() - const record = templateApi.getNewRecordTemplate(root) + const record = templateApi.getNewModelTemplate(root) record.name = "customer" const surname = templateApi.getNewField("string") surname.name = "surname" diff --git a/packages/core/test/templateApi.upgradeData.spec.js b/packages/core/test/templateApi.upgradeData.spec.js index 8118180121..14d5d34fbe 100644 --- a/packages/core/test/templateApi.upgradeData.spec.js +++ b/packages/core/test/templateApi.upgradeData.spec.js @@ -1,4 +1,4 @@ -import { +import { getRecordApiFromTemplateApi, getIndexApiFromTemplateApi, } from "./specHelpers" @@ -24,7 +24,7 @@ describe("upgradeData", () => { ]) expect(remainingKeys.length).toBe(0) - + }) it("should not delete other root record types, when root record node deleted", async () => { @@ -39,7 +39,7 @@ describe("upgradeData", () => { ]) expect(remainingKeys.length > 0).toBe(true) - + }) it("should delete all child records, when child record node deleted", async () => { @@ -166,13 +166,13 @@ describe("upgradeData", () => { leadField.name = "lead" leadField.type = "reference" leadField.typeOptions = { - reverseIndexNodeKeys: [ newIndex.nodeKey() ], + reverseIndexNodeKeys: [newIndex.nodeKey()], indexNodeKey: "/lead_index", displayValue: "name" } newSetup.templateApi.addField(newSetup.contact, leadField) - + await upgradeData(oldSetup.app)(newSetup.root) const indexKey = `${records.lead1.key}/contact_leads` @@ -194,7 +194,7 @@ describe("upgradeData", () => { it("should initialise a new root record", async () => { const { oldSetup, newSetup } = await configure() - const invoice = newSetup.templateApi.getNewRecordTemplate(newSetup.root, "invoice", true) + const invoice = newSetup.templateApi.getNewModelTemplate(newSetup.root, "invoice", true) invoice.collectionName = "invoices" const nameField = newSetup.templateApi.getNewField("string") @@ -207,7 +207,7 @@ describe("upgradeData", () => { expect(itemsInNewIndex.length).toBe(0) - const newInvoice = _getNew(invoice, "/invoices") + const newInvoice = _getNew(invoice, "/invoices") await _save(newSetup.app, newInvoice) itemsInNewIndex = await _listItems(newSetup.app, "/invoice_index") @@ -217,7 +217,7 @@ describe("upgradeData", () => { it("should initialise a new child record", async () => { const { oldSetup, newSetup, records } = await configure() - const invoice = newSetup.templateApi.getNewRecordTemplate(newSetup.contact, "invoice", true) + const invoice = newSetup.templateApi.getNewModelTemplate(newSetup.contact, "invoice", true) invoice.collectionName = "invoices" const nameField = newSetup.templateApi.getNewField("string") @@ -230,7 +230,7 @@ describe("upgradeData", () => { expect(itemsInNewIndex.length).toBe(0) - const newInvoice = _getNew(invoice, `${records.contact1.key}/invoices`) + const newInvoice = _getNew(invoice, `${records.contact1.key}/invoices`) await _save(newSetup.app, newInvoice) itemsInNewIndex = await _listItems(newSetup.app, `${records.contact1.key}/invoice_index`) @@ -258,7 +258,7 @@ it("should rebuild affected index when field is removed", async () => { it("should rebuild affected index when field is added", async () => { const { oldSetup, newSetup, records } = await configure() - + const aliveField = newSetup.templateApi.getNewField("string") aliveField.name = "isalive" newSetup.templateApi.addField(newSetup.contact, aliveField) @@ -276,10 +276,10 @@ it("should rebuild affected index when field is added", async () => { const configure = async () => { const oldSetup = await setup() - + const recordApi = await getRecordApiFromTemplateApi(oldSetup.templateApi) const indexApi = await getIndexApiFromTemplateApi(oldSetup.templateApi) - + const newSetup = await setup(oldSetup.store) const records = await createSomeRecords(recordApi) diff --git a/packages/core/test/upgradeDataSetup.js b/packages/core/test/upgradeDataSetup.js index 063da97790..84fbc14ee5 100644 --- a/packages/core/test/upgradeDataSetup.js +++ b/packages/core/test/upgradeDataSetup.js @@ -5,7 +5,7 @@ import { initialiseData } from "../src/appInitialise/initialiseData" export const setup = async store => { const { templateApi } = await getMemoryTemplateApi(store) const root = templateApi.getNewRootLevel() - const contact = templateApi.getNewRecordTemplate(root, "contact", true) + const contact = templateApi.getNewModelTemplate(root, "contact", true) contact.collectionName = "contacts" const nameField = templateApi.getNewField("string") @@ -16,9 +16,9 @@ export const setup = async store => { templateApi.addField(contact, nameField) templateApi.addField(contact, statusField) - const lead = templateApi.getNewRecordTemplate(root, "lead", true) + const lead = templateApi.getNewModelTemplate(root, "lead", true) lead.collectionName = "leads" - const deal = templateApi.getNewRecordTemplate(contact, "deal", true) + const deal = templateApi.getNewModelTemplate(contact, "deal", true) deal.collectionName = "deals" templateApi.addField(deal, { ...nameField }) diff --git a/packages/datastores/tests/setup.js b/packages/datastores/tests/setup.js index f88cd330d5..18bef0b8d1 100644 --- a/packages/datastores/tests/setup.js +++ b/packages/datastores/tests/setup.js @@ -20,7 +20,7 @@ export default async datastore => { const clients = templateApi.getNewCollectionTemplate(root) clients.name = "clients" - const client = templateApi.getNewRecordTemplate(clients) + const client = templateApi.getNewModelTemplate(clients) client.name = "client" addStringField(client, "FamilyName") addStringField(client, "Address1") @@ -33,7 +33,7 @@ export default async datastore => { const children = templateApi.getNewCollectionTemplate(client) children.name = "children" - const child = templateApi.getNewRecordTemplate(children) + const child = templateApi.getNewModelTemplate(children) child.name = "child" addStringField(child, "FirstName") addStringField(child, "Surname") @@ -43,7 +43,7 @@ export default async datastore => { const contacts = templateApi.getNewCollectionTemplate(client) contacts.name = "contacts" - const contact = templateApi.getNewRecordTemplate(contacts) + const contact = templateApi.getNewModelTemplate(contacts) contact.name = "contact" addStringField(contact, "Name") addStringField(contact, "relationship")