@@ -39,8 +39,6 @@ const CSV_WITH_QUOTES_AND_COMMAS = `parent,name*,displayName,description,synonym
3939,"Test1234","Contains a timestamp for the most recent ""login"" of this feature user, to be used for PIN expiration.","<p>Contains a timestamp for the most recent ""login"" of this feature user, to be used for PIN expiration.</p>",,,,,,user:admin,Approved,,,
4040,"TermWithComma,AndQuote","Display name with ""quoted"" text, and comma","<p>Description with ""quotes"" and, commas</p>",,,,,,user:admin,Approved,,,` ;
4141
42- const EXPECTED_PROCESSED = 4 ;
43-
4442test . describe ( 'CSV Import with Commas and Quotes - All Entity Types' , ( ) => {
4543 test . beforeEach ( async ( { page } ) => {
4644 await redirectToHomePage ( page ) ;
@@ -54,98 +52,93 @@ test.describe('CSV Import with Commas and Quotes - All Entity Types', () => {
5452 const targetGlossary = new Glossary ( `QuotesCommas-Target-${ uuid ( ) } ` ) ;
5553 let exportedCsvPath : string ;
5654
57- await test . step (
58- 'Create glossary and import CSV with quotes and commas' ,
59- async ( ) => {
60- await sourceGlossary . create ( apiContext ) ;
61- await sourceGlossary . visitPage ( page ) ;
62-
63- await page . click ( '[data-testid="manage-button"]' ) ;
64- await page . click ( '[data-testid="import-button-description"]' ) ;
65-
66- let tempFilePath : string | undefined ;
67- try {
68- const { tempFilePath : tempFile } = await uploadCSVAndWaitForGrid (
69- page ,
70- CSV_WITH_QUOTES_AND_COMMAS ,
71- {
72- isContentString : true ,
73- tempFileName : `temp-quotes-commas-${ uuid ( ) } .csv` ,
74- }
75- ) ;
76- tempFilePath = tempFile ;
77-
78- await expect (
79- page . getByRole ( 'gridcell' , { name : 'Term1' } ) . first ( )
80- ) . toBeVisible ( ) ;
81- await expect (
82- page
83- . getByRole ( 'gridcell' , { name : 'TermWithComma,AndQuote' } )
84- . first ( )
85- ) . toBeVisible ( ) ;
86-
87- const validationResponse = page . waitForResponse (
88- ( response ) =>
89- response . url ( ) . includes ( '/api/v1/glossaries/name/' ) &&
90- response . url ( ) . includes ( '/importAsync' ) &&
91- response . url ( ) . includes ( 'dryRun=true' ) &&
92- response . request ( ) . method ( ) === 'PUT'
93- ) ;
94-
95- await page . getByRole ( 'button' , { name : 'Next' } ) . click ( ) ;
96- await validationResponse ;
97- await page . waitForSelector ( 'text=Import is in progress.' , {
98- state : 'detached' ,
99- } ) ;
100-
101- await waitForImportGridLoadMaskToDisappear ( page ) ;
102-
103- await validateImportStatus ( page , {
104- passed : String ( EXPECTED_PROCESSED ) ,
105- processed : String ( EXPECTED_PROCESSED ) ,
106- failed : '0' ,
107- } ) ;
108-
109- const importResponse = page . waitForResponse (
110- ( response ) =>
111- response . url ( ) . includes ( '/api/v1/glossaries/name/' ) &&
112- response . url ( ) . includes ( '/importAsync' ) &&
113- response . url ( ) . includes ( 'dryRun=false' ) &&
114- response . request ( ) . method ( ) === 'PUT'
115- ) ;
116-
117- await page . getByRole ( 'button' , { name : 'Update' } ) . click ( ) ;
118- await importResponse ;
119- await waitForImportGridLoadMaskToDisappear ( page ) ;
120- } finally {
121- cleanupTempFile ( tempFilePath ) ;
122- }
123- }
124- ) ;
125-
126- await test . step (
127- 'Export CSV and verify it contains properly escaped quotes' ,
128- async ( ) => {
129- await sourceGlossary . visitPage ( page ) ;
130-
131- const downloadPromise = page . waitForEvent ( 'download' ) ;
132- await page . click ( '[data-testid="manage-button"]' ) ;
133- await page . click ( '[data-testid="export-button-description"]' ) ;
134- await page . fill ( '#fileName' , sourceGlossary . data . displayName ) ;
135- await page . click ( '#submit-button' ) ;
136- const download = await downloadPromise ;
137-
138- exportedCsvPath = `downloads/exported-${ uuid ( ) } .csv` ;
139- await download . saveAs ( exportedCsvPath ) ;
140-
141- const csvContent = fs . readFileSync ( exportedCsvPath , 'utf-8' ) ;
142- expect ( csvContent ) . toContain ( 'Term1' ) ;
143- expect ( csvContent ) . toContain ( 'TermWithComma,AndQuote' ) ;
144- expect ( csvContent ) . toContain ( '""' ) ;
145- expect ( csvContent ) . toContain ( '""quoted""' ) ;
146- expect ( csvContent ) . toContain ( '""quotes""' ) ;
55+ await test . step ( 'Create glossary and import CSV with quotes and commas' , async ( ) => {
56+ await sourceGlossary . create ( apiContext ) ;
57+ await sourceGlossary . visitPage ( page ) ;
58+
59+ await page . click ( '[data-testid="manage-button"]' ) ;
60+ await page . click ( '[data-testid="import-button-description"]' ) ;
61+
62+ let tempFilePath : string | undefined ;
63+ try {
64+ const { tempFilePath : tempFile } = await uploadCSVAndWaitForGrid (
65+ page ,
66+ CSV_WITH_QUOTES_AND_COMMAS ,
67+ {
68+ isContentString : true ,
69+ tempFileName : `temp-quotes-commas-${ uuid ( ) } .csv` ,
70+ }
71+ ) ;
72+ tempFilePath = tempFile ;
73+
74+ await expect (
75+ page . getByRole ( 'gridcell' , { name : 'Term1' } ) . first ( )
76+ ) . toBeVisible ( ) ;
77+ await expect (
78+ page . getByRole ( 'gridcell' , { name : 'TermWithComma,AndQuote' } ) . first ( )
79+ ) . toBeVisible ( ) ;
80+
81+ const validationResponse = page . waitForResponse (
82+ ( response ) =>
83+ response . url ( ) . includes ( '/api/v1/glossaries/name/' ) &&
84+ response . url ( ) . includes ( '/importAsync' ) &&
85+ response . url ( ) . includes ( 'dryRun=true' ) &&
86+ response . request ( ) . method ( ) === 'PUT'
87+ ) ;
88+
89+ await page . getByRole ( 'button' , { name : 'Next' } ) . click ( ) ;
90+ await validationResponse ;
91+ await page . waitForSelector ( 'text=Import is in progress.' , {
92+ state : 'detached' ,
93+ } ) ;
94+
95+ await waitForImportGridLoadMaskToDisappear ( page ) ;
96+
97+ const expectedProcessed = await page
98+ . getByTestId ( 'processed-row' )
99+ . textContent ( ) ;
100+ await validateImportStatus ( page , {
101+ passed : expectedProcessed ?. trim ( ) ?? '0' ,
102+ processed : expectedProcessed ?. trim ( ) ?? '0' ,
103+ failed : '0' ,
104+ } ) ;
105+
106+ const importResponse = page . waitForResponse (
107+ ( response ) =>
108+ response . url ( ) . includes ( '/api/v1/glossaries/name/' ) &&
109+ response . url ( ) . includes ( '/importAsync' ) &&
110+ response . url ( ) . includes ( 'dryRun=false' ) &&
111+ response . request ( ) . method ( ) === 'PUT'
112+ ) ;
113+
114+ await page . getByRole ( 'button' , { name : 'Update' } ) . click ( ) ;
115+ await importResponse ;
116+ await waitForImportGridLoadMaskToDisappear ( page ) ;
117+ } finally {
118+ cleanupTempFile ( tempFilePath ) ;
147119 }
148- ) ;
120+ } ) ;
121+
122+ await test . step ( 'Export CSV and verify it contains properly escaped quotes' , async ( ) => {
123+ await sourceGlossary . visitPage ( page ) ;
124+
125+ const downloadPromise = page . waitForEvent ( 'download' ) ;
126+ await page . click ( '[data-testid="manage-button"]' ) ;
127+ await page . click ( '[data-testid="export-button-description"]' ) ;
128+ await page . fill ( '#fileName' , sourceGlossary . data . displayName ) ;
129+ await page . click ( '#submit-button' ) ;
130+ const download = await downloadPromise ;
131+
132+ exportedCsvPath = `downloads/exported-${ uuid ( ) } .csv` ;
133+ await download . saveAs ( exportedCsvPath ) ;
134+
135+ const csvContent = fs . readFileSync ( exportedCsvPath , 'utf-8' ) ;
136+ expect ( csvContent ) . toContain ( 'Term1' ) ;
137+ expect ( csvContent ) . toContain ( 'TermWithComma,AndQuote' ) ;
138+ expect ( csvContent ) . toContain ( '""' ) ;
139+ expect ( csvContent ) . toContain ( '""quoted""' ) ;
140+ expect ( csvContent ) . toContain ( '""quotes""' ) ;
141+ } ) ;
149142
150143 await test . step ( 'Create new glossary and import exported CSV' , async ( ) => {
151144 await targetGlossary . create ( apiContext ) ;
@@ -180,9 +173,12 @@ test.describe('CSV Import with Commas and Quotes - All Entity Types', () => {
180173
181174 await waitForImportGridLoadMaskToDisappear ( page ) ;
182175
176+ const expectedProcessed = await page
177+ . getByTestId ( 'processed-row' )
178+ . textContent ( ) ;
183179 await validateImportStatus ( page , {
184- passed : String ( EXPECTED_PROCESSED ) ,
185- processed : String ( EXPECTED_PROCESSED ) ,
180+ passed : expectedProcessed ?. trim ( ) ?? '0' ,
181+ processed : expectedProcessed ?. trim ( ) ?? '0' ,
186182 failed : '0' ,
187183 } ) ;
188184
0 commit comments