all tests passing again after refactor for serving UI
This commit is contained in:
parent
5d0d14f16a
commit
7bc6dfbdd3
|
@ -502,6 +502,12 @@
|
||||||
"behaviourSource": "main",
|
"behaviourSource": "main",
|
||||||
"behaviourName": "createNewUser",
|
"behaviourName": "createNewUser",
|
||||||
"initialOptions": {}
|
"initialOptions": {}
|
||||||
|
},
|
||||||
|
"set_default_version": {
|
||||||
|
"name": "set_default_version",
|
||||||
|
"behaviourSource": "main",
|
||||||
|
"behaviourName": "setDefaultVersion",
|
||||||
|
"initialOptions": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"triggers": [
|
"triggers": [
|
||||||
|
|
|
@ -86,6 +86,22 @@ module.exports = (context) => {
|
||||||
authUser.accessLevels = [instance.version.defaultAccessLevel];
|
authUser.accessLevels = [instance.version.defaultAccessLevel];
|
||||||
|
|
||||||
await instanceApis.authApi.createUser(authUser);
|
await instanceApis.authApi.createUser(authUser);
|
||||||
|
},
|
||||||
|
|
||||||
|
setDefaultVersion : async ({apis, version}) => {
|
||||||
|
const appKey = $(version.key, [
|
||||||
|
splitKey,
|
||||||
|
take(2),
|
||||||
|
joinKey
|
||||||
|
]);
|
||||||
|
|
||||||
|
const application = await apis.recordApi.load(appKey);
|
||||||
|
|
||||||
|
if(application.defaultVersion.key) return;
|
||||||
|
|
||||||
|
application.defaultVersion = version;
|
||||||
|
|
||||||
|
await apis.recordApi.save(application);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1 +1,86 @@
|
||||||
{"hierarchy":{"name":"root","type":"root","children":[{"name":"customer","type":"record","fields":[{"name":"name","type":"string","typeOptions":{"maxLength":1000,"values":null,"allowDeclaredValuesOnly":false},"label":"name","getInitialValue":"default","getUndefinedValue":"default"}],"children":[{"name":"invoiceyooo","type":"record","fields":[{"name":"amount","type":"number","typeOptions":{"minValue":99999999999,"maxValue":99999999999,"decimalPlaces":2},"label":"amount","getInitialValue":"default","getUndefinedValue":"default"}],"children":[],"validationRules":[],"nodeId":2,"indexes":[],"allidsShardFactor":1,"collectionName":"invoices","isSingle":false}],"validationRules":[],"nodeId":1,"indexes":[],"allidsShardFactor":64,"collectionName":"customers","isSingle":false}],"pathMaps":[],"indexes":[],"nodeId":0},"triggers":[{"actionName":"output_to_file","eventName":"authApi:createUser:onComplete","optionsCreator":"return { filename:'tempaccess' + context.user.name, content:context.result.tempCode };","condition":"!context.password"},{"actionName":"output_to_file","eventName":"authApi:createTemporaryAccess:onComplete","optionsCreator":"return { filename:'tempaccess' + context.userName, content:context.result };","condition":""}],"actions":{"output_to_file":[{"name":"output_to_file","behaviourSource":"main","behaviourName":"outputToFile","initialOptions":{}}]}}
|
{
|
||||||
|
"hierarchy": {
|
||||||
|
"name": "root",
|
||||||
|
"type": "root",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "customer",
|
||||||
|
"type": "record",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"type": "string",
|
||||||
|
"typeOptions": {
|
||||||
|
"maxLength": 1000,
|
||||||
|
"values": null,
|
||||||
|
"allowDeclaredValuesOnly": false
|
||||||
|
},
|
||||||
|
"label": "name",
|
||||||
|
"getInitialValue": "default",
|
||||||
|
"getUndefinedValue": "default"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "invoiceyooo",
|
||||||
|
"type": "record",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "amount",
|
||||||
|
"type": "number",
|
||||||
|
"typeOptions": {
|
||||||
|
"minValue": 99999999999,
|
||||||
|
"maxValue": 99999999999,
|
||||||
|
"decimalPlaces": 2
|
||||||
|
},
|
||||||
|
"label": "amount",
|
||||||
|
"getInitialValue": "default",
|
||||||
|
"getUndefinedValue": "default"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"children": [],
|
||||||
|
"validationRules": [],
|
||||||
|
"nodeId": 2,
|
||||||
|
"indexes": [],
|
||||||
|
"allidsShardFactor": 1,
|
||||||
|
"collectionName": "invoices",
|
||||||
|
"isSingle": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"validationRules": [],
|
||||||
|
"nodeId": 1,
|
||||||
|
"indexes": [],
|
||||||
|
"allidsShardFactor": 64,
|
||||||
|
"collectionName": "customers",
|
||||||
|
"isSingle": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pathMaps": [],
|
||||||
|
"indexes": [],
|
||||||
|
"nodeId": 0
|
||||||
|
},
|
||||||
|
"triggers": [
|
||||||
|
{
|
||||||
|
"actionName": "output_to_file",
|
||||||
|
"eventName": "authApi:createUser:onComplete",
|
||||||
|
"optionsCreator": "return { filename:'tempaccess' + context.user.name, content:context.result.tempCode };",
|
||||||
|
"condition": "!context.password"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"actionName": "output_to_file",
|
||||||
|
"eventName": "authApi:createTemporaryAccess:onComplete",
|
||||||
|
"optionsCreator": "return { filename:'tempaccess' + context.userName, content:context.result };",
|
||||||
|
"condition": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actions": {
|
||||||
|
"output_to_file":
|
||||||
|
{
|
||||||
|
"name": "output_to_file",
|
||||||
|
"behaviourSource": "main",
|
||||||
|
"behaviourName": "outputToFile",
|
||||||
|
"initialOptions": {}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
|
@ -2,8 +2,13 @@ const fs = require("fs");
|
||||||
|
|
||||||
module.exports = (config) => ({
|
module.exports = (config) => ({
|
||||||
main: {
|
main: {
|
||||||
outputToFile : ({filename, content}) => {
|
outputToFile : async ({filename, content}) => {
|
||||||
fs.writeFile(`./tests/.data/${filename}`, content, {encoding:"utf8"});
|
await new Promise((resolve,reject) => {
|
||||||
|
fs.writeFile(`./tests/.data/${filename}`, content, {encoding:"utf8"}, err => {
|
||||||
|
if(err) reject();
|
||||||
|
else resolve(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -17,8 +17,8 @@
|
||||||
"budibase-core": "file:../core/dist",
|
"budibase-core": "file:../core/dist",
|
||||||
"koa": "^2.7.0",
|
"koa": "^2.7.0",
|
||||||
"koa-body": "^4.1.0",
|
"koa-body": "^4.1.0",
|
||||||
"koa-session": "^5.12.0",
|
|
||||||
"koa-send": "^5.0.0",
|
"koa-send": "^5.0.0",
|
||||||
|
"koa-session": "^5.12.0",
|
||||||
"koa-static": "^5.0.0",
|
"koa-static": "^5.0.0",
|
||||||
"ncp": "^2.0.0",
|
"ncp": "^2.0.0",
|
||||||
"rimraf": "^2.6.3",
|
"rimraf": "^2.6.3",
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
const statusCodes = require("../utilities/statusCodes");
|
const statusCodes = require("../utilities/statusCodes");
|
||||||
const constructHierarchy = require("../utilities/constructHierarchy");
|
const constructHierarchy = require("../utilities/constructHierarchy");
|
||||||
const { readFile } = require("../utilities/fsawait");
|
const { readFile } = require("../utilities/fsawait");
|
||||||
const {getRecordApi, getAuthApi} = require("budibase-core");
|
const { hierarchy } = require("budibase-core");
|
||||||
|
const { take } = require("lodash/fp");
|
||||||
const masterAppDefinition = constructHierarchy(
|
const masterAppDefinition = constructHierarchy(
|
||||||
require("../appPackages/master/appDefinition.json"));
|
require("../appPackages/master/appDefinition.json"));
|
||||||
const {getApisWithFullAccess} = require("../utilities/budibaseApi");
|
const {getApisWithFullAccess} = require("../utilities/budibaseApi");
|
||||||
|
@ -57,6 +58,15 @@ module.exports = (app) => {
|
||||||
.set("cookie", app.credentials.masterOwner.cookie)
|
.set("cookie", app.credentials.masterOwner.cookie)
|
||||||
.expect(statusCodes.OK);
|
.expect(statusCodes.OK);
|
||||||
|
|
||||||
|
const savedAppResponse = await app.get(`/_master/api/record/${newAppKey}`)
|
||||||
|
.set("cookie", app.credentials.masterOwner.cookie);
|
||||||
|
|
||||||
|
const savedApp = savedAppResponse.body;
|
||||||
|
savedApp.defaultVersion = version1
|
||||||
|
await app.post(`/_master/api/record/${newAppKey}`, savedApp)
|
||||||
|
.set("cookie", app.credentials.masterOwner.cookie)
|
||||||
|
.expect(statusCodes.OK);
|
||||||
|
|
||||||
app.apps.testApp1.version1 = version1;
|
app.apps.testApp1.version1 = version1;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@ const {
|
||||||
const getDatastore = require("./datastore");
|
const getDatastore = require("./datastore");
|
||||||
const getDatabaseManager = require("./databaseManager");
|
const getDatabaseManager = require("./databaseManager");
|
||||||
const {$, splitKey} = require("budibase-core").common;
|
const {$, splitKey} = require("budibase-core").common;
|
||||||
const { keyBy, last } = require("lodash/fp");
|
const { keyBy, last, filter } = require("lodash/fp");
|
||||||
const {
|
const {
|
||||||
masterAppPackage,
|
masterAppPackage,
|
||||||
applictionVersionPackage,
|
applictionVersionPackage,
|
||||||
|
@ -30,10 +30,13 @@ module.exports = async (context) => {
|
||||||
const bb = await getMasterApisWithFullAccess(context);
|
const bb = await getMasterApisWithFullAccess(context);
|
||||||
|
|
||||||
let applications;
|
let applications;
|
||||||
const loadApplications = async () =>
|
const loadApplications = async () => {
|
||||||
applications = $(await bb.indexApi.listItems("/all_applications"), [
|
const apps = await bb.indexApi.listItems("/all_applications");
|
||||||
|
applications = $(apps, [
|
||||||
|
filter(a => !!a.defaultVersion.key),
|
||||||
keyBy("name")
|
keyBy("name")
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
await loadApplications();
|
await loadApplications();
|
||||||
|
|
||||||
const getInstanceDatastore = (instanceDatastoreConfig) =>
|
const getInstanceDatastore = (instanceDatastoreConfig) =>
|
||||||
|
|
Loading…
Reference in New Issue