Skip to content

Commit

Permalink
Add test for time-based stream lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ar committed Oct 11, 2023
1 parent 80896b9 commit b3df9b2
Showing 1 changed file with 57 additions and 19 deletions.
76 changes: 57 additions & 19 deletions test/root.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ComposeClient } from '@composedb/client'
import { definition } from '@/src/__generated__/definition'
import { RuntimeCompositeDefinition } from '@composedb/types'
import { test, describe, beforeAll } from 'vitest'
import { test, describe, beforeAll, expect } from 'vitest'
import {
mutationCreateAttestation, mutationCreateClaim, mutationCreateProfile,
mutationCreateResearchObject, mutationUpdateAttestation, mutationUpdateResearchObject
mutationCreateResearchObject, mutationUpdateAttestation, mutationUpdateResearchObject, queryResearchObjects
} from '../utils/queries'
import { randomDID } from './util'
import { CeramicClient } from '@ceramicnetwork/http-client'
Expand Down Expand Up @@ -91,17 +91,13 @@ describe('ComposeDB nodes', () => {
composeClient,
{
targetID: myResearchObject.streamID,
targetVersion: myResearchObject.version,
targetVersion: myResearchObject.commitID,
claimID: myClaim.streamID,
claimVersion: myClaim.version,
claimVersion: myClaim.commitID,
revoked: false
}
);
});

test.skip('organization', async () => {
// pending membership modelling
})
});

describe('Attestations', async () => {
Expand Down Expand Up @@ -131,9 +127,9 @@ describe('ComposeDB nodes', () => {
composeClient,
{
targetID: ownProfile.streamID,
targetVersion: ownProfile.version,
targetVersion: ownProfile.commitID,
claimID: testClaim.streamID,
claimVersion: testClaim.version,
claimVersion: testClaim.commitID,
revoked: false
}
);
Expand All @@ -156,9 +152,9 @@ describe('ComposeDB nodes', () => {
composeClient,
{
targetID: user1ResearchObject.streamID,
targetVersion: user1ResearchObject.version,
targetVersion: user1ResearchObject.commitID,
claimID: testClaim.streamID,
claimVersion: testClaim.version,
claimVersion: testClaim.commitID,
revoked: false
}
);
Expand All @@ -179,9 +175,9 @@ describe('ComposeDB nodes', () => {
composeClient,
{
targetID: researchObject.streamID,
targetVersion: researchObject.version,
targetVersion: researchObject.commitID,
claimID: testClaim.streamID,
claimVersion: testClaim.version,
claimVersion: testClaim.commitID,
revoked: false
}
);
Expand All @@ -196,6 +192,16 @@ describe('ComposeDB nodes', () => {
})
})

describe.skip('Annotations', async () => {
test('can comment on research component', async () => { });

test('can comment on research object', async () => { });

test('can suggest metadata change on research component', async () => { });

test('can suggest metadata changes on research object', async () => { });
});

describe('User', async () => {
const composeClient = freshClient();
const user = await randomDID();
Expand Down Expand Up @@ -241,12 +247,44 @@ describe('ComposeDB nodes', () => {
);
}, TIMEOUT);

})
});

describe('System', async () => {
const composeClient = freshClient();
const user = await randomDID();
composeClient.setDID(user);

test('can get commits anchored before a certain time', async () => {
// This assumes anchors have been made, which is very fast running locally
// but are made in longer time periods with on-chain anchoring

const { streamID } = await mutationCreateResearchObject(
composeClient,
{
title: 'Old',
manifest: A_CID
}
);
const timeBetween = Date.now();
await setTimeout(1000)
await mutationUpdateResearchObject(
composeClient,
{
id: streamID,
title: 'New'
}
);

const stream = await ceramic.loadStream(streamID);
expect(stream.state.content.title).toEqual('New');

const streamBetween = await ceramic.loadStream(streamID, { atTime: timeBetween });
expect(streamBetween.state.content.title).toEqual('Old');
});
});


describe.skip('Querying relations', async () => {
test.todo('')
})
})

const freshClient = () =>
new ComposeClient({ceramic, definition: definition as RuntimeCompositeDefinition})
new ComposeClient({ ceramic, definition: definition as RuntimeCompositeDefinition })

0 comments on commit b3df9b2

Please sign in to comment.