feat!: @rudder/sdk 0.1.0: createClient, idempotent modules.call retries, storage save(type, data), drop resources and projectStorage
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Test-side helpers: load the seed artifact and build SDK clients against prod.
|
||||
|
||||
import { RudderClient } from '../../../src/client/RudderClient.js';
|
||||
import { RudderClient, createClient } from '../../../src/client/RudderClient.js';
|
||||
import type { TokenStore } from '../../../src/token/TokenStore.js';
|
||||
import { readArtifact } from './artifact.js';
|
||||
import type { SeedArtifact } from './types.js';
|
||||
@@ -41,7 +41,7 @@ export function createInMemoryTokenStore(): TokenStore {
|
||||
export function makeProdClient(
|
||||
artifact: SeedArtifact = loadArtifact(),
|
||||
): RudderClient {
|
||||
return new RudderClient({
|
||||
return createClient({
|
||||
baseUrl: artifact.baseUrl,
|
||||
projectKey: artifact.projectKey,
|
||||
tokenStore: createInMemoryTokenStore(),
|
||||
|
||||
@@ -2,10 +2,11 @@ import { describe, it, expect } from 'vitest';
|
||||
import { freshPlayer } from './_setup/harness.js';
|
||||
|
||||
describe('e2e-prod: player', () => {
|
||||
it('device login yields a profile with a player id and wallets array', async () => {
|
||||
it('device login yields a profile with a player id wallets array and counters', async () => {
|
||||
const client = await freshPlayer();
|
||||
const profile = await client.player.reload();
|
||||
expect(profile.player?.id).toBeTruthy();
|
||||
expect(Array.isArray(profile.wallets)).toBe(true);
|
||||
expect(profile).toHaveProperty('counters');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,18 +5,15 @@ describe('e2e-prod: storage', () => {
|
||||
it('save -> get -> delete round-trip', async () => {
|
||||
const client = await freshPlayer();
|
||||
const payload = JSON.stringify({ level: 7 });
|
||||
const item = { id: 'slot_1', type: 'savegame', data: payload };
|
||||
|
||||
await client.storage.save([item]);
|
||||
await client.storage.save('savegame', payload);
|
||||
|
||||
// The server may assign its own item id, so match on type + data, not the client id.
|
||||
// v0.2 fetches the whole storage; filtering by type is client-side.
|
||||
const got = await client.storage.reload();
|
||||
expect(got.items?.some((i) => i.type === 'savegame' && i.data === payload)).toBe(true);
|
||||
|
||||
await client.storage.delete('savegame');
|
||||
|
||||
const after = await client.storage.reload();
|
||||
expect(after.items?.some((i) => i.data === payload)).toBeFalsy();
|
||||
expect(after.items?.some((i) => i.type === 'savegame')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user