Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/merging-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ on:
branches: [master]

jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: npm i
- run: npm test

e2e-tests:
uses: ./.github/workflows/e2e-test.yml
with:
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/CruGlobal/plugin_ABDesigner/pr-merge-release.yml?logo=github&label=Build%20%26%20Test)](https://github.com/CruGlobal/plugin_ABDesigner/actions/workflows/pr-merge-release.yml)
[![GitHub tag (with filter)](https://img.shields.io/github/v/tag/CruGlobal/plugin_ABDesigner?logo=github&label=Latest%20Version)
](https://github.com/CruGlobal/plugin_ABDesigner/releases)
<p align="center">
<a href="https://github.com/CruGlobal/plugin_ABDesigner/actions/workflows/merging-rules.yml">
<img src="https://img.shields.io/github/actions/workflow/status/CruGlobal/plugin_ABDesigner/merging-rules.yml?branch=master&logo=github&label=Tests">
</a>
<a href="https://github.com/CruGlobal/plugin_ABDesigner/actions/workflows/pr-merge-release.yml">
<img src="https://img.shields.io/github/actions/workflow/status/CruGlobal/plugin_ABDesigner/pr-merge-release.yml?logo=github&
label=Build%20%26%20Test">
</a>
<a href="https://github.com/CruGlobal/plugin_ABDesigner/releases">
<img src="https://img.shields.io/github/v/tag/CruGlobal/plugin_ABDesigner?logo=github&label=Latest%20Version">
</a>
</p>


# AppBuilder Designer
A plugin for the AppBuilder platform that enables creating AB resources.
Expand Down
109 changes: 102 additions & 7 deletions test/_mock/AB.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
import { EventEmitter } from "events";

function noopProxy() {
return new Proxy(
function () { },
{
get: () => () => { },
apply: () => { },
}
);
}

class SortPopup extends EventEmitter {
constructor(/* ibase */) {
super();
}

init() {
return Promise.resolve();
}
}

export default class AB {
constructor(definitions) {
this._definitions = definitions || {};
this.applications = {};

this.custom = {
editunitlist: {
Expand All @@ -12,12 +33,27 @@ export default class AB {

this.Class = {
ABFieldManager: {
allFields: () => {}
}
allFields: () => { },
fieldByKey: () => undefined,
},
ABProcessTaskManager: {
allTasks: () => [
{
defaults: () => ({ key: "TimerStartEvent" }),
},
],
},
SortPopup,
};
this.ClassUI = ClassUI;
this.Config = new Config();
this.Multilingual = Multilingual;
this.UISettings = {
config: () => ({}),
};
this.Account = {
isSystemDesigner: () => false,
};
}

Label() {
Expand All @@ -27,18 +63,77 @@ export default class AB {
getPluginAPI() {
return { AB: this };
}

filterComplexNew(/* id */) {
return noopProxy();
}

datacollectionByID() {
return undefined;
}

applicationByID(id) {
return this.applications[id];
}

objectByID() {
return undefined;
}

queryByID() {
return undefined;
}

processByID() {
return undefined;
}

processNew(values) {
return Promise.resolve({
save: () => Promise.resolve(),
...values,
});
}

datacollectionNew(values) {
return {
init: () => { },
isValid: () => ({ fail: () => false }),
save: () => Promise.resolve(values),
filterCondition: () => { },
reloadData: () => { },
fromValues: () => { },
datasource: null,
...values,
};
}

plugins() {
return [];
}

jobID() {
return "test-job-id";
}
}

class ClassUI extends EventEmitter {
constructor(definitions) {
constructor(base, ids) {
super();
this.ids = {};
if (typeof definitions == "string") {
this.ids.component = definitions;
} else if (definitions) {
this.ids = definitions;
if (typeof base == "string") {
this.ids.component = base;
}
if (ids && typeof ids == "object") {
Object.keys(ids).forEach((k) => {
this.ids[k] = `${base}_${ids[k] || k}`;
});
} else if (typeof base == "object" && base !== null && !ids) {
this.ids = base;
}
}

static CYPRESS_REF() { }
}

class Config {
Expand Down
28 changes: 28 additions & 0 deletions test/_mock/uiWorkTestHelpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sinon from "sinon";

export function listComponentStub(base) {
return {
idBase: base,
ids: { component: base },
ui: sinon.stub(),
init: sinon.stub().resolves(),
on: sinon.stub(),
dataLoad: sinon.stub(),
ready: sinon.stub(),
select: sinon.stub(),
selectedItem: sinon.stub(),
warningsRefresh: sinon.stub(),
};
}

export function registerApplication(ab, application) {
if (!application.id) {
application.id = `mock-app-${Date.now()}-${Math.random()}`;
}
ab.applications[application.id] = application;
return application;
}

export function registerApplicationForTarget(target, application) {
return registerApplication(target.AB, application);
}
16 changes: 16 additions & 0 deletions test/_mock/webix.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,20 @@ export default class webix {
static confirm() {}
static extend() {}
static ui() {}
static ProgressBar = {};
static DataCollection = class {
constructor() {
this.data = { attachEvent: () => { } };
}

sort() { }

count() {
return 0;
}

remove() { }

parse() { }
};
}
1 change: 1 addition & 0 deletions test/_mock/webix_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function webixElement(id) {
setValues: () => {},
show: () => {},
showProgress: () => {},
unselectAll: () => { },
unblockEvent: () => {},
validate: () => {},
};
Expand Down
37 changes: 37 additions & 0 deletions test/_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,43 @@ Module._load = function (request, parent, isMain) {
);
};
}
if (request.includes("properties/PropertyManager")) {
const propertyMgrStub = {
fields: () => [],
processElements: () => [],
views: () => [],
mobileViews: () => [],
};
const factory = () => propertyMgrStub;
factory.default = factory;
return factory;
}
if (request.includes("properties/views/ABViewCSVImporter")) {
const factory = () => {
return class MockCSVImporterProperties {
constructor() {
this.component = {
ui: () => ({}),
init: () => Promise.resolve(),
detatch: () => { },
onShow: () => { },
};
}
ui() {
return {};
}
init() {
return Promise.resolve();
}

toSettings() {
return {};
}
};
};
factory.default = factory;
return factory;
}
if (request.includes("ABViewRuleListFormRecordRules")) {
const popupStub = {
init() { },
Expand Down
Loading
Loading