|
| 1 | +import { describe, it } from 'node:test'; |
| 2 | +import { runTutorial } from './run-tutorial.mjs'; |
| 3 | +import { assertTutorialSuccess } from './assertions.mjs'; |
| 4 | + |
| 5 | +const tutorials = [ |
| 6 | + { |
| 7 | + path: 'connect.mjs', |
| 8 | + name: 'connect', |
| 9 | + expectedPatterns: ['Connected\\. System status:'], |
| 10 | + errorPatterns: ['Failed to fetch'], |
| 11 | + timeoutMs: 30_000, |
| 12 | + }, |
| 13 | + { |
| 14 | + path: 'create-wallet.mjs', |
| 15 | + name: 'create-wallet', |
| 16 | + expectedPatterns: ['Mnemonic:', 'Platform address:'], |
| 17 | + errorPatterns: ['Something went wrong'], |
| 18 | + timeoutMs: 30_000, |
| 19 | + }, |
| 20 | + { |
| 21 | + path: '1-Identities-and-Names/identity-retrieve.mjs', |
| 22 | + name: 'identity-retrieve', |
| 23 | + expectedPatterns: ['Identity retrieved:'], |
| 24 | + errorPatterns: ['Something went wrong'], |
| 25 | + }, |
| 26 | + { |
| 27 | + path: '1-Identities-and-Names/name-resolve-by-name.mjs', |
| 28 | + name: 'name-resolve-by-name', |
| 29 | + expectedPatterns: ['Identity ID for'], |
| 30 | + errorPatterns: ['Something went wrong'], |
| 31 | + }, |
| 32 | + { |
| 33 | + path: '1-Identities-and-Names/name-search-by-name.mjs', |
| 34 | + name: 'name-search-by-name', |
| 35 | + expectedPatterns: ['\\.dash'], |
| 36 | + errorPatterns: ['Something went wrong'], |
| 37 | + }, |
| 38 | + { |
| 39 | + path: '1-Identities-and-Names/name-get-identity-names.mjs', |
| 40 | + name: 'name-get-identity-names', |
| 41 | + expectedPatterns: ['Name\\(s\\) retrieved'], |
| 42 | + errorPatterns: ['Something went wrong'], |
| 43 | + }, |
| 44 | + { |
| 45 | + path: '2-Contracts-and-Documents/contract-retrieve.mjs', |
| 46 | + name: 'contract-retrieve', |
| 47 | + expectedPatterns: ['Contract retrieved:'], |
| 48 | + errorPatterns: ['Something went wrong'], |
| 49 | + }, |
| 50 | + { |
| 51 | + path: '2-Contracts-and-Documents/contract-retrieve-history.mjs', |
| 52 | + name: 'contract-retrieve-history', |
| 53 | + expectedPatterns: ['Version at'], |
| 54 | + errorPatterns: ['Something went wrong'], |
| 55 | + }, |
| 56 | + { |
| 57 | + path: '2-Contracts-and-Documents/document-retrieve.mjs', |
| 58 | + name: 'document-retrieve', |
| 59 | + expectedPatterns: ['Document:'], |
| 60 | + errorPatterns: ['Something went wrong'], |
| 61 | + }, |
| 62 | +]; |
| 63 | + |
| 64 | +describe('Read-only tutorials', () => { |
| 65 | + for (const entry of tutorials) { |
| 66 | + it(entry.name, { timeout: entry.timeoutMs ?? 120_000 }, async () => { |
| 67 | + const result = await runTutorial(entry.path, { |
| 68 | + env: entry.env, |
| 69 | + timeoutMs: entry.timeoutMs, |
| 70 | + }); |
| 71 | + assertTutorialSuccess(result, entry); |
| 72 | + }); |
| 73 | + } |
| 74 | +}); |
0 commit comments