import * as path from 'path'; import { expect } from 'chai'; import { Knex } from 'knex'; import loadEnv from "../../src/utils/loadEnv" loadEnv(); import getDatabaseClient from "../../src/database/knexClient" import {rollbackMigrations} from "../../src/database/knexClient" import { OrderBy } from "../../src/utils/enum"; import { BASELINE_VERSION_ID, CORE, CREATED_AT, DESCRIPTOR, DESCRIPTOR_SCHEMA_ID, DESCRIPTOR_SCHEMA_VERSION, EDITABLE, ID, INSTANCE_ID, RUNTIME, TENANT_ID, WORKPAGE_ID } from "../../src/utils/globals"; import { CoreService } from "../../src/service/coreService"; import { RuntimeService } from "../../src/service/RuntimeService"; import { exec } from 'child_process'; describe('Database tests', () => { // the tests container let dbClient:Knex; before(async function () { console.log("before"); dbClient = await getDatabaseClient(RUNTIME); }); // Drop the schema before each test in the describe block. after(async function () { console.log("after"); // await rollbackMigrations(dbClient, RUNTIME, true); }); it('Should return workpage with all related entities according to params sent', async () => { // the single test const workpage = await RuntimeService.getWorkPage({ params: ['*'], zoneId: "9f77a69d-5d71-48b4-b759-93616a3d60f6", id: "70b3aa12-ce74-4b22-83c3-f6e1f801adbf", instanceId: "1d59c4d7-5985-4f21-ad3c-1ac66bf14d2b"}); expect(workpage).to.be.an('object'); expect(workpage).to.have.property(ID).that.equals('70b3aa12-ce74-4b22-83c3-f6e1f801adbf'); expect(workpage).to.have.property(TENANT_ID).that.equals('9f77a69d-5d71-48b4-b759-93616a3d60f6'); expect(workpage).to.have.property(INSTANCE_ID).that.equals('1d59c4d7-5985-4f21-ad3c-1ac66bf14d2b'); expect(workpage).to.have.property(CREATED_AT); expect(workpage).to.have.property(DESCRIPTOR_SCHEMA_ID).that.equals(null); expect(workpage).to.have.property(DESCRIPTOR_SCHEMA_VERSION).that.equals('1.0'); expect(workpage).to.have.property(DESCRIPTOR).that.deep.equals({ "sap.ui": { "name": { "newName": "test" } } }); expect(workpage).to.have.property(EDITABLE).that.equals(false); expect(workpage).to.have.property('IsDefault').that.equals(false); expect(workpage).to.have.property('CurrentVersionId').that.equals('1'); expect(workpage).to.have.property('Draft').that.equals(null); expect(workpage).to.have.property('Versions').that.equals(null); }); it('Should return workpage with only required params sent', async () => { // the single test const workpage = await RuntimeService.getWorkPage({ params: [ID, TENANT_ID], zoneId: "9f77a69d-5d71-48b4-b759-93616a3d60f6", id: "70b3aa12-ce74-4b22-83c3-f6e1f801adbf", instanceId: "1d59c4d7-5985-4f21-ad3c-1ac66bf14d2b"}); expect(workpage).to.be.an('object'); expect(workpage).to.have.property('Id').that.equals('70b3aa12-ce74-4b22-83c3-f6e1f801adbf'); expect(workpage).to.have.property('TenantId').that.equals('9f77a69d-5d71-48b4-b759-93616a3d60f6'); expect(workpage).to.not.have.property('InstanceId'); expect(workpage).to.not.have.property('CreatedAt'); expect(workpage).to.not.have.property('DescriptorSchemaId'); expect(workpage).to.not.have.property('DescriptorSchemaVersion'); expect(workpage).to.not.have.property('Descriptor'); expect(workpage).to.not.have.property('Editable'); expect(workpage).to.not.have.property('IsDefault'); expect(workpage).to.not.have.property('CurrentVersionId'); expect(workpage).to.not.have.property('Draft'); expect(workpage).to.not.have.property('Versions'); }); });