-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
522c256
commit 0293175
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import test from 'tape' | ||
import { pause } from '@holochain/tryorama' | ||
import { | ||
buildPlayer, | ||
mockIdentifier, | ||
mockAddress, | ||
} from '../init.js' | ||
|
||
const testCommitmentProps = { | ||
action: 'raise', | ||
resourceClassifiedAs: ['some-resource-type'], | ||
resourceQuantity: { hasNumericalValue: 1, hasUnit: mockIdentifier() }, | ||
provider: mockAddress(), | ||
receiver: mockAddress(), | ||
} | ||
|
||
test('Plan links & queries', async (t) => { | ||
// display the filename for context in the terminal and use .warn | ||
// to override the tap testing log filters | ||
console.warn(`\n\n${import.meta.url}`) | ||
const alice = await buildPlayer(['combined']) | ||
|
||
// ===CREATE PLAN=== | ||
let start = new Date() | ||
try { | ||
let resp = await alice.graphQL(` | ||
mutation($rs: PlanCreateParams!) { | ||
res: createPlan(plan: $rs) { | ||
plan { | ||
id | ||
} | ||
} | ||
} | ||
`, { | ||
rs: { | ||
name: 'test plan', | ||
created: new Date(), | ||
due: new Date(), | ||
note: 'just testing, nothing was rly planned', | ||
}, | ||
}) | ||
let end = new Date() | ||
console.log('⏱︎ time to create plan:', (end - start) * 0.001, 'seconds ⏱︎') | ||
t.ok(resp.data.res.plan.id, 'plan created') | ||
const planId = resp.data.res.plan.id | ||
|
||
// ===CREATE 4 COMMITMENTS AND 4 PROCESSES=== | ||
// define async function to create a process and commitment | ||
const createProcessAndCommitment = async (processName, commitmentNote) => { | ||
const resp = await alice.graphQL(` | ||
mutation($p: ProcessCreateParams!, $c: CommitmentCreateParams!) { | ||
process: createProcess(process: $p) { | ||
process { | ||
id | ||
} | ||
} | ||
commitment: createCommitment(commitment: $c) { | ||
commitment { | ||
id | ||
} | ||
} | ||
} | ||
`, { | ||
p: { | ||
plannedWithin: planId, | ||
name: processName, | ||
note: 'linked process note 1', | ||
}, | ||
c: { | ||
independentDemandOf: planId, | ||
plannedWithin: planId, | ||
note: commitmentNote, | ||
due: new Date(Date.now() + 86400000), | ||
...testCommitmentProps, | ||
}, | ||
}) | ||
return resp.data.process.process.id | ||
} | ||
|
||
start = new Date() | ||
let processId1 = await createProcessAndCommitment('linked process name 1', 'linked commitment 1') | ||
t.ok(processId1, 'process 1 created') | ||
end = new Date() | ||
|
||
console.log('⏱︎ time to create 1 commitments and 1 processes:', (end - start) * 0.001 , 'seconds ⏱︎') | ||
} catch (e) { | ||
await alice.scenario.cleanUp() | ||
throw e | ||
} | ||
await alice.scenario.cleanUp() | ||
}) |