@@ -9,7 +9,7 @@ import { SFProjectRole } from 'realtime-server/lib/esm/scriptureforge/models/sf-
99import { createTestProjectProfile } from 'realtime-server/lib/esm/scriptureforge/models/sf-project-test-data' ;
1010import { TextInfoPermission } from 'realtime-server/lib/esm/scriptureforge/models/text-info-permission' ;
1111import { ProjectType } from 'realtime-server/lib/esm/scriptureforge/models/translate-config' ;
12- import { BehaviorSubject , EMPTY , of , Subject , throwError } from 'rxjs' ;
12+ import { EMPTY , of , Subject , throwError } from 'rxjs' ;
1313import { instance , mock , verify , when } from 'ts-mockito' ;
1414import { ActivatedProjectService } from 'xforge-common/activated-project.service' ;
1515import { AuthService } from 'xforge-common/auth.service' ;
@@ -200,7 +200,7 @@ describe('DraftGenerationComponent', () => {
200200 }
201201 } )
202202 } as SFProjectProfileDoc ;
203- mockAuthService = jasmine . createSpyObj < AuthService > ( [ 'requestParatextCredentialUpdate' ] , {
203+ mockAuthService = jasmine . createSpyObj < AuthService > ( [ 'requestParatextCredentialUpdate' , 'getAccessToken' ] , {
204204 currentUserId,
205205 currentUserRoles : [ SystemRole . User ]
206206 } ) ;
@@ -1331,15 +1331,6 @@ describe('DraftGenerationComponent', () => {
13311331 } ) ;
13321332
13331333 describe ( 'isDraftFaulted' , ( ) => {
1334- it ( 'should return true if the draft build is faulted' , ( ) => {
1335- const env = new TestEnvironment ( ) ;
1336- env . component . draftJob = { ...buildDto , state : BuildStates . Faulted } ;
1337- env . fixture . detectChanges ( ) ;
1338- expect ( env . component . isDraftFaulted ( { state : BuildStates . Faulted } as BuildDto ) ) . toBe ( true ) ;
1339- expect ( env . getElementByTestId ( 'warning-generation-failed' ) ) . not . toBeNull ( ) ;
1340- expect ( env . getElementByTestId ( 'technical-details' ) ) . not . toBeNull ( ) ;
1341- } ) ;
1342-
13431334 it ( 'should return false if the draft build is not faulted' , ( ) => {
13441335 const env = new TestEnvironment ( ) ;
13451336 expect ( env . component . isDraftFaulted ( { state : BuildStates . Active } as BuildDto ) ) . toBe ( false ) ;
@@ -1368,107 +1359,4 @@ describe('DraftGenerationComponent', () => {
13681359 expect ( env . component . isDraftInProgress ( { state : BuildStates . Faulted } as BuildDto ) ) . toBe ( false ) ;
13691360 } ) ;
13701361 } ) ;
1371-
1372- describe ( 'download draft button' , ( ) => {
1373- it ( 'button should display if there are draft books available' , ( ) => {
1374- const env = new TestEnvironment ( ) ;
1375- env . component . draftJob = { ...buildDto , state : BuildStates . Faulted } ;
1376- env . component . hasDraftBooksAvailable = true ;
1377- env . fixture . detectChanges ( ) ;
1378- expect ( env . downloadButton ) . not . toBeNull ( ) ;
1379- } ) ;
1380-
1381- it ( 'button should display if there is a completed build while a build is faulted' , ( ) => {
1382- const env = new TestEnvironment ( ) ;
1383- env . component . draftJob = { ...buildDto , state : BuildStates . Faulted } ;
1384- env . component . lastCompletedBuild = { ...buildDto , state : BuildStates . Completed } ;
1385- env . component . hasDraftBooksAvailable = true ;
1386- env . fixture . detectChanges ( ) ;
1387-
1388- expect ( env . downloadButton ) . not . toBeNull ( ) ;
1389- } ) ;
1390-
1391- it ( 'button should display if there is a completed build while a build is queued' , ( ) => {
1392- const env = new TestEnvironment ( ) ;
1393- env . setup ( ) ;
1394- env . component . draftJob = { ...buildDto , state : BuildStates . Queued } ;
1395- env . component . lastCompletedBuild = { ...buildDto , state : BuildStates . Completed } ;
1396- env . component . hasDraftBooksAvailable = true ;
1397- env . fixture . detectChanges ( ) ;
1398-
1399- expect ( env . downloadButton ) . not . toBeNull ( ) ;
1400- } ) ;
1401-
1402- it ( 'button should not display if there is no completed build while a build is faulted' , ( ) => {
1403- const env = new TestEnvironment ( ) ;
1404- env . component . draftJob = { ...buildDto , state : BuildStates . Faulted } ;
1405- env . component . lastCompletedBuild = undefined ;
1406- env . component . hasDraftBooksAvailable = true ;
1407- env . fixture . detectChanges ( ) ;
1408-
1409- expect ( env . downloadButton ) . toBeNull ( ) ;
1410- } ) ;
1411-
1412- it ( 'button should display if the project has a draft complete' , fakeAsync ( ( ) => {
1413- // Setup the project and subject
1414- const projectDoc : SFProjectProfileDoc = {
1415- data : createTestProjectProfile ( {
1416- translateConfig : {
1417- preTranslate : true ,
1418- projectType : ProjectType . Standard ,
1419- source : {
1420- projectRef : 'testSourceProjectId' ,
1421- writingSystem : {
1422- tag : 'es'
1423- }
1424- }
1425- } ,
1426- texts : [
1427- {
1428- bookNum : 1 ,
1429- chapters : [ { number : 1 } ] ,
1430- permissions : { user01 : TextInfoPermission . Write }
1431- }
1432- ]
1433- } )
1434- } as SFProjectProfileDoc ;
1435- const projectSubject = new BehaviorSubject < SFProjectProfileDoc > ( projectDoc ) ;
1436- const projectObservable = projectSubject . asObservable ( ) ;
1437- const buildSubject = new BehaviorSubject < BuildDto > ( buildDto ) ;
1438- const buildObservable = buildSubject . asObservable ( ) ;
1439-
1440- // Setup the initial environment
1441- const env = new TestEnvironment ( ( ) => {
1442- mockActivatedProjectService = jasmine . createSpyObj ( 'ActivatedProjectService' , [ ] , {
1443- projectDoc : projectDoc ,
1444- projectId : projectId ,
1445- projectId$ : of ( projectId ) ,
1446- projectDoc$ : projectObservable ,
1447- changes$ : projectObservable
1448- } ) ;
1449- mockDraftGenerationService . getBuildProgress . and . returnValue ( buildObservable ) ;
1450- mockDraftGenerationService . pollBuildProgress . and . returnValue ( buildObservable ) ;
1451- mockDraftGenerationService . getLastCompletedBuild . and . returnValue ( buildObservable ) ;
1452- mockSFProjectService . hasDraft . and . returnValue ( false ) ;
1453- } ) ;
1454- tick ( 500 ) ;
1455- env . fixture . detectChanges ( ) ;
1456-
1457- // Verify the button is not visible
1458- expect ( env . downloadButton ) . toBeNull ( ) ;
1459-
1460- // Update the has draft flag for the project
1461- mockSFProjectService . hasDraft . and . returnValue ( true ) ;
1462- projectDoc . data ! . translateConfig . draftConfig . lastSelectedTranslationScriptureRanges = [
1463- { projectId : 'testSourceProjectId' , scriptureRange : 'GEN' }
1464- ] ;
1465- projectSubject . next ( projectDoc ) ;
1466- buildSubject . next ( { ...buildDto , state : BuildStates . Completed } ) ;
1467- tick ( 500 ) ;
1468- env . fixture . detectChanges ( ) ;
1469-
1470- // Verify the button is visible
1471- expect ( env . downloadButton ) . not . toBeNull ( ) ;
1472- } ) ) ;
1473- } ) ;
14741362} ) ;
0 commit comments