Skip to content

Commit

Permalink
add test-plan-small
Browse files Browse the repository at this point in the history
  • Loading branch information
LeosPrograms committed Nov 4, 2024
1 parent 522c256 commit 0293175
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"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",
"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",
"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",
"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",
"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",
"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",
"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",
Expand Down
91 changes: 91 additions & 0 deletions test/plan/test_plan_small.js
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()
})

0 comments on commit 0293175

Please sign in to comment.