@datalayer/core 0.0.12 → 0.0.13
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.
- package/README.md +2 -2
- package/lib/api/DatalayerApi.d.ts +38 -26
- package/lib/api/DatalayerApi.js +35 -8
- package/lib/api/iam/authentication.d.ts +8 -7
- package/lib/api/iam/authentication.js +14 -15
- package/lib/api/iam/healthz.d.ts +3 -2
- package/lib/api/iam/healthz.js +5 -3
- package/lib/api/iam/index.d.ts +9 -4
- package/lib/api/iam/index.js +9 -4
- package/lib/api/iam/oauth2.d.ts +115 -0
- package/lib/api/iam/oauth2.js +309 -0
- package/lib/api/iam/profile.d.ts +8 -1
- package/lib/api/iam/profile.js +17 -2
- package/lib/api/iam/usage.d.ts +56 -0
- package/lib/api/iam/usage.js +39 -0
- package/lib/api/index.d.ts +6 -5
- package/lib/api/index.js +6 -5
- package/lib/api/runtimes/environments.js +3 -2
- package/lib/api/runtimes/healthz.d.ts +3 -13
- package/lib/api/runtimes/healthz.js +4 -3
- package/lib/api/runtimes/index.d.ts +3 -2
- package/lib/api/runtimes/index.js +3 -2
- package/lib/api/runtimes/runtimes.js +17 -6
- package/lib/api/runtimes/snapshots.js +3 -2
- package/lib/api/spacer/documents.d.ts +12 -0
- package/lib/api/spacer/documents.js +43 -0
- package/lib/api/spacer/healthz.d.ts +3 -13
- package/lib/api/spacer/healthz.js +4 -3
- package/lib/api/spacer/index.d.ts +4 -2
- package/lib/api/spacer/index.js +4 -2
- package/lib/api/spacer/items.d.ts +9 -1
- package/lib/api/spacer/items.js +17 -2
- package/lib/api/spacer/lexicals.js +3 -2
- package/lib/api/spacer/notebooks.js +3 -2
- package/lib/api/spacer/spaces.js +3 -2
- package/lib/api/spacer/users.js +3 -2
- package/lib/api/types/common.d.ts +64 -0
- package/lib/api/types/iam.d.ts +88 -65
- package/lib/api/types/index.d.ts +4 -2
- package/lib/api/types/index.js +4 -2
- package/lib/api/types/runtimes.d.ts +9 -39
- package/lib/api/types/spacer.d.ts +37 -65
- package/lib/api/utils/validation.d.ts +24 -1
- package/lib/api/utils/validation.js +62 -1
- package/lib/client/base.d.ts +75 -0
- package/lib/client/base.js +199 -0
- package/lib/client/constants.d.ts +22 -0
- package/lib/client/constants.js +22 -0
- package/lib/client/index.d.ts +108 -0
- package/lib/client/index.js +79 -0
- package/lib/client/mixins/IAMMixin.d.ts +54 -0
- package/lib/client/mixins/IAMMixin.js +181 -0
- package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
- package/lib/client/mixins/RuntimesMixin.js +229 -0
- package/lib/client/mixins/SpacerMixin.d.ts +111 -0
- package/lib/client/mixins/SpacerMixin.js +340 -0
- package/lib/client/models/Credits.d.ts +91 -0
- package/lib/client/models/Credits.js +130 -0
- package/lib/client/models/Environment.d.ts +73 -0
- package/lib/client/models/Environment.js +88 -0
- package/lib/client/models/HealthCheck.d.ts +72 -0
- package/lib/client/models/HealthCheck.js +107 -0
- package/lib/client/models/Item.d.ts +69 -0
- package/lib/client/models/Item.js +191 -0
- package/lib/client/models/Lexical.d.ts +83 -0
- package/lib/client/models/Lexical.js +152 -0
- package/lib/client/models/Notebook.d.ts +87 -0
- package/lib/client/models/Notebook.js +153 -0
- package/lib/client/models/Runtime.d.ts +122 -0
- package/lib/client/models/Runtime.js +204 -0
- package/lib/client/models/Snapshot.d.ts +92 -0
- package/lib/client/models/Snapshot.js +139 -0
- package/lib/client/models/Space.d.ts +135 -0
- package/lib/client/models/Space.js +234 -0
- package/lib/client/models/User.d.ts +64 -0
- package/lib/client/models/User.js +83 -0
- package/lib/client/models/index.d.ts +26 -0
- package/lib/client/models/index.js +25 -0
- package/lib/client/utils/mixins.d.ts +12 -0
- package/lib/{sdk/client → client}/utils/mixins.js +0 -28
- package/lib/client/utils/spacerUtils.d.ts +18 -0
- package/lib/client/utils/spacerUtils.js +32 -0
- package/lib/collaboration/DatalayerCollaboration.d.ts +6 -1
- package/lib/collaboration/DatalayerCollaboration.js +2 -2
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +5 -0
- package/lib/collaboration/DatalayerCollaborationProvider.js +10 -9
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.js +1 -1
- package/lib/components/runtimes/RuntimePickerCell.js +2 -2
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +1 -1
- package/lib/components/runtimes/RuntimeTransfer.d.ts +1 -1
- package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +27 -20
- package/lib/config/Configuration.d.ts +8 -0
- package/lib/hooks/useDatalayer.js +1 -1
- package/lib/hooks/useRuntimes.js +1 -1
- package/lib/hooks/useToast.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -2
- package/lib/sdk/index.d.ts +5 -4
- package/lib/sdk/index.js +6 -5
- package/lib/services/DatalayerServiceManager.js +1 -1
- package/lib/state/substates/CoreState.js +2 -0
- package/lib/state/substates/RuntimesState.d.ts +1 -1
- package/lib/state/substates/RuntimesState.js +1 -1
- package/lib/{sdk/stateful → stateful}/index.d.ts +1 -1
- package/lib/{sdk/stateful → stateful}/index.js +1 -1
- package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.d.ts +1 -41
- package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.js +1 -20
- package/lib/{sdk/stateful → stateful}/runtimes/actions.d.ts +3 -3
- package/lib/{sdk/stateful → stateful}/runtimes/actions.js +8 -8
- package/lib/{sdk/stateful → stateful}/runtimes/apis.d.ts +8 -8
- package/lib/stateful/runtimes/apis.js +5 -0
- package/package.json +12 -10
- package/lib/__tests__/hooks.test.d.ts +0 -1
- package/lib/__tests__/hooks.test.js +0 -19
- package/lib/__tests__/index.test.d.ts +0 -1
- package/lib/__tests__/index.test.js +0 -27
- package/lib/__tests__/integration.test.d.ts +0 -1
- package/lib/__tests__/integration.test.js +0 -57
- package/lib/__tests__/shared/cleanup-shared.d.ts +0 -4
- package/lib/__tests__/shared/cleanup-shared.js +0 -228
- package/lib/__tests__/shared/test-config.d.ts +0 -51
- package/lib/__tests__/shared/test-config.js +0 -110
- package/lib/__tests__/shared/test-constants.d.ts +0 -66
- package/lib/__tests__/shared/test-constants.js +0 -79
- package/lib/__tests__/utils.test.d.ts +0 -1
- package/lib/__tests__/utils.test.js +0 -59
- package/lib/api/__tests__/iam.authentication.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.authentication.integration.test.js +0 -247
- package/lib/api/__tests__/iam.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.healthz.integration.test.js +0 -63
- package/lib/api/__tests__/iam.profile.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.profile.integration.test.js +0 -252
- package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.environments.integration.test.js +0 -122
- package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.healthz.integration.test.js +0 -50
- package/lib/api/__tests__/runtimes.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.integration.test.js +0 -369
- package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/spacer.healthz.integration.test.js +0 -50
- package/lib/api/__tests__/spacer.integration.test.d.ts +0 -1
- package/lib/api/__tests__/spacer.integration.test.js +0 -519
- package/lib/api/iam/__tests__/authentication.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/authentication.unit.test.js +0 -63
- package/lib/api/iam/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/healthz.unit.test.js +0 -60
- package/lib/api/iam/__tests__/profile.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/profile.unit.test.js +0 -57
- package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/environments.unit.test.js +0 -77
- package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/healthz.unit.test.js +0 -57
- package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/runtimes.unit.test.js +0 -139
- package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/snapshots.unit.test.js +0 -96
- package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/healthz.unit.test.js +0 -57
- package/lib/api/spacer/__tests__/items.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/items.unit.test.js +0 -165
- package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/lexicals.unit.test.js +0 -323
- package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/notebooks.unit.test.js +0 -224
- package/lib/api/spacer/__tests__/users.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/users.unit.test.js +0 -132
- package/lib/api/utils/__tests__/validation.test.d.ts +0 -1
- package/lib/api/utils/__tests__/validation.test.js +0 -109
- package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.health.integration.test.js +0 -110
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +0 -179
- package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.models.integration.test.js +0 -376
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +0 -276
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +0 -361
- package/lib/sdk/client/base.d.ts +0 -88
- package/lib/sdk/client/base.js +0 -112
- package/lib/sdk/client/index.d.ts +0 -192
- package/lib/sdk/client/index.js +0 -128
- package/lib/sdk/client/mixins/HealthMixin.d.ts +0 -100
- package/lib/sdk/client/mixins/HealthMixin.js +0 -133
- package/lib/sdk/client/mixins/IAMMixin.d.ts +0 -59
- package/lib/sdk/client/mixins/IAMMixin.js +0 -83
- package/lib/sdk/client/mixins/RuntimesMixin.d.ts +0 -134
- package/lib/sdk/client/mixins/RuntimesMixin.js +0 -221
- package/lib/sdk/client/mixins/SpacerMixin.d.ts +0 -184
- package/lib/sdk/client/mixins/SpacerMixin.js +0 -278
- package/lib/sdk/client/models/Lexical.d.ts +0 -156
- package/lib/sdk/client/models/Lexical.js +0 -275
- package/lib/sdk/client/models/Notebook.d.ts +0 -174
- package/lib/sdk/client/models/Notebook.js +0 -311
- package/lib/sdk/client/models/Runtime.d.ts +0 -221
- package/lib/sdk/client/models/Runtime.js +0 -341
- package/lib/sdk/client/models/Snapshot.d.ts +0 -156
- package/lib/sdk/client/models/Snapshot.js +0 -244
- package/lib/sdk/client/models/Space.d.ts +0 -182
- package/lib/sdk/client/models/Space.js +0 -276
- package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Lexical.test.js +0 -288
- package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Notebook.test.js +0 -206
- package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Runtime.test.js +0 -133
- package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Snapshot.test.js +0 -244
- package/lib/sdk/client/models/__tests__/Space.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Space.test.js +0 -334
- package/lib/sdk/client/models/index.d.ts +0 -30
- package/lib/sdk/client/models/index.js +0 -30
- package/lib/sdk/client/utils/mixins.d.ts +0 -42
- /package/lib/{sdk/stateful/runtimes/apis.js → api/types/common.js} +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/settings.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/settings.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/utils.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/utils.js +0 -0
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
6
|
-
import { DatalayerSDK } from '..';
|
|
7
|
-
import { Runtime } from '../models/Runtime';
|
|
8
|
-
import { Snapshot } from '../models/Snapshot';
|
|
9
|
-
import { testConfig } from '../../../__tests__/shared/test-config';
|
|
10
|
-
import { DEFAULT_SERVICE_URLS } from '../../../api/constants';
|
|
11
|
-
import { performCleanup } from '../../../__tests__/shared/cleanup-shared';
|
|
12
|
-
/**
|
|
13
|
-
* SDK Runtimes Integration Tests
|
|
14
|
-
*
|
|
15
|
-
* Tests runtime and snapshot lifecycle management
|
|
16
|
-
* using the SDK client and model classes.
|
|
17
|
-
*/
|
|
18
|
-
describe('SDK Runtimes Integration Tests', () => {
|
|
19
|
-
let sdk;
|
|
20
|
-
let createdRuntime = null;
|
|
21
|
-
let createdSnapshot = null;
|
|
22
|
-
beforeAll(async () => {
|
|
23
|
-
if (!testConfig.hasToken()) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
await performCleanup('setup');
|
|
27
|
-
sdk = new DatalayerSDK({
|
|
28
|
-
token: testConfig.getToken(),
|
|
29
|
-
iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
|
|
30
|
-
runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
|
|
31
|
-
spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
afterAll(async () => {
|
|
35
|
-
if (!testConfig.hasToken()) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
await performCleanup('teardown');
|
|
39
|
-
}, 30000);
|
|
40
|
-
describe.skipIf(!testConfig.hasToken())('Environment management', () => {
|
|
41
|
-
it('should list available environments', async () => {
|
|
42
|
-
console.log('Testing list environments...');
|
|
43
|
-
const environments = await sdk.listEnvironments();
|
|
44
|
-
expect(environments).toBeDefined();
|
|
45
|
-
expect(Array.isArray(environments)).toBe(true);
|
|
46
|
-
expect(environments.length).toBeGreaterThan(0);
|
|
47
|
-
const firstEnv = environments[0];
|
|
48
|
-
expect(firstEnv.name).toBeDefined();
|
|
49
|
-
expect(firstEnv.title).toBeDefined();
|
|
50
|
-
expect(firstEnv.language).toBeDefined();
|
|
51
|
-
console.log(`Found ${environments.length} environment(s)`);
|
|
52
|
-
console.log(`First environment: ${firstEnv.title} (${firstEnv.name})`);
|
|
53
|
-
console.log(` Language: ${firstEnv.language}`);
|
|
54
|
-
console.log(` Resources: CPU ${firstEnv.resources?.cpu}, Memory ${firstEnv.resources?.memory}`);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe.skipIf(!testConfig.hasToken() || testConfig.shouldSkipExpensive())('Runtime lifecycle', () => {
|
|
58
|
-
it('should create a runtime', async () => {
|
|
59
|
-
console.log('Creating runtime...');
|
|
60
|
-
const runtime = await sdk.createRuntime({
|
|
61
|
-
environment_name: 'python-cpu-env',
|
|
62
|
-
type: 'notebook',
|
|
63
|
-
given_name: 'sdk-test-runtime',
|
|
64
|
-
credits_limit: 10,
|
|
65
|
-
});
|
|
66
|
-
expect(runtime).toBeInstanceOf(Runtime);
|
|
67
|
-
expect(runtime.podName).toBeDefined();
|
|
68
|
-
expect(runtime.environmentName).toBe('python-cpu-env');
|
|
69
|
-
expect(runtime.givenName).toContain('sdk-test-runtime');
|
|
70
|
-
createdRuntime = runtime;
|
|
71
|
-
console.log(`Created runtime: ${runtime.podName}`);
|
|
72
|
-
console.log(` Given name: ${runtime.givenName}`);
|
|
73
|
-
console.log(` Environment: ${runtime.environmentName}`);
|
|
74
|
-
});
|
|
75
|
-
it('should list runtimes and find created runtime', async () => {
|
|
76
|
-
if (!createdRuntime) {
|
|
77
|
-
throw new Error('Test dependency failed: createdRuntime should be available from previous test');
|
|
78
|
-
}
|
|
79
|
-
console.log('Listing runtimes...');
|
|
80
|
-
const runtimes = await sdk.listRuntimes();
|
|
81
|
-
expect(Array.isArray(runtimes)).toBe(true);
|
|
82
|
-
const found = runtimes.find(r => r.podName === createdRuntime.podName);
|
|
83
|
-
expect(found).toBeDefined();
|
|
84
|
-
expect(found).toBeInstanceOf(Runtime);
|
|
85
|
-
console.log(`Found ${runtimes.length} runtime(s)`);
|
|
86
|
-
console.log(`Created runtime found in list: ${found.podName}`);
|
|
87
|
-
});
|
|
88
|
-
it('should get runtime details', async () => {
|
|
89
|
-
if (!createdRuntime) {
|
|
90
|
-
throw new Error('Test dependency failed: createdRuntime should be available from previous test');
|
|
91
|
-
}
|
|
92
|
-
console.log('Getting runtime details...');
|
|
93
|
-
const runtime = await sdk.getRuntime(createdRuntime.podName);
|
|
94
|
-
expect(runtime).toBeInstanceOf(Runtime);
|
|
95
|
-
expect(runtime.podName).toBe(createdRuntime.podName);
|
|
96
|
-
expect(runtime.environmentName).toBe(createdRuntime.environmentName);
|
|
97
|
-
console.log(`Retrieved runtime: ${runtime.podName}`);
|
|
98
|
-
console.log(` State: ${await runtime.getState()}`);
|
|
99
|
-
console.log(` Running: ${await runtime.isRunning()}`);
|
|
100
|
-
});
|
|
101
|
-
it('should test runtime model methods', async () => {
|
|
102
|
-
if (!createdRuntime) {
|
|
103
|
-
throw new Error('Test dependency failed: createdRuntime should be available from previous test');
|
|
104
|
-
}
|
|
105
|
-
console.log('Testing runtime model methods...');
|
|
106
|
-
// Test state checking methods
|
|
107
|
-
const state = await createdRuntime.getState();
|
|
108
|
-
expect(state).toBeDefined();
|
|
109
|
-
console.log(`Runtime state: ${state}`);
|
|
110
|
-
const isRunning = await createdRuntime.isRunning();
|
|
111
|
-
expect(typeof isRunning).toBe('boolean');
|
|
112
|
-
console.log(`Is running: ${isRunning}`);
|
|
113
|
-
const hasError = await createdRuntime.hasError();
|
|
114
|
-
expect(typeof hasError).toBe('boolean');
|
|
115
|
-
console.log(`Has error: ${hasError}`);
|
|
116
|
-
// Test JSON export
|
|
117
|
-
const json = await createdRuntime.toJSON();
|
|
118
|
-
expect(json).toBeDefined();
|
|
119
|
-
expect(json.pod_name).toBe(createdRuntime.podName);
|
|
120
|
-
// Test toString
|
|
121
|
-
const str = createdRuntime.toString();
|
|
122
|
-
expect(str).toContain('Runtime');
|
|
123
|
-
expect(str).toContain(createdRuntime.podName);
|
|
124
|
-
console.log(`Runtime string: ${str}`);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
describe.skipIf(!testConfig.hasToken() || testConfig.shouldSkipExpensive())('Snapshot lifecycle', () => {
|
|
128
|
-
it('should create a snapshot from runtime', async () => {
|
|
129
|
-
if (!createdRuntime) {
|
|
130
|
-
throw new Error('Test dependency failed: createdRuntime should be available from previous test');
|
|
131
|
-
}
|
|
132
|
-
console.log('Creating snapshot from runtime...');
|
|
133
|
-
const snapshot = await createdRuntime.createSnapshot('sdk-test-snapshot', 'Test snapshot from SDK');
|
|
134
|
-
expect(snapshot).toBeInstanceOf(Snapshot);
|
|
135
|
-
expect(snapshot.uid).toBeDefined();
|
|
136
|
-
expect(snapshot.name).toContain('sdk-test-snapshot');
|
|
137
|
-
createdSnapshot = snapshot;
|
|
138
|
-
console.log(`Created snapshot: ${snapshot.uid}`);
|
|
139
|
-
console.log(` Name: ${snapshot.name}`);
|
|
140
|
-
console.log(` Description: ${snapshot.description}`);
|
|
141
|
-
});
|
|
142
|
-
it('should list snapshots and find created snapshot', async () => {
|
|
143
|
-
if (!createdSnapshot) {
|
|
144
|
-
throw new Error('Test dependency failed: createdSnapshot should be available from previous test');
|
|
145
|
-
}
|
|
146
|
-
console.log('Listing snapshots...');
|
|
147
|
-
const snapshots = await sdk.listSnapshots();
|
|
148
|
-
expect(Array.isArray(snapshots)).toBe(true);
|
|
149
|
-
const found = snapshots.find(s => s.uid === createdSnapshot.uid);
|
|
150
|
-
expect(found).toBeDefined();
|
|
151
|
-
expect(found).toBeInstanceOf(Snapshot);
|
|
152
|
-
console.log(`Found ${snapshots.length} snapshot(s)`);
|
|
153
|
-
console.log(`Created snapshot found in list: ${found.uid}`);
|
|
154
|
-
});
|
|
155
|
-
it('should get snapshot details', async () => {
|
|
156
|
-
if (!createdSnapshot) {
|
|
157
|
-
throw new Error('Test dependency failed: createdSnapshot should be available from previous test');
|
|
158
|
-
}
|
|
159
|
-
console.log('Getting snapshot details...');
|
|
160
|
-
const snapshot = await sdk.getSnapshot(createdSnapshot.uid);
|
|
161
|
-
expect(snapshot).toBeInstanceOf(Snapshot);
|
|
162
|
-
expect(snapshot.uid).toBe(createdSnapshot.uid);
|
|
163
|
-
expect(snapshot.environment).toBe(createdSnapshot.environment);
|
|
164
|
-
console.log(`Retrieved snapshot: ${snapshot.uid}`);
|
|
165
|
-
const status = await snapshot.getStatus();
|
|
166
|
-
console.log(` Status: ${status}`);
|
|
167
|
-
const size = await snapshot.getSize();
|
|
168
|
-
console.log(` Size: ${size} bytes`);
|
|
169
|
-
});
|
|
170
|
-
it('should test snapshot model methods', async () => {
|
|
171
|
-
if (!createdSnapshot) {
|
|
172
|
-
throw new Error('Test dependency failed: createdSnapshot should be available from previous test');
|
|
173
|
-
}
|
|
174
|
-
console.log('Testing snapshot model methods...');
|
|
175
|
-
// Test status method
|
|
176
|
-
const status = await createdSnapshot.getStatus();
|
|
177
|
-
expect(status).toBeDefined();
|
|
178
|
-
console.log(`Snapshot status: ${status}`);
|
|
179
|
-
// Test size method
|
|
180
|
-
const size = await createdSnapshot.getSize();
|
|
181
|
-
expect(typeof size).toBe('number');
|
|
182
|
-
console.log(`Snapshot size: ${size} bytes`);
|
|
183
|
-
// Test metadata method
|
|
184
|
-
const metadata = await createdSnapshot.getLatestMetadata();
|
|
185
|
-
expect(metadata).toBeDefined();
|
|
186
|
-
console.log(`Metadata keys: ${Object.keys(metadata).join(', ')}`);
|
|
187
|
-
// Test JSON export
|
|
188
|
-
const json = await createdSnapshot.toJSON();
|
|
189
|
-
expect(json).toBeDefined();
|
|
190
|
-
expect(json.uid).toBe(createdSnapshot.uid);
|
|
191
|
-
// Test toString
|
|
192
|
-
const str = createdSnapshot.toString();
|
|
193
|
-
expect(str).toContain('Snapshot');
|
|
194
|
-
expect(str).toContain(createdSnapshot.uid);
|
|
195
|
-
console.log(`Snapshot string: ${str}`);
|
|
196
|
-
});
|
|
197
|
-
it('should delete snapshot', async () => {
|
|
198
|
-
if (!createdSnapshot) {
|
|
199
|
-
throw new Error('Test dependency failed: createdSnapshot should be available from previous test');
|
|
200
|
-
}
|
|
201
|
-
console.log('Deleting snapshot...');
|
|
202
|
-
const snapshotUid = createdSnapshot.uid; // Get uid before deletion
|
|
203
|
-
await sdk.deleteSnapshot(createdSnapshot);
|
|
204
|
-
console.log(`Snapshot ${snapshotUid} deleted`);
|
|
205
|
-
// Verify deletion
|
|
206
|
-
try {
|
|
207
|
-
await createdSnapshot.getStatus();
|
|
208
|
-
expect(true).toBe(false); // Should not reach here
|
|
209
|
-
}
|
|
210
|
-
catch (error) {
|
|
211
|
-
expect(error.message).toContain('deleted');
|
|
212
|
-
console.log('Snapshot correctly marked as deleted');
|
|
213
|
-
}
|
|
214
|
-
createdSnapshot = null; // Clear reference as it's deleted
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
describe.skipIf(!testConfig.hasToken() || testConfig.shouldSkipExpensive())('Runtime deletion', () => {
|
|
218
|
-
it('should delete runtime', async () => {
|
|
219
|
-
if (!createdRuntime) {
|
|
220
|
-
throw new Error('Test dependency failed: createdRuntime should be available from previous test');
|
|
221
|
-
}
|
|
222
|
-
console.log('Deleting runtime...');
|
|
223
|
-
const podName = createdRuntime.podName; // Get podName before deletion
|
|
224
|
-
await sdk.deleteRuntime(createdRuntime);
|
|
225
|
-
console.log(`Runtime ${podName} deleted`);
|
|
226
|
-
// Verify deletion
|
|
227
|
-
try {
|
|
228
|
-
await createdRuntime.getState();
|
|
229
|
-
expect(true).toBe(false); // Should not reach here
|
|
230
|
-
}
|
|
231
|
-
catch (error) {
|
|
232
|
-
expect(error.message).toContain('deleted');
|
|
233
|
-
console.log('Runtime correctly marked as deleted');
|
|
234
|
-
}
|
|
235
|
-
createdRuntime = null; // Clear reference as it's deleted
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
describe.skipIf(!testConfig.hasToken())('Error handling', () => {
|
|
239
|
-
it('should handle non-existent runtime gracefully', async () => {
|
|
240
|
-
console.log('Testing non-existent runtime...');
|
|
241
|
-
try {
|
|
242
|
-
await sdk.getRuntime('non-existent-pod-name');
|
|
243
|
-
expect(true).toBe(false); // Should not reach here
|
|
244
|
-
}
|
|
245
|
-
catch (error) {
|
|
246
|
-
expect(error).toBeDefined();
|
|
247
|
-
console.log('Non-existent runtime error handled correctly');
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
it('should handle non-existent snapshot gracefully', async () => {
|
|
251
|
-
console.log('Testing non-existent snapshot...');
|
|
252
|
-
try {
|
|
253
|
-
await sdk.getSnapshot('non-existent-snapshot-uid');
|
|
254
|
-
expect(true).toBe(false); // Should not reach here
|
|
255
|
-
}
|
|
256
|
-
catch (error) {
|
|
257
|
-
expect(error).toBeDefined();
|
|
258
|
-
console.log('Non-existent snapshot error handled correctly');
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
it('should validate runtime creation parameters', async () => {
|
|
262
|
-
console.log('Testing invalid runtime creation...');
|
|
263
|
-
try {
|
|
264
|
-
await sdk.createRuntime({
|
|
265
|
-
environment_name: '', // Invalid
|
|
266
|
-
type: 'notebook',
|
|
267
|
-
});
|
|
268
|
-
expect(true).toBe(false); // Should not reach here
|
|
269
|
-
}
|
|
270
|
-
catch (error) {
|
|
271
|
-
expect(error).toBeDefined();
|
|
272
|
-
console.log('Invalid runtime parameters rejected');
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
6
|
-
import { DatalayerSDK } from '..';
|
|
7
|
-
import { Space } from '../models/Space';
|
|
8
|
-
import { Notebook } from '../models/Notebook';
|
|
9
|
-
import { Lexical } from '../models/Lexical';
|
|
10
|
-
import { testConfig } from '../../../__tests__/shared/test-config';
|
|
11
|
-
import { DEFAULT_SERVICE_URLS } from '../../../api/constants';
|
|
12
|
-
import { performCleanup } from '../../../__tests__/shared/cleanup-shared';
|
|
13
|
-
/**
|
|
14
|
-
* SDK Spacer Integration Tests
|
|
15
|
-
*
|
|
16
|
-
* Tests workspace, notebook, and lexical document lifecycle
|
|
17
|
-
* using the SDK client and model classes.
|
|
18
|
-
*/
|
|
19
|
-
describe('SDK Spacer Integration Tests', () => {
|
|
20
|
-
let sdk;
|
|
21
|
-
let testSpace = null;
|
|
22
|
-
let createdNotebook = null;
|
|
23
|
-
let createdLexical = null;
|
|
24
|
-
beforeAll(async () => {
|
|
25
|
-
if (!testConfig.hasToken()) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
await performCleanup('setup');
|
|
29
|
-
sdk = new DatalayerSDK({
|
|
30
|
-
token: testConfig.getToken(),
|
|
31
|
-
iamRunUrl: DEFAULT_SERVICE_URLS.IAM,
|
|
32
|
-
runtimesRunUrl: DEFAULT_SERVICE_URLS.RUNTIMES,
|
|
33
|
-
spacerRunUrl: DEFAULT_SERVICE_URLS.SPACER,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
afterAll(async () => {
|
|
37
|
-
if (!testConfig.hasToken()) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
await performCleanup('teardown');
|
|
41
|
-
}, 30000);
|
|
42
|
-
describe.skipIf(!testConfig.hasToken())('Space management', () => {
|
|
43
|
-
it('should get user spaces', async () => {
|
|
44
|
-
console.log('Getting user spaces...');
|
|
45
|
-
const spaces = await sdk.getMySpaces();
|
|
46
|
-
expect(spaces).toBeDefined();
|
|
47
|
-
expect(Array.isArray(spaces)).toBe(true);
|
|
48
|
-
expect(spaces.length).toBeGreaterThan(0);
|
|
49
|
-
const firstSpace = spaces[0];
|
|
50
|
-
expect(firstSpace).toBeInstanceOf(Space);
|
|
51
|
-
expect(firstSpace.id || firstSpace.uid).toBeDefined();
|
|
52
|
-
testSpace = firstSpace;
|
|
53
|
-
console.log(`Found ${spaces.length} space(s)`);
|
|
54
|
-
const spaceName = await firstSpace.getName();
|
|
55
|
-
console.log(`Using space: ${spaceName || firstSpace.id || firstSpace.uid}`);
|
|
56
|
-
});
|
|
57
|
-
it('should test space model methods', async () => {
|
|
58
|
-
if (!testSpace) {
|
|
59
|
-
throw new Error('Test dependency failed: testSpace should be available from previous test');
|
|
60
|
-
}
|
|
61
|
-
console.log('Testing space model methods...');
|
|
62
|
-
// Test getName method (lazy loading)
|
|
63
|
-
const name = await testSpace.getName();
|
|
64
|
-
expect(name).toBeDefined();
|
|
65
|
-
console.log(`Space name: ${name}`);
|
|
66
|
-
// Test getDescription method
|
|
67
|
-
const description = await testSpace.getDescription();
|
|
68
|
-
console.log(`Space description: ${description || 'None'}`);
|
|
69
|
-
// Test getUpdatedAt method
|
|
70
|
-
const updatedAt = await testSpace.getUpdatedAt();
|
|
71
|
-
if (updatedAt) {
|
|
72
|
-
expect(updatedAt).toBeInstanceOf(Date);
|
|
73
|
-
console.log(`Space updated at: ${updatedAt.toISOString()}`);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
console.log('Space has no update timestamp');
|
|
77
|
-
}
|
|
78
|
-
// Test getItems method
|
|
79
|
-
const items = await testSpace.getItems();
|
|
80
|
-
expect(Array.isArray(items)).toBe(true);
|
|
81
|
-
console.log(`Space has ${items.length} item(s)`);
|
|
82
|
-
// Test toJSON method
|
|
83
|
-
const json = await testSpace.toJSON();
|
|
84
|
-
expect(json).toBeDefined();
|
|
85
|
-
expect(json.id || json.uid).toBeDefined();
|
|
86
|
-
// Test toString
|
|
87
|
-
const str = testSpace.toString();
|
|
88
|
-
expect(str).toContain('Space');
|
|
89
|
-
console.log(`Space string: ${str}`);
|
|
90
|
-
});
|
|
91
|
-
// Space creation is not implemented - removed this test
|
|
92
|
-
});
|
|
93
|
-
describe.skipIf(!testConfig.hasToken())('Notebook lifecycle', () => {
|
|
94
|
-
it('should create a notebook', async () => {
|
|
95
|
-
if (!testSpace) {
|
|
96
|
-
throw new Error('Test dependency failed: testSpace should be available from previous test');
|
|
97
|
-
}
|
|
98
|
-
console.log('Creating notebook...');
|
|
99
|
-
const notebook = await sdk.createNotebook({
|
|
100
|
-
spaceId: testSpace.uid,
|
|
101
|
-
notebookType: 'jupyter',
|
|
102
|
-
name: 'sdk-test-notebook-' + Date.now(),
|
|
103
|
-
description: 'Test notebook from SDK',
|
|
104
|
-
});
|
|
105
|
-
expect(notebook).toBeInstanceOf(Notebook);
|
|
106
|
-
expect(notebook.id).toBeDefined();
|
|
107
|
-
expect(notebook.spaceId).toBe(testSpace.uid);
|
|
108
|
-
createdNotebook = notebook;
|
|
109
|
-
console.log(`Created notebook: ${notebook.id}`);
|
|
110
|
-
console.log(` Name: ${await notebook.getName()}`);
|
|
111
|
-
console.log(` Space: ${notebook.spaceId}`);
|
|
112
|
-
});
|
|
113
|
-
it('should get notebook details', async () => {
|
|
114
|
-
if (!createdNotebook) {
|
|
115
|
-
throw new Error('Test dependency failed: notebook should be created in previous test');
|
|
116
|
-
}
|
|
117
|
-
console.log('Getting notebook details...');
|
|
118
|
-
const notebook = await sdk.getNotebook(createdNotebook.uid);
|
|
119
|
-
expect(notebook).toBeInstanceOf(Notebook);
|
|
120
|
-
expect(notebook.id).toBe(createdNotebook.id);
|
|
121
|
-
expect(notebook.spaceId).toBe(createdNotebook.spaceId);
|
|
122
|
-
console.log(`Retrieved notebook: ${notebook.id}`);
|
|
123
|
-
const notebookName = await notebook.getName();
|
|
124
|
-
console.log(` Name: ${notebookName}`);
|
|
125
|
-
});
|
|
126
|
-
it('should update notebook', async () => {
|
|
127
|
-
if (!createdNotebook) {
|
|
128
|
-
throw new Error('Test dependency failed: notebook should be created in previous test');
|
|
129
|
-
}
|
|
130
|
-
console.log('Updating notebook...');
|
|
131
|
-
const updatedNotebook = await sdk.updateNotebook(createdNotebook, {
|
|
132
|
-
name: 'sdk-test-notebook-updated',
|
|
133
|
-
description: 'Updated description from SDK test',
|
|
134
|
-
});
|
|
135
|
-
expect(updatedNotebook).toBeInstanceOf(Notebook);
|
|
136
|
-
expect(updatedNotebook.id).toBe(createdNotebook.id);
|
|
137
|
-
console.log(`Updated notebook: ${updatedNotebook.id}`);
|
|
138
|
-
const updatedNotebookName = await updatedNotebook.getName();
|
|
139
|
-
console.log(` New name: ${updatedNotebookName}`);
|
|
140
|
-
});
|
|
141
|
-
it('should test notebook model methods', async () => {
|
|
142
|
-
if (!createdNotebook) {
|
|
143
|
-
throw new Error('Test dependency failed: notebook should be created in previous test');
|
|
144
|
-
}
|
|
145
|
-
console.log('Testing notebook model methods...');
|
|
146
|
-
// Check the raw data structure (debugging removed)
|
|
147
|
-
const rawData = await createdNotebook.toJSON();
|
|
148
|
-
expect(rawData).toBeDefined();
|
|
149
|
-
// Test getName method (lazy loading)
|
|
150
|
-
const name = await createdNotebook.getName();
|
|
151
|
-
expect(name).toBeDefined();
|
|
152
|
-
console.log(`Notebook name: ${name}`);
|
|
153
|
-
// Test getContent method
|
|
154
|
-
const content = await createdNotebook.getContent();
|
|
155
|
-
console.log(`Notebook has content: ${content !== null}`);
|
|
156
|
-
// Test getKernelSpec method
|
|
157
|
-
const kernelSpec = await createdNotebook.getKernelSpec();
|
|
158
|
-
console.log(`Kernel spec: ${kernelSpec ? JSON.stringify(kernelSpec).substring(0, 50) : 'None'}`);
|
|
159
|
-
// Test getUpdatedAt method
|
|
160
|
-
const updatedAt = await createdNotebook.getUpdatedAt();
|
|
161
|
-
expect(updatedAt).toBeInstanceOf(Date);
|
|
162
|
-
console.log(`Notebook updated at: ${updatedAt.toISOString()}`);
|
|
163
|
-
// Skip the update test as the notebook was already updated in the previous test
|
|
164
|
-
// The API doesn't like rapid successive updates
|
|
165
|
-
console.log('Skipping model update test (notebook already updated)');
|
|
166
|
-
// Test toJSON method
|
|
167
|
-
const json = await createdNotebook.toJSON();
|
|
168
|
-
expect(json).toBeDefined();
|
|
169
|
-
expect(json.id).toBe(createdNotebook.id);
|
|
170
|
-
// Test toString
|
|
171
|
-
const str = createdNotebook.toString();
|
|
172
|
-
expect(str).toContain('Notebook');
|
|
173
|
-
expect(str).toContain(createdNotebook.id);
|
|
174
|
-
console.log(`Notebook string: ${str}`);
|
|
175
|
-
});
|
|
176
|
-
it('should delete notebook', async () => {
|
|
177
|
-
if (!createdNotebook) {
|
|
178
|
-
throw new Error('Test dependency failed: notebook should be created in previous test');
|
|
179
|
-
}
|
|
180
|
-
console.log('Deleting notebook...');
|
|
181
|
-
await createdNotebook.delete();
|
|
182
|
-
console.log(`Notebook deleted successfully`);
|
|
183
|
-
// Verify deletion
|
|
184
|
-
expect(createdNotebook.isDeleted).toBe(true);
|
|
185
|
-
try {
|
|
186
|
-
await createdNotebook.getName();
|
|
187
|
-
expect(true).toBe(false); // Should not reach here
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
expect(error.message).toContain('deleted');
|
|
191
|
-
console.log('Notebook correctly marked as deleted');
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
describe.skipIf(!testConfig.hasToken())('Lexical document lifecycle', () => {
|
|
196
|
-
it('should create a lexical document', async () => {
|
|
197
|
-
if (!testSpace) {
|
|
198
|
-
throw new Error('Test dependency failed: testSpace should be available from previous test');
|
|
199
|
-
}
|
|
200
|
-
console.log('Creating lexical document...');
|
|
201
|
-
const lexical = await sdk.createLexical({
|
|
202
|
-
spaceId: testSpace.uid,
|
|
203
|
-
name: 'sdk-test-lexical-' + Date.now(),
|
|
204
|
-
description: 'Test lexical from SDK',
|
|
205
|
-
documentType: 'document',
|
|
206
|
-
});
|
|
207
|
-
expect(lexical).toBeInstanceOf(Lexical);
|
|
208
|
-
expect(lexical.id).toBeDefined();
|
|
209
|
-
expect(lexical.spaceId).toBe(testSpace.uid);
|
|
210
|
-
createdLexical = lexical;
|
|
211
|
-
console.log(`Created lexical: ${lexical.id}`);
|
|
212
|
-
const lexicalName = await lexical.getName();
|
|
213
|
-
console.log(` Name: ${lexicalName}`);
|
|
214
|
-
});
|
|
215
|
-
it('should get lexical details', async () => {
|
|
216
|
-
if (!createdLexical) {
|
|
217
|
-
throw new Error('Test dependency failed: lexical should be created in previous test');
|
|
218
|
-
}
|
|
219
|
-
console.log('Getting lexical details...');
|
|
220
|
-
const lexical = await sdk.getLexical(createdLexical.uid);
|
|
221
|
-
expect(lexical).toBeInstanceOf(Lexical);
|
|
222
|
-
expect(lexical.id).toBe(createdLexical.id);
|
|
223
|
-
expect(lexical.spaceId).toBe(createdLexical.spaceId);
|
|
224
|
-
console.log(`Retrieved lexical: ${lexical.id}`);
|
|
225
|
-
const retrievedLexicalName = await lexical.getName();
|
|
226
|
-
console.log(` Name: ${retrievedLexicalName}`);
|
|
227
|
-
});
|
|
228
|
-
it('should update lexical', async () => {
|
|
229
|
-
if (!createdLexical) {
|
|
230
|
-
throw new Error('Test dependency failed: lexical should be created in previous test');
|
|
231
|
-
}
|
|
232
|
-
console.log('Updating lexical...');
|
|
233
|
-
const updatedLexical = await sdk.updateLexical(createdLexical, {
|
|
234
|
-
name: 'sdk-test-lexical-updated',
|
|
235
|
-
description: 'Updated description from SDK test',
|
|
236
|
-
});
|
|
237
|
-
expect(updatedLexical).toBeInstanceOf(Lexical);
|
|
238
|
-
expect(updatedLexical.id).toBe(createdLexical.id);
|
|
239
|
-
console.log(`Updated lexical: ${updatedLexical.id}`);
|
|
240
|
-
const updatedLexicalName = await updatedLexical.getName();
|
|
241
|
-
console.log(` New name: ${updatedLexicalName}`);
|
|
242
|
-
});
|
|
243
|
-
it('should test lexical model methods', async () => {
|
|
244
|
-
if (!createdLexical) {
|
|
245
|
-
throw new Error('Test dependency failed: lexical should be created in previous test');
|
|
246
|
-
}
|
|
247
|
-
console.log('Testing lexical model methods...');
|
|
248
|
-
// Check the raw data structure (debugging removed)
|
|
249
|
-
const rawData = await createdLexical.toJSON();
|
|
250
|
-
expect(rawData).toBeDefined();
|
|
251
|
-
// Test getName method (lazy loading)
|
|
252
|
-
const name = await createdLexical.getName();
|
|
253
|
-
expect(name).toBeDefined();
|
|
254
|
-
console.log(`Lexical name: ${name}`);
|
|
255
|
-
// Test getContent method
|
|
256
|
-
const content = await createdLexical.getContent();
|
|
257
|
-
console.log(`Lexical has content: ${content !== null}`);
|
|
258
|
-
// Test getUpdatedAt method
|
|
259
|
-
const updatedAt = await createdLexical.getUpdatedAt();
|
|
260
|
-
expect(updatedAt).toBeInstanceOf(Date);
|
|
261
|
-
console.log(`Lexical updated at: ${updatedAt.toISOString()}`);
|
|
262
|
-
// Skip the update test as the lexical was already updated in the previous test
|
|
263
|
-
// The API doesn't like rapid successive updates
|
|
264
|
-
console.log('Skipping model update test (lexical already updated)');
|
|
265
|
-
// Test toJSON method
|
|
266
|
-
const json = await createdLexical.toJSON();
|
|
267
|
-
expect(json).toBeDefined();
|
|
268
|
-
expect(json.id).toBe(createdLexical.id);
|
|
269
|
-
// Test toString
|
|
270
|
-
const str = createdLexical.toString();
|
|
271
|
-
expect(str).toContain('Lexical');
|
|
272
|
-
expect(str).toContain(createdLexical.id);
|
|
273
|
-
console.log(`Lexical string: ${str}`);
|
|
274
|
-
});
|
|
275
|
-
it('should delete lexical document', async () => {
|
|
276
|
-
if (!createdLexical) {
|
|
277
|
-
throw new Error('Test dependency failed: lexical should be created in previous test');
|
|
278
|
-
}
|
|
279
|
-
console.log('Deleting lexical...');
|
|
280
|
-
await createdLexical.delete();
|
|
281
|
-
console.log(`Lexical deleted successfully`);
|
|
282
|
-
// Verify deletion
|
|
283
|
-
expect(createdLexical.isDeleted).toBe(true);
|
|
284
|
-
try {
|
|
285
|
-
await createdLexical.getName();
|
|
286
|
-
expect(true).toBe(false); // Should not reach here
|
|
287
|
-
}
|
|
288
|
-
catch (error) {
|
|
289
|
-
expect(error.message).toContain('deleted');
|
|
290
|
-
console.log('Lexical correctly marked as deleted');
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
describe.skipIf(!testConfig.hasToken())('Space items management', () => {
|
|
295
|
-
it('should get space items', async () => {
|
|
296
|
-
if (!testSpace) {
|
|
297
|
-
throw new Error('Test dependency failed: testSpace should be available from previous test');
|
|
298
|
-
}
|
|
299
|
-
console.log('Getting space items...');
|
|
300
|
-
const response = await sdk.getSpaceItems(testSpace.uid);
|
|
301
|
-
expect(response).toBeDefined();
|
|
302
|
-
expect(response.items).toBeDefined();
|
|
303
|
-
expect(Array.isArray(response.items)).toBe(true);
|
|
304
|
-
console.log(`Space has ${response.items.length} item(s)`);
|
|
305
|
-
if (response.items.length > 0) {
|
|
306
|
-
const firstItem = response.items[0];
|
|
307
|
-
console.log(`First item: ${firstItem.name} (${firstItem.type})`);
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
it('should delete space item', async () => {
|
|
311
|
-
// Note: We don't actually delete items here as they might be important
|
|
312
|
-
// This just tests the method exists and can be called
|
|
313
|
-
console.log('Testing space item deletion (dry run)...');
|
|
314
|
-
// We would normally create a test item and delete it
|
|
315
|
-
// For now, just verify the method exists
|
|
316
|
-
expect(sdk.deleteSpaceItem).toBeDefined();
|
|
317
|
-
console.log('Space item deletion method verified');
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
describe.skipIf(!testConfig.hasToken())('Error handling', () => {
|
|
321
|
-
it('should handle non-existent notebook gracefully', async () => {
|
|
322
|
-
console.log('Testing non-existent notebook...');
|
|
323
|
-
try {
|
|
324
|
-
await sdk.getNotebook('non-existent-notebook-id');
|
|
325
|
-
expect(true).toBe(false); // Should not reach here
|
|
326
|
-
}
|
|
327
|
-
catch (error) {
|
|
328
|
-
expect(error).toBeDefined();
|
|
329
|
-
console.log('Non-existent notebook error handled correctly');
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
it('should handle non-existent lexical gracefully', async () => {
|
|
333
|
-
console.log('Testing non-existent lexical...');
|
|
334
|
-
try {
|
|
335
|
-
await sdk.getLexical('non-existent-lexical-id');
|
|
336
|
-
expect(true).toBe(false); // Should not reach here
|
|
337
|
-
}
|
|
338
|
-
catch (error) {
|
|
339
|
-
expect(error).toBeDefined();
|
|
340
|
-
console.log('Non-existent lexical error handled correctly');
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
it('should validate notebook creation parameters', async () => {
|
|
344
|
-
console.log('Testing invalid notebook creation...');
|
|
345
|
-
try {
|
|
346
|
-
// Missing required fields
|
|
347
|
-
await sdk.createNotebook({
|
|
348
|
-
spaceId: '', // Invalid empty spaceId
|
|
349
|
-
notebookType: 'jupyter',
|
|
350
|
-
name: 'test',
|
|
351
|
-
description: 'test description',
|
|
352
|
-
});
|
|
353
|
-
expect(true).toBe(false); // Should not reach here
|
|
354
|
-
}
|
|
355
|
-
catch (error) {
|
|
356
|
-
expect(error).toBeDefined();
|
|
357
|
-
console.log('Invalid notebook parameters rejected');
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
});
|