import { expect } from "chai" ; import { describe , before , it } from "mocha" ; import path = require ( "path" ) ; import { delay , openAdvplProject } from "../helper" ; import { ApplyPatchPageObject } from "../page-objects/apply-patch-po" ; import { ApplyTemplatePageObject } from "../page-objects/apply-template-po" ; import { ServerTreeItemPageObject } from "../page-objects/server-tree-item-po" ; import { ServerViewPageObject } from "../page-objects/server-view-po" ; import { WorkbenchPageObject } from "../page-objects/workbench-po" ; import { ADMIN_USER_DATA , APPSERVER_DATA , TEMPLATE_FILES } from "../scenario" ; ( TEMPLATE_FILES ? describe . skip : describe . skip ) ( "Apply Template" , ( ) => { let serverTreePO ; let serverItemPO ; let workbenchPO ; before ( async ( ) => { await openAdvplProject ( ) ; workbenchPO = new WorkbenchPageObject ( ) ; serverTreePO = await workbenchPO . openTotvsView ( ) ; await serverTreePO . addNewServer ( APPSERVER_DATA ) ; await delay ( ) ; } ) ; beforeEach ( async ( ) => { serverItemPO = await serverTreePO . connect ( APPSERVER_DATA . serverName , APPSERVER_DATA . environment , ADMIN_USER_DATA ) ; } ) ; afterEach ( async ( ) => { await serverItemPO . fireDisconnectAction ( ) ; serverItemPO = null ; } ) ; TEMPLATE_FILES [ "p20" ] . forEach ( ( filename ) => { it ( `Apply template: ${ path . basename ( filename ) }` , async ( ) => { await workbenchPO . executeCommand ( "totvs-developer-studio.templateApply" ) ; const applyTemplatehPO = new ApplyTemplatePageObject ( ) ; await applyTemplatehPO . setTemplateFile ( filename ) ; await applyTemplatehPO . fireSubmitClose ( ) ; await delay ( 2000 ) ; if ( await serverItemPO . isServerP20OrGreater ( ) ) { expect ( await workbenchPO . isApplyTemplateNotSuported ( ) ) . is . true ; } else { expect ( await workbenchPO . applyTemplateInProgress ( ) ) . is . true ; await workbenchPO . waitApplyTemplate ( ) ; expect ( await workbenchPO . isTemplateApplied ( ) ) . is . true ; } } ) ; } ) ; } ) ;