import { expect } from "chai" ; import { describe , before , it , afterEach } from "mocha" ; import { EditorView , TextEditor } from "vscode-extension-tester" ; import { avoidsBacksliding , delay , readServersJsonFile , openAdvplProject , } from "../helper" ; import { CompileKeyPageObject } from "../page-objects/compile-key-po" ; import { IncludePageObject } from "../page-objects/include-po" ; import { ICompileKeyData } from "../page-objects/interface-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 { COMPILE_KEY_FILE , DELETE_DATA , INCLUDE_PATH_DATA } from "../scenario" ; describe . skip ( "TOTVS: Server View Configurations" , ( ) => { let serverTreePO ; let serverItemPO ; let workbenchPO ; before ( async ( ) => { await openAdvplProject ( ) ; workbenchPO = new WorkbenchPageObject ( ) ; serverTreePO = new ServerViewPageObject ( ) ; serverItemPO = new ServerTreeItemPageObject ( await serverTreePO . getNewServer ( DELETE_DATA ) ) ; await delay ( ) ; } ) ; it ( "Include (change)" , async ( ) => { const includePO = new IncludePageObject ( ) ; await serverItemPO . fireInclude ( ) ; await includePO . fillIncludePage ( INCLUDE_PATH_DATA . toChange ) ; await includePO . fireSave ( true ) ; await serverItemPO . fireInclude ( ) ; const pageData = await includePO . getIncludePage ( ) ; expect ( pageData . join ( ";" ) ) . to . equal ( INCLUDE_PATH_DATA . toChange . join ( ";" ) ) ; await includePO . fireSave ( true ) ; } ) ; it ( "Include (add more patchs)" , async ( ) => { await avoidsBacksliding ( ) ; const includePO = new IncludePageObject ( ) ; await serverItemPO . fireInclude ( ) ; const oldValue = await includePO . getIncludePage ( ) ; const newValue = [ ... oldValue , ... INCLUDE_PATH_DATA . toAdd ] ; await includePO . fillIncludePage ( newValue ) ; await includePO . fireSave ( true ) ; await avoidsBacksliding ( ) ; await serverItemPO . fireInclude ( ) ; const pageData = await includePO . getIncludePage ( ) ; expect ( pageData . join ( ";" ) ) . to . equal ( newValue . join ( ";" ) ) ; await includePO . fireSave ( true ) ; } ) ; it ( "Configure Server View" , async ( ) => { await serverTreePO . fireConfigureServerView ( ) ; const view = new EditorView ( ) ; const editor = new TextEditor ( view ) ; const title = await editor . getTitle ( ) ; const textServer = await readServersJsonFile ( ) ; const transform = ( text ) : string => { const replaces = [ [ /\r/g , "" ] , ] ; replaces . forEach ( ( element ) => { text = text . replace ( element [ 0 ] , element [ 1 ] ) ; } ) ; return text ; } ; const text = await editor . getText ( ) ; expect ( transform ( text ) ) . to . equals ( transform ( textServer ) ) ; await view . closeEditor ( title ) ; } ) ; it ( "Compile key (valid input)" , async ( ) => { const compileKeyPO = new CompileKeyPageObject ( ) ; await serverItemPO . fireCompileKey ( ) ; const oldValue = await compileKeyPO . getCompileKeyPage ( ) ; expect ( oldValue . machineId ) . not . empty ; const newValue = { ... oldValue , compileKeyFile : COMPILE_KEY_FILE [ oldValue . machineId ] , } ; await compileKeyPO . fillCompileKeyPage ( newValue ) ; expect ( await compileKeyPO . isValidKey ( ) ) . is . true ; await compileKeyPO . fireSave ( true ) ; expect ( await workbenchPO . isHaveKey ( ) ) . is . true ; } ) ; it ( "Compile key (clear)" , async ( ) => { const compileKeyPO = new CompileKeyPageObject ( ) ; await serverItemPO . fireCompileKey ( ) ; const oldValue = await compileKeyPO . getCompileKeyPage ( ) ; let newValue = { ... oldValue , compileKeyFile : COMPILE_KEY_FILE [ oldValue . machineId ] , } ; await compileKeyPO . fillCompileKeyPage ( newValue ) ; await compileKeyPO . fireSave ( true ) ; await serverItemPO . fireCompileKey ( ) ; await compileKeyPO . fireClear ( ) ; await compileKeyPO . fireSave ( false ) ; newValue = await compileKeyPO . getCompileKeyPage ( ) ; await compileKeyPO . fireSave ( true ) ; expect ( newValue . token ) . is . empty ; expect ( await workbenchPO . isNotHaveKey ( ) ) . is . true ; } ) ; } ) ;