import { expect } from "chai" ; import { describe , before , it } from "mocha" ; import { delay , openAdvplProject } from "../helper" ; import { ApplyPatchPageObject } from "../page-objects/apply-patch-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 , PATCHS_FILES } from "../scenario" ; describe ( "Patch Operations" , ( ) => { 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 ; } ) ; ( PATCHS_FILES . single ? it : it . skip ) ( "Apply single file" , async ( ) => { await serverItemPO . fireApplyPatchAction ( ) ; const applyPatchPO = new ApplyPatchPageObject ( ) ; await applyPatchPO . setUploadFile ( [ PATCHS_FILES . single ] ) ; await applyPatchPO . fireSubmitClose ( ) ; await delay ( 2000 ) ; expect ( await workbenchPO . applyPatchInProgress ( ) ) . is . true ; await workbenchPO . waitApplyPatch ( ) ; expect ( await workbenchPO . isPatchApplied ( ) ) . is . true ; } ) ; ( PATCHS_FILES . many ? it : it . skip ) ( "Apply many file" , async ( ) => { await serverItemPO . fireApplyPatchAction ( ) ; const applyPatchPO = new ApplyPatchPageObject ( ) ; await applyPatchPO . setUploadFile ( PATCHS_FILES . many ) ; await applyPatchPO . fireSubmitClose ( ) ; await delay ( 2000 ) ; expect ( await workbenchPO . applyPatchInProgress ( ) ) . is . true ; await workbenchPO . waitApplyPatch ( ) ; expect ( await workbenchPO . isPatchApplied ( ) ) . is . true ; } ) ; ( PATCHS_FILES . invalid ? it : it . skip ) ( "Apply invalid file" , async ( ) => { await serverItemPO . fireApplyPatchAction ( ) ; const applyPatchPO = new ApplyPatchPageObject ( ) ; await applyPatchPO . setUploadFile ( PATCHS_FILES . invalid ) ; await applyPatchPO . fireSubmitClose ( ) ; await delay ( 2000 ) ; expect ( await workbenchPO . isPatchValidateNotBeExecuted ( ) ) . is . true ; } ) ; ( PATCHS_FILES . zip ? it : it . skip ) ( "Apply many file" , async ( ) => { await serverItemPO . fireApplyPatchAction ( ) ; const applyPatchPO = new ApplyPatchPageObject ( ) ; await applyPatchPO . setUploadFile ( PATCHS_FILES . zip ) ; await applyPatchPO . fireSubmitClose ( ) ; expect ( await workbenchPO . applyPatchInProgress ( ) ) . is . true ; await workbenchPO . waitApplyPatch ( ) ; expect ( await workbenchPO . isPatchApplied ( ) ) . is . true ; } ) ; } ) ;