@@ -8,68 +8,81 @@ import * as vscode from "vscode";
88import { getDocUri , openDocument , activate } from "./helper" ;
99import { expect } from "chai" ;
1010
11-
1211suite ( "Test OPC-taglist command" , async ( ) => {
13- setup ( async ( ) => {
14- await vscode . commands . executeCommand ( 'workbench.action.closeAllEditors' ) ;
15- await activate ( ) ;
16- const files = await vscode . workspace . findFiles ( '**/opc_tags*' ) ;
17- for ( const file of files ) {
18- await vscode . workspace . fs . delete ( file ) ;
19- }
20- } ) ;
21-
22- teardown ( async ( ) => {
23- await vscode . commands . executeCommand ( 'workbench.action.closeAllEditors' ) ;
24- const files = await vscode . workspace . findFiles ( '**/opc_tags*' ) ;
25- for ( const file of files ) {
26- await vscode . workspace . fs . delete ( file ) ;
27- }
28- } ) ;
29-
30- test ( "Get OPC taglist from SCG context" , async ( ) => {
31- const commandPromise = vscode . commands . executeCommand ( "septic.opcTagList" ) ;
32- await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
33- await vscode . commands . executeCommand ( 'workbench.action.acceptSelectedQuickOpenItem' ) ;
34-
35- await commandPromise ;
36- const wsPath = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ;
37- const expectedFileName = "opc_tags_scg.csv" ;
38- const filePath = vscode . Uri . file ( `${ wsPath } /${ expectedFileName } ` ) ;
39-
40- const fileExists = await vscode . workspace . fs . stat ( filePath ) . then ( ( ) => true , ( ) => false ) ;
41- expect ( fileExists ) . to . be . true ;
42-
43- // Verify file content
44- const fileContent = await vscode . workspace . fs . readFile ( filePath ) ;
45- const contentStr = Buffer . from ( fileContent ) . toString ( ) ;
46- expect ( contentStr ) . to . include ( "Tag" ) ;
47-
48-
49- } ) ;
50-
51- test ( "Get OPC taglist from standalone cnfg" , async ( ) => {
52- await openDocument ( getDocUri ( "test.cnfg" ) ) ;
53- const commandPromise = vscode . commands . executeCommand ( "septic.opcTagList" ) ;
54- await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
55- await vscode . commands . executeCommand ( 'workbench.action.quickOpenSelectNext' ) ; // Move to second option
56- await vscode . commands . executeCommand ( 'workbench.action.acceptSelectedQuickOpenItem' ) ;
57-
58- await commandPromise ;
59- const wsPath = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ;
60- const expectedFileName = "opc_tags_test.csv" ;
61- const filePath = vscode . Uri . file ( `${ wsPath } /${ expectedFileName } ` ) ;
62-
63- const fileExists = await vscode . workspace . fs . stat ( filePath ) . then ( ( ) => true , ( ) => false ) ;
64- expect ( fileExists ) . to . be . true ;
65-
66- // Verify file content
67- const fileContent = await vscode . workspace . fs . readFile ( filePath ) ;
68- const contentStr = Buffer . from ( fileContent ) . toString ( ) ;
69- expect ( contentStr ) . to . include ( "Tag" ) ;
70-
71-
72- } ) ;
73-
74-
75- } ) ;
12+ setup ( async ( ) => {
13+ await vscode . commands . executeCommand (
14+ "workbench.action.closeAllEditors"
15+ ) ;
16+ await activate ( ) ;
17+ const files = await vscode . workspace . findFiles ( "**/opc_tags*" ) ;
18+ for ( const file of files ) {
19+ await vscode . workspace . fs . delete ( file ) ;
20+ }
21+ } ) ;
22+
23+ teardown ( async ( ) => {
24+ await vscode . commands . executeCommand (
25+ "workbench.action.closeAllEditors"
26+ ) ;
27+ const files = await vscode . workspace . findFiles ( "**/opc_tags*" ) ;
28+ for ( const file of files ) {
29+ await vscode . workspace . fs . delete ( file ) ;
30+ }
31+ } ) ;
32+
33+ test ( "Get OPC taglist from SCG context" , async ( ) => {
34+ const commandPromise =
35+ vscode . commands . executeCommand ( "septic.opcTagList" ) ;
36+ await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) ;
37+ await vscode . commands . executeCommand (
38+ "workbench.action.acceptSelectedQuickOpenItem"
39+ ) ;
40+
41+ await commandPromise ;
42+ const wsPath = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ;
43+ const expectedFileName = "opc_tags_scg.csv" ;
44+ const filePath = vscode . Uri . file ( `${ wsPath } /${ expectedFileName } ` ) ;
45+
46+ const fileExists = await vscode . workspace . fs . stat ( filePath ) . then (
47+ ( ) => true ,
48+ ( ) => false
49+ ) ;
50+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
51+ expect ( fileExists ) . to . be . true ;
52+
53+ // Verify file content
54+ const fileContent = await vscode . workspace . fs . readFile ( filePath ) ;
55+ const contentStr = Buffer . from ( fileContent ) . toString ( ) ;
56+ expect ( contentStr ) . to . include ( "Tag" ) ;
57+ } ) ;
58+
59+ test ( "Get OPC taglist from standalone cnfg" , async ( ) => {
60+ await openDocument ( getDocUri ( "test.cnfg" ) ) ;
61+ const commandPromise =
62+ vscode . commands . executeCommand ( "septic.opcTagList" ) ;
63+ await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) ) ;
64+ await vscode . commands . executeCommand (
65+ "workbench.action.quickOpenSelectNext"
66+ ) ; // Move to second option
67+ await vscode . commands . executeCommand (
68+ "workbench.action.acceptSelectedQuickOpenItem"
69+ ) ;
70+
71+ await commandPromise ;
72+ const wsPath = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath ;
73+ const expectedFileName = "opc_tags_test.csv" ;
74+ const filePath = vscode . Uri . file ( `${ wsPath } /${ expectedFileName } ` ) ;
75+
76+ const fileExists = await vscode . workspace . fs . stat ( filePath ) . then (
77+ ( ) => true ,
78+ ( ) => false
79+ ) ;
80+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
81+ expect ( fileExists ) . to . be . true ;
82+
83+ // Verify file content
84+ const fileContent = await vscode . workspace . fs . readFile ( filePath ) ;
85+ const contentStr = Buffer . from ( fileContent ) . toString ( ) ;
86+ expect ( contentStr ) . to . include ( "Tag" ) ;
87+ } ) ;
88+ } ) ;
0 commit comments