@aiot-toolkit/velasim
Version:
vela for sim
704 lines (650 loc) • 22.9 kB
JavaScript
export default function(global, globalThis, window, $app_exports$){
globalThis = undefined;
global = typeof window === "undefined" ? global.__proto__ : window ;
var createPageHandler = function() {
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/script-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/module-loader.js!./node_modules/babel-loader/lib/index.js?cwd=/home/zhoubingqing/workspace/vela/vela-demo-quality&cacheDirectory&plugins[]=/home/zhoubingqing/workspace/vela/vela-demo-quality/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/zhoubingqing/workspace/vela/vela-demo-quality/node_modules/@aiot-toolkit/packager/babel.config.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=script!./node_modules/@aiot-toolkit/packager/lib/loaders/inject-suite-loader.js?hookName=onReady!./src/Summary/index.ux?uxType=page":
/*!*********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/script-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/module-loader.js!./node_modules/babel-loader/lib/index.js?cwd=/home/zhoubingqing/workspace/vela/vela-demo-quality&cacheDirectory&plugins[]=/home/zhoubingqing/workspace/vela/vela-demo-quality/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/zhoubingqing/workspace/vela/vela-demo-quality/node_modules/@aiot-toolkit/packager/babel.config.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=script!./node_modules/@aiot-toolkit/packager/lib/loaders/inject-suite-loader.js?hookName=onReady!./src/Summary/index.ux?uxType=page ***!
\*********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
module.exports = function __scriptModule__ (module, exports, $app_require$){"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _system = _interopRequireDefault($app_require$("@app-module/system.router"));
var _autocase = __webpack_require__(/*! ../../test/autocase */ "./test/autocase.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function findNextTestPage() {
const list = __webpack_require__.g.loadData('pageNameList');
const item = list.shift();
__webpack_require__.g.saveData('pageNameList', list);
console.log('findNextTestPage', item);
return item;
}
function waitForOk(time = 100) {
return new Promise(resolve => {
setTimeout(resolve, time);
});
}
var _default = {
private: {
pageNameList: [],
pageTestList: [],
shouldTestAll: true,
showCompletedText: false,
isRunningTest: false,
autoTestFlag: true,
back: 'false'
},
onInit() {
this.pageNameList = _autocase.autoCaseList;
if (__webpack_require__.g.loadData) {
__webpack_require__.g.saveData('pageNameList', this.pageNameList);
}
},
onShow() {
this.pageTestList = (__webpack_require__.g.loadData('pageTestList') || []).map(item => {
item.showPageTestDetail = false;
item.tests.forEach(itemCase => {
itemCase.showPageTestErrDetail = false;
});
console.log('onShow', item);
return item;
});
this.shouldTestAll && this.startNextTestPage();
},
onReady() {
if (this.autoTestFlag) {
this.requestTestByClick();
}
this.$options = this._options || this.$options;
if (this.$options._descriptor) {
this.$options._descriptor['back'] = {
access: 'public'
};
}
__webpack_require__.g.CASE_TEST_START = __webpack_require__.g.CASE_TEST_START || 1000;
__webpack_require__.g.CASE_TEST_TIMEOUT = __webpack_require__.g.CASE_TEST_TIMEOUT || 2000;
setTimeout(() => {
if (this.back !== 'false') {
console.info('没有关联测试用例,直接返回到之前的页面');
}
}, __webpack_require__.g.CASE_TEST_START);
},
requestTestByClick() {
setTimeout(() => {
this.$emitElement('click', null, 'btnTest');
console.info(`AutoTesting: Trigger click on test button`);
}, 1e3);
},
requestSaveByClick() {
setTimeout(() => {
this.$emitElement('click', null, 'btnSaveTest');
console.info(`AutoTesting: Trigger click on save button`);
}, 3e3);
},
restartTestProcess() {
if (!this.isRunningTest) {
this.isRunningTest = true;
__webpack_require__.g.saveData('pageNameList', this.pageNameList);
__webpack_require__.g.saveData('pageTestLsit', []);
this.pageTestList = [];
this.showCompletedText = false;
this.shouldTestAll = true;
this.startNextTestPage();
}
},
async startNextTestPage() {
const pageItem = findNextTestPage();
if (pageItem) {
console.info(`下个测试用例:${pageItem.title}:${pageItem.name}`);
await waitForOk(1000);
console.info(`开始测试页面:${pageItem.title}:${pageItem.name}`);
_system.default.push({
uri: pageItem.name,
params: pageItem.params
});
} else {
console.info(`测试用例表执行完毕`);
this.isRunningTest = false;
this.showCompletedText = true;
this.shouldTestAll = false;
this.saveTestResultData();
}
},
gotoPage(path, params) {
params = Object.assign({
back: 'false'
}, params);
_system.default.push({
uri: path,
params
});
},
togglePageTestDetailStatus($item) {
$item.showPageTestDetail = !$item.showPageTestDetail;
},
togglePageErrStackStatus($item) {
$item.showPageTestErrDetail = !$item.showPageTestErrDetail;
},
collectAppTestData() {
const pageTestList = this.pageTestList;
const appTestData = {
summary: {
suites: 0,
tests: 0,
passes: 0,
failures: 0,
pending: 0
},
suites: pageTestList
};
pageTestList.forEach(pageTestItem => {
appTestData.summary.suites += pageTestItem.stats.suites;
appTestData.summary.tests += pageTestItem.stats.tests;
appTestData.summary.passes += pageTestItem.stats.passes;
appTestData.summary.failures += pageTestItem.stats.failures;
appTestData.summary.pending += pageTestItem.stats.pending;
});
return appTestData;
},
saveTestResultData() {
const file = $app_require$('@app-module/system.file');
const appTestData = this.collectAppTestData();
const that = this;
file.writeText({
uri: 'internal://files/latest.json',
text: JSON.stringify(appTestData),
success: res => {
console.info(`保存测试结果成功:${JSON.stringify(res)}`);
_system.default.back();
},
fail: err => {
console.info(`保存测试结果失败:${JSON.stringify(err)}`);
}
});
}
};
exports.default = _default;
const moduleOwn = exports.default || module.exports;
const accessors = ['public', 'protected', 'private'];
if (moduleOwn.data && accessors.some(function (acc) {
return moduleOwn[acc];
})) {
throw new Error('页面VM对象中的属性data不可与"' + accessors.join(',') + '"同时存在,请使用private替换data名称');
} else if (!moduleOwn.data) {
moduleOwn.data = {};
moduleOwn._descriptor = {};
accessors.forEach(function (acc) {
const accType = typeof moduleOwn[acc];
if (accType === 'object') {
moduleOwn.data = Object.assign(moduleOwn.data, moduleOwn[acc]);
for (const name in moduleOwn[acc]) {
moduleOwn._descriptor[name] = {
access: acc
};
}
} else if (accType === 'function') {
console.warn('页面VM对象中的属性' + acc + '的值不能是函数,请使用对象');
}
});
}}
/***/ }),
/***/ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/style-loader.js?index=0&type=style!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=style!./src/Summary/index.ux?uxType=page":
/*!*********************************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/style-loader.js?index=0&type=style!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=style!./src/Summary/index.ux?uxType=page ***!
\*********************************************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = [
[
[
[
0,
"page-summary-root"
]
],
{
"backgroundColor": "#fbf9fe",
"flex": 1,
"flexDirection": "column"
}
],
[
[
[
0,
"page-summary-desc"
]
],
{
"paddingTop": "20px",
"paddingRight": "20px",
"paddingBottom": "20px",
"paddingLeft": "20px",
"justifyContent": "center",
"backgroundColor": "#ffe4c4"
}
],
[
[
[
0,
"page-item"
]
],
{
"flexDirection": "column"
}
],
[
[
[
0,
"page-item-summary"
]
],
{
"paddingTop": "20px",
"paddingRight": "20px",
"paddingBottom": "20px",
"paddingLeft": "20px",
"backgroundColor": "#efebc6"
}
],
[
[
[
0,
"page-item-summary-num-name"
]
],
{
"fontWeight": "bold",
"marginRight": "40px"
}
],
[
[
[
0,
"page-item-summary-num-total"
]
],
{
"marginRight": "20px"
}
],
[
[
[
0,
"page-item-summary-num-pass"
]
],
{
"marginRight": "20px",
"color": "#008000"
}
],
[
[
[
0,
"page-item-summary-num-fail"
]
],
{
"marginRight": "20px",
"color": "#FF0000"
}
],
[
[
[
0,
"page-item-caselist"
]
],
{
"flexDirection": "column",
"marginTop": "10px"
}
],
[
[
[
0,
"case-item"
]
],
{
"flexDirection": "column",
"paddingTop": "10px",
"paddingRight": "50px",
"paddingBottom": "10px",
"paddingLeft": "50px",
"marginBottom": "5px"
}
],
[
[
[
0,
"case-item-pass"
]
],
{
"backgroundColor": "#008000"
}
],
[
[
[
0,
"case-item-fail"
]
],
{
"backgroundColor": "#FF0000"
}
]
]
/***/ }),
/***/ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/template-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=template!./src/Summary/index.ux?uxType=page&":
/*!*********************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/template-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=template!./src/Summary/index.ux?uxType=page& ***!
\*********************************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = function (vm) {
const _vm_ = vm || this
return aiot.__ce__("div", {
"classList": [
"page-summary-root"
]
}, [
aiot.__ce__("div", {
"style": {
"flexDirection": "column"
}
}, [
aiot.__ce__("div", {
"id": "btnTest",
"classList": [
"page-summary-desc"
],
"events": {
"click": function (evt) {_vm_.restartTestProcess(evt)}
}
}, [
aiot.__ce__("text", {
"value": "点击重新测试"
})
]),
aiot.__cf__({
exp: function () {return _vm_.pageTestList}
},
function ($idx, $item) {
return aiot.__ce__("div", {
"classList": [
"page-item"
]
}, [
aiot.__ce__("div", {
"classList": [
"page-item-summary"
]
}, [
aiot.__ce__("text", {
"classList": [
"page-item-summary-num-name"
]
}, [
aiot.__ce__("span", {
"value": function () {return $item.stats.title}
})
]),
aiot.__ce__("text", {
"events": {
"click": function (evt) { return _vm_.togglePageTestDetailStatus($item,evt)}
}
}, [
aiot.__ce__("span", {
"classList": [
"page-item-summary-num-total"
],
"value": function () {return '' + '结果:' + ($item.stats.tests) + ':'}
}),
aiot.__ce__("span", {
"classList": [
"page-item-summary-num-pass"
],
"value": function () {return '' + '(' + ($item.stats.passes) + ':'}
}),
aiot.__ce__("span", {
"classList": [
"page-item-summary-num-fail"
],
"value": function () {return '' + ($item.stats.failures) + ')'}
})
])
]),
aiot.__ce__("div", {
"show": function () {return !!$item.showPageTestDetail},
"classList": [
"page-item-caselist"
]
}, [
aiot.__cf__({
exp: function () {return $item.tests}
},
function ($idx, $item) {
return aiot.__ce__("div", {
"classList": function () {return ['case-item', !$item.err.message?'case-item-pass':'case-item-fail']}
}, [
aiot.__ce__("text", {
"classList": [
"case-item-title"
],
"events": {
"click": function (evt) { return _vm_.togglePageErrStackStatus($item,evt)}
},
"value": function () {return $item.title}
}),
aiot.__ci__({
shown: function () {return $item.err.message}
},
function () {
return aiot.__ce__("text", {
"show": function () {return !!$item.showPageTestErrDetail},
"value": function () {return $item.err.stack}
})})
])})
])
])}),
aiot.__ce__("div", {
"show": function () {return _vm_.showCompletedText},
"classList": [
"page-summary-desc"
],
"style": {
"backgroundColor": "#d9d7d6"
}
}, [
aiot.__ce__("text", {
"value": "所有测试已结束"
})
]),
aiot.__ce__("div", {
"classList": [
"page-summary-desc"
],
"style": {
"backgroundColor": "#d9d7d6",
"marginTop": "60px"
}
}, [
aiot.__ce__("text", {
"value": "测试的页面列表"
})
]),
aiot.__cf__({
exp: function () {return _vm_.pageNameList}
},
function ($idx, $item) {
return aiot.__ce__("div", {
"classList": [
"page-item"
]
}, [
aiot.__ce__("div", {
"classList": [
"page-item-summary"
],
"events": {
"click": function (evt) { return _vm_.gotoPage($item.name,$item.params,evt)}
}
}, [
aiot.__ce__("text", {
"value": function () {return '' + ($item.title) + ' : ' + ($item.name)}
})
])
])}),
aiot.__ce__("div", {
"id": "btnSaveTest",
"classList": [
"page-summary-desc"
],
"events": {
"click": function (evt) {_vm_.saveTestResultData(evt)}
},
"style": {
"backgroundColor": "#d9d7d6",
"marginTop": "60px"
}
}, [
aiot.__ce__("text", {
"value": "保存测试结果的数据"
})
])
])
])
}
/***/ }),
/***/ "./src/Summary/index.ux?uxType=page":
/*!******************************************!*\
!*** ./src/Summary/index.ux?uxType=page ***!
\******************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var $app_style$ = __webpack_require__(/*! !../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/style-loader.js?index=0&type=style!../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=style!./index.ux?uxType=page */ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/style-loader.js?index=0&type=style!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=style!./src/Summary/index.ux?uxType=page")
var $app_script$ = __webpack_require__(/*! !../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/script-loader.js!../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/module-loader.js!../../node_modules/babel-loader/lib/index.js?cwd=/home/zhoubingqing/workspace/vela/vela-demo-quality&cacheDirectory&plugins[]=/home/zhoubingqing/workspace/vela/vela-demo-quality/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/zhoubingqing/workspace/vela/vela-demo-quality/node_modules/@aiot-toolkit/packager/babel.config.js!../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=script!../../node_modules/@aiot-toolkit/packager/lib/loaders/inject-suite-loader.js?hookName=onReady!./index.ux?uxType=page */ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/script-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/module-loader.js!./node_modules/babel-loader/lib/index.js?cwd=/home/zhoubingqing/workspace/vela/vela-demo-quality&cacheDirectory&plugins[]=/home/zhoubingqing/workspace/vela/vela-demo-quality/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/zhoubingqing/workspace/vela/vela-demo-quality/node_modules/@aiot-toolkit/packager/babel.config.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=script!./node_modules/@aiot-toolkit/packager/lib/loaders/inject-suite-loader.js?hookName=onReady!./src/Summary/index.ux?uxType=page")
var $app_template$ = __webpack_require__(/*! !../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/template-loader.js!../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=template!./index.ux?uxType=page& */ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/template-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=template!./src/Summary/index.ux?uxType=page&")
$app_script$({}, $app_exports$, $app_require$);
$app_exports$.default.template = $app_template$;
$app_exports$.default.style = $app_style$;
module.exports = $app_exports$.default;
/***/ }),
/***/ "./test/autocase.js":
/*!**************************!*\
!*** ./test/autocase.js ***!
\**************************/
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.autoCaseList = void 0;
const autoCaseList = [{
title: 'text组件',
name: 'widgets/text/origin'
}, {
title: 'progress组件',
name: 'widgets/progress/origin'
}, {
title: 'switch组件',
name: 'widgets/switch/origin'
}, {
title: 'image组件',
name: 'widgets/image/origin'
}, {
title: 'div组件:flex',
name: 'widgets/div/flex'
}, {
title: 'stack组件',
name: 'widgets/stack/origin'
}, {
title: 'list组件',
name: 'widgets/list/origin'
}, {
title: 'swiper组件',
name: 'widgets/swiper/origin'
}, {
title: 'marquee组件',
name: 'widgets/marquee/origin'
}, {
title: 'chart组件',
name: 'widgets/chart/origin'
}, {
title: 'input组件',
name: 'widgets/input/origin'
}, {
title: 'picker组件',
name: 'widgets/picker/origin'
}, {
title: 'slider组件',
name: 'widgets/slider/origin'
}];
exports.autoCaseList = autoCaseList;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/global */
/******/ (() => {
/******/ __webpack_require__.g = (function() {
/******/ if (typeof globalThis === 'object') return globalThis;
/******/ try {
/******/ return this || new Function('return this')();
/******/ } catch (e) {
/******/ if (typeof window === 'object') return window;
/******/ }
/******/ })();
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __webpack_require__("./src/Summary/index.ux?uxType=page");
/******/
/******/ })()
;
};
return createPageHandler();
};