test: 新增测试用例:嵌套跨节点表达式
This commit is contained in:
parent
a5cb652468
commit
c5456b3fcb
|
|
@ -1835,4 +1835,90 @@ export default (storeGetter: () => DbStore<EntityDict, TestContext>) => {
|
|||
assert(r1.length === 1, `Deeply nested query failed`);
|
||||
assert(r1[0].system?.platform?.name === 'test_platform', `Nested projection failed`);
|
||||
});
|
||||
|
||||
it('[1.4.1]嵌套跨节点表达式', async () => {
|
||||
const store = storeGetter();
|
||||
const context = new TestContext(store);
|
||||
await context.begin();
|
||||
|
||||
const platformId = v4();
|
||||
await store.operate('platform', {
|
||||
id: v4(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: platformId,
|
||||
name: 'test2'
|
||||
}
|
||||
}, context, {})
|
||||
await store.operate('application', {
|
||||
id: v4(),
|
||||
action: 'create',
|
||||
data: [{
|
||||
id: v4(),
|
||||
name: 'test',
|
||||
description: 'ttttt',
|
||||
type: 'web',
|
||||
system: {
|
||||
id: v4(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: v4(),
|
||||
name: 'systest',
|
||||
folder: 'systest',
|
||||
platformId,
|
||||
}
|
||||
},
|
||||
}, {
|
||||
id: v4(),
|
||||
name: 'test222',
|
||||
description: 'ttttt2',
|
||||
type: 'web',
|
||||
system: {
|
||||
id: v4(),
|
||||
action: 'create',
|
||||
data: {
|
||||
id: v4(),
|
||||
name: 'test2222',
|
||||
folder: 'test2',
|
||||
platformId,
|
||||
}
|
||||
},
|
||||
}]
|
||||
}, context, {});
|
||||
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
// 查询所有的application,过滤条件是application->system.name = application->system->platform.name
|
||||
const apps = await store.select('application', {
|
||||
data: {
|
||||
id: 1,
|
||||
name: 1,
|
||||
system: {
|
||||
id: 1,
|
||||
name: 1,
|
||||
platform: {
|
||||
id: 1,
|
||||
name: 1,
|
||||
}
|
||||
}
|
||||
},
|
||||
filter: {
|
||||
system: {
|
||||
"#id": 'node-1',
|
||||
platform: {
|
||||
$expr: {
|
||||
$eq: [
|
||||
{ "#attr": 'name' },
|
||||
{ "#refId": 'node-1', "#refAttr": 'folder' }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, context, {});
|
||||
|
||||
process.env.NODE_ENV = undefined;
|
||||
assert(apps.length === 1 && apps[0].name === 'test222');
|
||||
await context.commit();
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue