@cubejs-backend/testing 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,10 +10,40 @@ cube(`Orders`, {
|
|
|
10
10
|
UNION ALL
|
|
11
11
|
select 5 as id, 600 as amount, 'shipped' status, '2024-01-05'::timestamptz created_at
|
|
12
12
|
`,
|
|
13
|
+
joins: {
|
|
14
|
+
OrderItems: {
|
|
15
|
+
relationship: 'one_to_many',
|
|
16
|
+
sql: `${CUBE.id} = ${OrderItems.order_id}`
|
|
17
|
+
},
|
|
18
|
+
},
|
|
13
19
|
measures: {
|
|
14
20
|
count: {
|
|
15
21
|
type: `count`,
|
|
16
22
|
},
|
|
23
|
+
orderCount: {
|
|
24
|
+
type: `count_distinct`,
|
|
25
|
+
sql: `CASE WHEN ${Orders.status} = 'shipped' THEN ${CUBE}.id END`
|
|
26
|
+
},
|
|
27
|
+
netCollectionCompleted: {
|
|
28
|
+
type: `sum`,
|
|
29
|
+
sql: `CASE WHEN ${Orders.status} = 'shipped' THEN ${CUBE}.amount END`
|
|
30
|
+
},
|
|
31
|
+
arpu: {
|
|
32
|
+
type: `number`,
|
|
33
|
+
sql: `1.0 * ${netCollectionCompleted} / ${orderCount}`
|
|
34
|
+
},
|
|
35
|
+
refundRate: {
|
|
36
|
+
type: `number`,
|
|
37
|
+
sql: `1.0 * ${refundOrdersCount} / ${overallOrders}`
|
|
38
|
+
},
|
|
39
|
+
refundOrdersCount: {
|
|
40
|
+
type: `count_distinct`,
|
|
41
|
+
sql: `CASE WHEN ${Orders.status} = 'refunded' THEN ${CUBE}.id END`
|
|
42
|
+
},
|
|
43
|
+
overallOrders: {
|
|
44
|
+
type: `count_distinct`,
|
|
45
|
+
sql: `CASE WHEN ${Orders.status} != 'cancelled' THEN ${CUBE}.id END`
|
|
46
|
+
},
|
|
17
47
|
totalAmount: {
|
|
18
48
|
sql: `amount`,
|
|
19
49
|
type: `sum`,
|
|
@@ -96,6 +126,57 @@ cube(`Orders`, {
|
|
|
96
126
|
},
|
|
97
127
|
});
|
|
98
128
|
|
|
129
|
+
cube(`OrderItems`, {
|
|
130
|
+
sql: `
|
|
131
|
+
select 1 as id, 1 as order_id, 'Phone' AS name, 'Electronics' AS type, '2024-01-01'::timestamptz created_at
|
|
132
|
+
UNION ALL
|
|
133
|
+
select 2 as id, 2 as order_id, 'Keyboard' AS name, 'Electronics' AS type, '2024-01-02'::timestamptz created_at
|
|
134
|
+
UNION ALL
|
|
135
|
+
select 3 as id, 3 as order_id, 'Glass' AS name, 'Home' AS type, '2024-01-03'::timestamptz created_at
|
|
136
|
+
UNION ALL
|
|
137
|
+
select 4 as id, 4 as order_id, 'Lamp' AS name, 'Home' AS type, '2024-01-04'::timestamptz created_at
|
|
138
|
+
UNION ALL
|
|
139
|
+
select 5 as id, 5 as order_id, 'Pen' AS name, 'Office' AS type, '2024-01-05'::timestamptz created_at
|
|
140
|
+
`,
|
|
141
|
+
measures: {
|
|
142
|
+
count: {
|
|
143
|
+
type: `count`,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
dimensions: {
|
|
147
|
+
id: {
|
|
148
|
+
sql: `id`,
|
|
149
|
+
type: `number`,
|
|
150
|
+
primaryKey: true,
|
|
151
|
+
public: true,
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
order_id: {
|
|
155
|
+
sql: `order_id`,
|
|
156
|
+
type: `number`,
|
|
157
|
+
public: true,
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
name: {
|
|
161
|
+
sql: `name`,
|
|
162
|
+
type: `string`,
|
|
163
|
+
public: true,
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
type: {
|
|
167
|
+
sql: `type`,
|
|
168
|
+
type: `string`,
|
|
169
|
+
public: true,
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
createdAt: {
|
|
173
|
+
sql: `created_at`,
|
|
174
|
+
type: `time`,
|
|
175
|
+
public: true,
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
|
|
99
180
|
view(`OrdersView`, {
|
|
100
181
|
cubes: [{
|
|
101
182
|
joinPath: Orders,
|
|
@@ -103,3 +184,17 @@ view(`OrdersView`, {
|
|
|
103
184
|
excludes: [`toRemove`]
|
|
104
185
|
}]
|
|
105
186
|
});
|
|
187
|
+
|
|
188
|
+
view(`OrdersItemsPrefixView`, {
|
|
189
|
+
cubes: [{
|
|
190
|
+
joinPath: Orders,
|
|
191
|
+
includes: `*`,
|
|
192
|
+
excludes: [`toRemove`],
|
|
193
|
+
prefix: true
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
joinPath: Orders.OrderItems,
|
|
197
|
+
includes: `*`,
|
|
198
|
+
prefix: true
|
|
199
|
+
}]
|
|
200
|
+
});
|
|
@@ -22,6 +22,27 @@ module.exports = {
|
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
if (user === 'manager') {
|
|
26
|
+
if (password && password !== 'manager_password') {
|
|
27
|
+
throw new Error(`Password doesn't match for ${user}`);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
password,
|
|
31
|
+
superuser: false,
|
|
32
|
+
securityContext: {
|
|
33
|
+
auth: {
|
|
34
|
+
username: 'manager',
|
|
35
|
+
userAttributes: {
|
|
36
|
+
region: 'CA',
|
|
37
|
+
city: 'Fresno',
|
|
38
|
+
canHaveAdmin: false,
|
|
39
|
+
minDefaultId: 10000,
|
|
40
|
+
},
|
|
41
|
+
roles: ['manager'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
25
46
|
throw new Error(`User "${user}" doesn't exist`);
|
|
26
47
|
}
|
|
27
48
|
};
|
|
@@ -55,7 +55,10 @@ cube('line_items', {
|
|
|
55
55
|
// This is to test dynamic values based on security context
|
|
56
56
|
values: [`${security_context.auth?.userAttributes?.minDefaultId || 20000}`],
|
|
57
57
|
}]
|
|
58
|
-
}
|
|
58
|
+
},
|
|
59
|
+
memberLevel: {
|
|
60
|
+
excludes: ['count', 'price', 'price_dim'],
|
|
61
|
+
},
|
|
59
62
|
},
|
|
60
63
|
{
|
|
61
64
|
role: 'admin',
|
|
@@ -68,6 +71,24 @@ cube('line_items', {
|
|
|
68
71
|
// The "allowAll" flag should negate the default `id` filter
|
|
69
72
|
allowAll: true,
|
|
70
73
|
},
|
|
74
|
+
memberLevel: {
|
|
75
|
+
excludes: ['price_dim'],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
role: 'manager',
|
|
80
|
+
conditions: [
|
|
81
|
+
{
|
|
82
|
+
if: security_context.auth?.userAttributes?.region === 'CA',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
// This condition should not match the one defined in the "manager" mock context
|
|
86
|
+
if: security_context.auth?.userAttributes?.region === 'San Francisco',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
rowLevel: {
|
|
90
|
+
allowAll: true,
|
|
91
|
+
},
|
|
71
92
|
memberLevel: {
|
|
72
93
|
excludes: ['created_at'],
|
|
73
94
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubejs-backend/testing",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "Cube.js e2e tests",
|
|
5
5
|
"author": "Cube Dev, Inc.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"smoke:postgres": "jest --verbose -i dist/test/smoke-postgres.test.js",
|
|
74
74
|
"smoke:redshift": "jest --verbose -i dist/test/smoke-redshift.test.js",
|
|
75
75
|
"smoke:redshift:snapshot": "jest --verbose --updateSnapshot -i dist/test/smoke-redshift.test.js",
|
|
76
|
-
"smoke:rbac": "TZ=UTC jest --verbose
|
|
76
|
+
"smoke:rbac": "TZ=UTC jest --verbose -i dist/test/smoke-rbac.test.js",
|
|
77
77
|
"smoke:cubesql": "TZ=UTC jest --verbose --forceExit -i dist/test/smoke-cubesql.test.js",
|
|
78
78
|
"smoke:cubesql:snapshot": "TZ=UTC jest --verbose --forceExit --updateSnapshot -i dist/test/smoke-cubesql.test.js",
|
|
79
79
|
"smoke:prestodb": "jest --verbose -i dist/test/smoke-prestodb.test.js",
|
|
@@ -90,14 +90,14 @@
|
|
|
90
90
|
"birdbox-fixtures"
|
|
91
91
|
],
|
|
92
92
|
"dependencies": {
|
|
93
|
-
"@cubejs-backend/cubestore-driver": "1.1.
|
|
93
|
+
"@cubejs-backend/cubestore-driver": "1.1.8",
|
|
94
94
|
"@cubejs-backend/dotenv": "^9.0.2",
|
|
95
|
-
"@cubejs-backend/ksql-driver": "1.1.
|
|
96
|
-
"@cubejs-backend/postgres-driver": "1.1.
|
|
97
|
-
"@cubejs-backend/query-orchestrator": "1.1.
|
|
98
|
-
"@cubejs-backend/schema-compiler": "1.1.
|
|
99
|
-
"@cubejs-backend/shared": "1.1.
|
|
100
|
-
"@cubejs-backend/testing-shared": "1.1.
|
|
95
|
+
"@cubejs-backend/ksql-driver": "1.1.8",
|
|
96
|
+
"@cubejs-backend/postgres-driver": "1.1.8",
|
|
97
|
+
"@cubejs-backend/query-orchestrator": "1.1.8",
|
|
98
|
+
"@cubejs-backend/schema-compiler": "1.1.8",
|
|
99
|
+
"@cubejs-backend/shared": "1.1.8",
|
|
100
|
+
"@cubejs-backend/testing-shared": "1.1.8",
|
|
101
101
|
"@cubejs-client/ws-transport": "^1.0.0",
|
|
102
102
|
"dedent": "^0.7.0",
|
|
103
103
|
"fs-extra": "^8.1.0",
|
|
@@ -146,5 +146,5 @@
|
|
|
146
146
|
"eslintConfig": {
|
|
147
147
|
"extends": "../cubejs-linter"
|
|
148
148
|
},
|
|
149
|
-
"gitHead": "
|
|
149
|
+
"gitHead": "2b4bc9efeee2dc43515822738f23c6c5e85e4461"
|
|
150
150
|
}
|