Skip to content

Commit 0293175

Browse files
committed
add test-plan-small
1 parent 522c256 commit 0293175

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"test-stage": "TRYORAMA_LOG_LEVEL=debug WASM_LOG=debug RUST_LOG='debug,wasmer_compiler_cranelift=error,holochain::core::workflow=error,cranelift_codegen=error,holochain::conductor::entry_def_store=error' RUST_BACKTRACE=1 GRAPHQL_DEBUG=1 npx tape test/economic-event/e2e_stage.js",
3333
"test-process-specifications": "TRYORAMA_LOG_LEVEL=debug WASM_LOG=debug RUST_LOG='debug,wasmer_compiler_cranelift=error,holochain::core::workflow=error,cranelift_codegen=error,holochain::conductor::entry_def_store=error' RUST_BACKTRACE=1 GRAPHQL_DEBUG=1 npx tape test/specification/test_processspecification_crud.js",
3434
"test-commitments": "TRYORAMA_LOG_LEVEL=warn WASM_LOG=warn RUST_LOG='warn,wasmer_compiler_cranelift=error,holochain::core::workflow=error,cranelift_codegen=error,holochain::conductor::entry_def_store=error' RUST_BACKTRACE=1 GRAPHQL_DEBUG=1 npx tape test/commitment/test_stage.js",
35+
"test-plan-small": "TRYORAMA_LOG_LEVEL=warn WASM_LOG=warn RUST_LOG='warn,wasmer_compiler_cranelift=error,holochain::core::workflow=error,cranelift_codegen=error,holochain::conductor::entry_def_store=error' RUST_BACKTRACE=1 GRAPHQL_DEBUG=1 npx tape test/plan/test_plan_small.js",
3536
"test-plan-large": "TRYORAMA_LOG_LEVEL=warn WASM_LOG=warn RUST_LOG='warn,wasmer_compiler_cranelift=error,holochain::core::workflow=error,cranelift_codegen=error,holochain::conductor::entry_def_store=error' RUST_BACKTRACE=1 GRAPHQL_DEBUG=1 npx tape test/plan/test_plan_large.js",
3637
"test-fulfillment": "TRYORAMA_LOG_LEVEL=debug WASM_LOG=debug RUST_LOG='debug,wasmer_compiler_cranelift=error,holochain::core::workflow=error,cranelift_codegen=error,holochain::conductor::entry_def_store=error' RUST_BACKTRACE=1 GRAPHQL_DEBUG=1 npx tape test/fulfillment/fulfillment_records_e2e.js",
3738
"test-proposal": "TRYORAMA_LOG_LEVEL=debug WASM_LOG=debug RUST_LOG='debug,wasmer_compiler_cranelift=error,holochain::core::workflow=error,cranelift_codegen=error,holochain::conductor::entry_def_store=error' RUST_BACKTRACE=1 GRAPHQL_DEBUG=1 npx tape test/proposal/test_proposedintent_crud.js",

test/plan/test_plan_small.js

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import test from 'tape'
2+
import { pause } from '@holochain/tryorama'
3+
import {
4+
buildPlayer,
5+
mockIdentifier,
6+
mockAddress,
7+
} from '../init.js'
8+
9+
const testCommitmentProps = {
10+
action: 'raise',
11+
resourceClassifiedAs: ['some-resource-type'],
12+
resourceQuantity: { hasNumericalValue: 1, hasUnit: mockIdentifier() },
13+
provider: mockAddress(),
14+
receiver: mockAddress(),
15+
}
16+
17+
test('Plan links & queries', async (t) => {
18+
// display the filename for context in the terminal and use .warn
19+
// to override the tap testing log filters
20+
console.warn(`\n\n${import.meta.url}`)
21+
const alice = await buildPlayer(['combined'])
22+
23+
// ===CREATE PLAN===
24+
let start = new Date()
25+
try {
26+
let resp = await alice.graphQL(`
27+
mutation($rs: PlanCreateParams!) {
28+
res: createPlan(plan: $rs) {
29+
plan {
30+
id
31+
}
32+
}
33+
}
34+
`, {
35+
rs: {
36+
name: 'test plan',
37+
created: new Date(),
38+
due: new Date(),
39+
note: 'just testing, nothing was rly planned',
40+
},
41+
})
42+
let end = new Date()
43+
console.log('⏱︎ time to create plan:', (end - start) * 0.001, 'seconds ⏱︎')
44+
t.ok(resp.data.res.plan.id, 'plan created')
45+
const planId = resp.data.res.plan.id
46+
47+
// ===CREATE 4 COMMITMENTS AND 4 PROCESSES===
48+
// define async function to create a process and commitment
49+
const createProcessAndCommitment = async (processName, commitmentNote) => {
50+
const resp = await alice.graphQL(`
51+
mutation($p: ProcessCreateParams!, $c: CommitmentCreateParams!) {
52+
process: createProcess(process: $p) {
53+
process {
54+
id
55+
}
56+
}
57+
commitment: createCommitment(commitment: $c) {
58+
commitment {
59+
id
60+
}
61+
}
62+
}
63+
`, {
64+
p: {
65+
plannedWithin: planId,
66+
name: processName,
67+
note: 'linked process note 1',
68+
},
69+
c: {
70+
independentDemandOf: planId,
71+
plannedWithin: planId,
72+
note: commitmentNote,
73+
due: new Date(Date.now() + 86400000),
74+
...testCommitmentProps,
75+
},
76+
})
77+
return resp.data.process.process.id
78+
}
79+
80+
start = new Date()
81+
let processId1 = await createProcessAndCommitment('linked process name 1', 'linked commitment 1')
82+
t.ok(processId1, 'process 1 created')
83+
end = new Date()
84+
85+
console.log('⏱︎ time to create 1 commitments and 1 processes:', (end - start) * 0.001 , 'seconds ⏱︎')
86+
} catch (e) {
87+
await alice.scenario.cleanUp()
88+
throw e
89+
}
90+
await alice.scenario.cleanUp()
91+
})

0 commit comments

Comments
 (0)