Skip to content

Commit

Permalink
Update testing to work with alternative id types (#2700)
Browse files Browse the repository at this point in the history
* Update testing to work with alternative id types

* Update changelogs
  • Loading branch information
stwiname authored Feb 26, 2025
1 parent f17701a commit 418e188
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/testing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Update subqlTest to support entities with alternative ID types (#2700)

## [2.2.3] - 2025-02-04
### Changed
Expand Down
8 changes: 4 additions & 4 deletions packages/testing/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

export * from './interfaces';

import {Entity} from '@subql/types-core';
import {CompatEntity} from '@subql/types-core';

// Register test functions to a global array
export function subqlTest(
export function subqlTest<E extends CompatEntity<any> = CompatEntity<any>>(
name: string,
blockHeight: number,
dependentEntities: Entity[],
expectedEntities: Entity[],
dependentEntities: E[],
expectedEntities: E[],
handler: string
): void {
(global as any).subqlTests = (global as any).subqlTests ?? [];
Expand Down
2 changes: 2 additions & 0 deletions packages/types-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- CompatEntity type for when using alternative ID types (#2700)

## [2.0.1] - 2025-02-04
### Changed
Expand Down
3 changes: 3 additions & 0 deletions packages/types-core/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export interface Entity {
save?: () => Promise<void>;
}

// Used in selective places where @dbType directive is used to change the ID type
export type CompatEntity<T> = Omit<Entity, 'id'> & {id: T};

export type GetOptions<T> = {
/**
* The number of items to return, if this exceeds the query-limit flag it will throw
Expand Down

0 comments on commit 418e188

Please sign in to comment.