11import { Injectable , Logger } from '@nestjs/common' ;
22import { TestStatus } from '@prisma/client' ;
3- import { StaticService } from '../../../shared/ static/static.service' ;
3+ import { StaticService } from '../../../static/static.service' ;
44import { DiffResult } from '../../../test-runs/diffResult' ;
55import { parseConfig } from '../../utils' ;
66import { ImageComparator } from '../image-comparator.interface' ;
@@ -9,6 +9,8 @@ import { DIFF_DIMENSION_RESULT, NO_BASELINE_RESULT } from '../consts';
99import { compare } from 'odiff-bin' ;
1010import { IgnoreAreaDto } from 'src/test-runs/dto/ignore-area.dto' ;
1111import { OdiffConfig , OdiffIgnoreRegions , OdiffResult } from './odiff.types' ;
12+ import { HddService } from 'src/static/hdd/hdd.service' ;
13+ import { isHddStaticServiceConfigured } from '../../../static/utils' ;
1214
1315export const DEFAULT_CONFIG : OdiffConfig = {
1416 outputDiffMask : true ,
@@ -20,8 +22,14 @@ export const DEFAULT_CONFIG: OdiffConfig = {
2022@Injectable ( )
2123export class OdiffService implements ImageComparator {
2224 private readonly logger : Logger = new Logger ( OdiffService . name ) ;
25+ private readonly hddService : HddService ;
2326
24- constructor ( private staticService : StaticService ) { }
27+ constructor ( private staticService : StaticService ) {
28+ if ( ! isHddStaticServiceConfigured ( ) ) {
29+ throw new Error ( 'OdiffService can only be used with HddService' ) ;
30+ }
31+ this . hddService = this . staticService as unknown as HddService ;
32+ }
2533
2634 parseConfig ( configJson : string ) : OdiffConfig {
2735 return parseConfig ( configJson , DEFAULT_CONFIG , this . logger ) ;
@@ -37,10 +45,10 @@ export class OdiffService implements ImageComparator {
3745 }
3846
3947 // compare
40- const diff = this . staticService . generateNewImage ( 'diff' ) ;
48+ const diff = this . hddService . generateNewImage ( 'diff' ) ;
4149 const compareResult = ( await compare (
42- this . staticService . getImagePath ( data . baseline ) ,
43- this . staticService . getImagePath ( data . image ) ,
50+ this . hddService . getImagePath ( data . baseline ) ,
51+ this . hddService . getImagePath ( data . image ) ,
4452 diff . imagePath ,
4553 {
4654 ...config ,
0 commit comments