From a5f05eea3fc695be421dcdf36d13ee319541de4c Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 2 Dec 2022 18:53:21 +0800 Subject: [PATCH 1/8] fix(nocodb): provide header in XLSX.utils.json_to_sheet --- packages/nocodb/src/lib/meta/api/dataApis/helpers.ts | 5 ++++- .../src/lib/meta/api/publicApis/publicDataExportApis.ts | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts b/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts index b68a10f1d3..5bb19fa1b4 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts @@ -58,7 +58,10 @@ export async function extractXlsxData(view: View, req: Request) { }); const { offset, dbRows, elapsed } = await getDbRows(baseModel, view, req); - const data = XLSX.utils.json_to_sheet(dbRows); + + const fields = req.query.fields as string[]; + + const data = XLSX.utils.json_to_sheet(dbRows, { header: fields }); return { offset, dbRows, elapsed, data }; } diff --git a/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts b/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts index 6d56f2f393..530504c9b7 100644 --- a/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts +++ b/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts @@ -32,7 +32,9 @@ async function exportExcel(req: Request, res: Response) { const { offset, dbRows, elapsed } = await getDbRows(model, view, req); - const data = XLSX.utils.json_to_sheet(dbRows); + const fields = req.query.fields as string[]; + + const data = XLSX.utils.json_to_sheet(dbRows, { header: fields }); const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, data, view.title); const buf = XLSX.write(wb, { type: 'base64', bookType: 'xlsx' }); From e0c67ae656dcb9d3aad7f12b16b0224186b6d0f2 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 3 Dec 2022 17:39:14 +0800 Subject: [PATCH 2/8] feat(playwrights): add download xlsx test --- .../Dashboard/common/Toolbar/ViewMenu.ts | 40 +++++++++++++++++++ tests/playwright/tests/viewMenu.spec.ts | 20 ++++++++++ 2 files changed, 60 insertions(+) diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts b/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts index ca999fb118..7b534a1c17 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts +++ b/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts @@ -4,6 +4,7 @@ import { GridPage } from '../../Grid'; import { ToolbarPage } from './index'; // @ts-ignore import fs from 'fs'; +import XLSX from 'xlsx'; export class ToolbarViewMenuPage extends BasePage { readonly toolbar: ToolbarPage; @@ -46,6 +47,33 @@ export class ToolbarViewMenuPage extends BasePage { await expect(file).toEqual(expectedData); } + async verifyDownloadAsXLSX({ + downloadLocator, + expectedDataFile, + }: { + downloadLocator: Locator; + expectedDataFile: string; + }) { + const [download] = await Promise.all([ + // Start waiting for the download + this.rootPage.waitForEvent('download'), + // Perform the action that initiates download + downloadLocator.click(), + ]); + + // Save downloaded file somewhere + await download.saveAs('./output/at.xlsx'); + + // convert xlsx to csv + const wb = XLSX.readFile('./output/at.xlsx'); + XLSX.writeFile(wb, './output/at.txt', { bookType: 'csv' }); + + // verify downloaded content against expected content + const expectedData = fs.readFileSync(expectedDataFile, 'utf8'); + const file = fs.readFileSync('./output/at.txt', 'utf8'); + await expect(file).toEqual(expectedData); + } + // menu items // Collaborative View // Download @@ -68,6 +96,13 @@ export class ToolbarViewMenuPage extends BasePage { .last(), expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.txt', }); + } else if (subMenu === 'Download as XLSX') { + await this.verifyDownloadAsXLSX({ + downloadLocator: await this.rootPage + .locator(`.ant-dropdown-menu-title-content:has-text("${subMenu}")`) + .last(), + expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.txt', + }); } else { await this.rootPage.locator(`.ant-dropdown-menu-title-content:has-text("${subMenu}")`).last().click(); } @@ -78,6 +113,11 @@ export class ToolbarViewMenuPage extends BasePage { message: 'Successfully exported all table data', }); break; + case 'Download as XLSX': + await this.verifyToast({ + message: 'Successfully exported all table data', + }); + break; case 'Locked View': await this.verifyToast({ message: 'Successfully Switched to locked view', diff --git a/tests/playwright/tests/viewMenu.spec.ts b/tests/playwright/tests/viewMenu.spec.ts index 51037e3b6b..94a2b67b51 100644 --- a/tests/playwright/tests/viewMenu.spec.ts +++ b/tests/playwright/tests/viewMenu.spec.ts @@ -56,4 +56,24 @@ test.describe('Grid view locked', () => { }, }); }); + + test.only('Download XLSX', async () => { + // close 'Team & Auth' tab + await dashboard.closeTab({ title: 'Team & Auth' }); + await dashboard.treeView.openTable({ title: 'Country' }); + + await dashboard.grid.toolbar.clickFields(); + // Hide 'LastUpdate' column + await dashboard.grid.toolbar.fields.click({ + title: 'LastUpdate', + }); + + await dashboard.grid.toolbar.viewsMenu.click({ + menu: 'Download', + subMenu: 'Download as XLSX', + verificationInfo: { + verificationFile: isPg(context) ? './fixtures/expectedBaseDownloadDataPg.txt' : null, + }, + }); + }); }); From f6e12f86fafc52a6908dbc7a24a44814b3b2521e Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 3 Dec 2022 18:16:13 +0800 Subject: [PATCH 3/8] feat(playwright): clean up export tests --- .../fixtures/expectedBaseDownloadData.txt | 110 ------------------ .../fixtures/expectedBaseDownloadDataPg.txt | 110 ------------------ tests/playwright/fixtures/expectedData.txt | 4 - .../fixtures/expectedDataSqlite.txt | 19 --- .../Dashboard/common/Toolbar/ViewMenu.ts | 12 +- .../pages/Dashboard/common/Toolbar/index.ts | 2 +- tests/playwright/tests/viewGridShare.spec.ts | 2 +- tests/playwright/tests/viewMenu.spec.ts | 6 +- 8 files changed, 11 insertions(+), 254 deletions(-) delete mode 100644 tests/playwright/fixtures/expectedBaseDownloadData.txt delete mode 100644 tests/playwright/fixtures/expectedBaseDownloadDataPg.txt delete mode 100644 tests/playwright/fixtures/expectedData.txt delete mode 100644 tests/playwright/fixtures/expectedDataSqlite.txt diff --git a/tests/playwright/fixtures/expectedBaseDownloadData.txt b/tests/playwright/fixtures/expectedBaseDownloadData.txt deleted file mode 100644 index ffce972614..0000000000 --- a/tests/playwright/fixtures/expectedBaseDownloadData.txt +++ /dev/null @@ -1,110 +0,0 @@ -Country,City List -Afghanistan,Kabul -Algeria,"Batna, Bchar, Skikda" -American Samoa,Tafuna -Angola,"Benguela, Namibe" -Anguilla,South Hill -Argentina,"Almirante Brown, Avellaneda, Baha Blanca, Crdoba, Escobar, Ezeiza, La Plata, Merlo, Quilmes, San Miguel de Tucumn, Santa F, Tandil, Vicente Lpez" -Armenia,Yerevan -Australia,Woodridge -Austria,"Graz, Linz, Salzburg" -Azerbaijan,"Baku, Sumqayit" -Bahrain,al-Manama -Bangladesh,"Dhaka, Jamalpur, Tangail" -Belarus,"Mogiljov, Molodetno" -Bolivia,"El Alto, Sucre" -Brazil,"Alvorada, Angra dos Reis, Anpolis, Aparecida de Goinia, Araatuba, Bag, Belm, Blumenau, Boa Vista, Braslia, Goinia, Guaruj, guas Lindas de Gois, Ibirit, Juazeiro do Norte, Juiz de Fora, Luzinia, Maring, Po, Poos de Caldas, Rio Claro, Santa Brbara dOeste, Santo Andr, So Bernardo do Campo, So Leopoldo" -Brunei,Bandar Seri Begawan -Bulgaria,"Ruse, Stara Zagora" -Cambodia,"Battambang, Phnom Penh" -Cameroon,"Bamenda, Yaound" -Canada,"Gatineau, Halifax, Lethbridge, London, Oshawa, Richmond Hill, Vancouver" -Chad,NDjamna -Chile,"Antofagasta, Coquimbo, Rancagua" -China,"Baicheng, Baiyin, Binzhou, Changzhou, Datong, Daxian, Dongying, Emeishan, Enshi, Ezhou, Fuyu, Fuzhou, Haining, Hami, Hohhot, Huaian, Jinchang, Jining, Jinzhou, Junan, Korla, Laiwu, Laohekou, Lengshuijiang, Leshan" -Colombia,"Buenaventura, Dos Quebradas, Florencia, Pereira, Sincelejo, Sogamoso" -"Congo, The Democratic Republic of the","Lubumbashi, Mwene-Ditu" -Czech Republic,Olomouc -Dominican Republic,"La Romana, San Felipe de Puerto Plata, Santiago de los Caballeros" -Ecuador,"Loja, Portoviejo, Robamba" -Egypt,"Bilbays, Idfu, Mit Ghamr, Qalyub, Sawhaj, Shubra al-Khayma" -Estonia,Tartu -Ethiopia,Addis Abeba -Faroe Islands,Trshavn -Finland,Oulu -France,"Brest, Le Mans, Toulon, Toulouse" -French Guiana,Cayenne -French Polynesia,"Faaa, Papeete" -Gambia,Banjul -Germany,"Duisburg, Erlangen, Halle/Saale, Mannheim, Saarbrcken, Siegen, Witten" -Greece,"Athenai, Patras" -Greenland,Nuuk -Holy See (Vatican City State),Citt del Vaticano -Hong Kong,Kowloon and New Kowloon -Hungary,Szkesfehrvr -India,"Adoni, Ahmadnagar, Allappuzha (Alleppey), Ambattur, Amroha, Balurghat, Berhampore (Baharampur), Bhavnagar, Bhilwara, Bhimavaram, Bhopal, Bhusawal, Bijapur, Chandrapur, Chapra, Dhule (Dhulia), Etawah, Firozabad, Gandhinagar, Gulbarga, Haldia, Halisahar, Hoshiarpur, Hubli-Dharwad, Jaipur" -Indonesia,"Cianjur, Ciomas, Ciparay, Gorontalo, Jakarta, Lhokseumawe, Madiun, Pangkal Pinang, Pemalang, Pontianak, Probolinggo, Purwakarta, Surakarta, Tegal" -Iran,"Arak, Esfahan, Kermanshah, Najafabad, Qomsheh, Shahr-e Kord, Sirjan, Tabriz" -Iraq,Mosul -Israel,"Ashdod, Ashqelon, Bat Yam, Tel Aviv-Jaffa" -Italy,"Alessandria, Bergamo, Brescia, Brindisi, Livorno, Syrakusa, Udine" -Japan,"Akishima, Fukuyama, Higashiosaka, Hino, Hiroshima, Isesaki, Iwaki, Iwakuni, Iwatsuki, Izumisano, Kakamigahara, Kamakura, Kanazawa, Koriyama, Kurashiki, Kuwana, Matsue, Miyakonojo, Nagareyama, Okayama, Okinawa, Omiya, Onomichi, Otsu, Sagamihara" -Kazakstan,"Pavlodar, Zhezqazghan" -Kenya,"Kisumu, Nyeri" -Kuwait,Jalib al-Shuyukh -Latvia,"Daugavpils, Liepaja" -Liechtenstein,Vaduz -Lithuania,Vilnius -Madagascar,Mahajanga -Malawi,Lilongwe -Malaysia,"Ipoh, Kuching, Sungai Petani" -Mexico,"Acua, Allende, Atlixco, Carmen, Celaya, Coacalco de Berriozbal, Coatzacoalcos, Cuauhtmoc, Cuautla, Cuernavaca, El Fuerte, Guadalajara, Hidalgo, Huejutla de Reyes, Huixquilucan, Jos Azueta, Jurez, La Paz, Matamoros, Mexicali, Monclova, Nezahualcyotl, Pachuca de Soto, Salamanca, San Felipe del Progreso" -Moldova,Chisinau -Morocco,"Beni-Mellal, Nador, Sal" -Mozambique,"Beira, Naala-Porto, Tete" -Myanmar,"Monywa, Myingyan" -Nauru,Yangor -Nepal,Birgunj -Netherlands,"Amersfoort, Apeldoorn, Ede, Emmen, s-Hertogenbosch" -New Zealand,Hamilton -Nigeria,"Benin City, Deba Habe, Effon-Alaiye, Ife, Ikerre, Ilorin, Kaduna, Ogbomosho, Ondo, Owo, Oyo, Sokoto, Zaria" -North Korea,Pyongyang -Oman,"Masqat, Salala" -Pakistan,"Dadu, Mandi Bahauddin, Mardan, Okara, Shikarpur" -Paraguay,"Asuncin, Ciudad del Este, San Lorenzo" -Peru,"Callao, Hunuco, Lima, Sullana" -Philippines,"Baybay, Bayugan, Bislig, Cabuyao, Cavite, Davao, Gingoog, Hagonoy, Iligan, Imus, Lapu-Lapu, Mandaluyong, Ozamis, Santa Rosa, Taguig, Talavera, Tanauan, Tanza, Tarlac, Tuguegarao" -Poland,"Bydgoszcz, Czestochowa, Jastrzebie-Zdrj, Kalisz, Lublin, Plock, Tychy, Wroclaw" -Puerto Rico,"Arecibo, Ponce" -Romania,"Botosani, Bucuresti" -Runion,Saint-Denis -Russian Federation,"Atinsk, Balaiha, Dzerzinsk, Elista, Ivanovo, Jaroslavl, Jelets, Kaliningrad, Kamyin, Kirovo-Tepetsk, Kolpino, Korolev, Kurgan, Kursk, Lipetsk, Ljubertsy, Maikop, Moscow, Nabereznyje Telny, Niznekamsk, Novoterkassk, Pjatigorsk, Serpuhov, Smolensk, Syktyvkar" -Saint Vincent and the Grenadines,Kingstown -Saudi Arabia,"Abha, al-Hawiya, al-Qatif, Jedda, Tabuk" -Senegal,Ziguinchor -Slovakia,Bratislava -South Africa,"Boksburg, Botshabelo, Chatsworth, Johannesburg, Kimberley, Klerksdorp, Newcastle, Paarl, Rustenburg, Soshanguve, Springs" -South Korea,"Cheju, Kimchon, Naju, Tonghae, Uijongbu" -Spain,"A Corua (La Corua), Donostia-San Sebastin, Gijn, Ourense (Orense), Santiago de Compostela" -Sri Lanka,Jaffna -Sudan,"al-Qadarif, Omdurman" -Sweden,Malm -Switzerland,"Basel, Bern, Lausanne" -Taiwan,"Changhwa, Chiayi, Chungho, Fengshan, Hsichuh, Lungtan, Nantou, Tanshui, Touliu, Tsaotun" -Tanzania,"Mwanza, Tabora, Zanzibar" -Thailand,"Nakhon Sawan, Pak Kret, Songkhla" -Tonga,Nukualofa -Tunisia,Sousse -Turkey,"Adana, Balikesir, Batman, Denizli, Eskisehir, Gaziantep, Inegl, Kilis, Ktahya, Osmaniye, Sivas, Sultanbeyli, Tarsus, Tokat, Usak" -Turkmenistan,Ashgabat -Tuvalu,Funafuti -Ukraine,"Kamjanets-Podilskyi, Konotop, Mukateve, ostka, Simferopol, Sumy" -United Arab Emirates,"Abu Dhabi, al-Ayn, Sharja" -United Kingdom,"Bradford, Dundee, London, Southampton, Southend-on-Sea, Southport, Stockport, York" -United States,"Akron, Arlington, Augusta-Richmond County, Aurora, Bellevue, Brockton, Cape Coral, Citrus Heights, Clarksville, Compton, Dallas, Dayton, El Monte, Fontana, Garden Grove, Garland, Grand Prairie, Greensboro, Joliet, Kansas City, Lancaster, Laredo, Lincoln, Manchester, Memphis" -Venezuela,"Barcelona, Caracas, Cuman, Maracabo, Ocumare del Tuy, Valencia, Valle de la Pascua" -Vietnam,"Cam Ranh, Haiphong, Hanoi, Nam Dinh, Nha Trang, Vinh" -"Virgin Islands, U.S.",Charlotte Amalie -Yemen,"Aden, Hodeida, Sanaa, Taizz" -Yugoslavia,"Kragujevac, Novi Sad" -Zambia,Kitwe \ No newline at end of file diff --git a/tests/playwright/fixtures/expectedBaseDownloadDataPg.txt b/tests/playwright/fixtures/expectedBaseDownloadDataPg.txt deleted file mode 100644 index ffce972614..0000000000 --- a/tests/playwright/fixtures/expectedBaseDownloadDataPg.txt +++ /dev/null @@ -1,110 +0,0 @@ -Country,City List -Afghanistan,Kabul -Algeria,"Batna, Bchar, Skikda" -American Samoa,Tafuna -Angola,"Benguela, Namibe" -Anguilla,South Hill -Argentina,"Almirante Brown, Avellaneda, Baha Blanca, Crdoba, Escobar, Ezeiza, La Plata, Merlo, Quilmes, San Miguel de Tucumn, Santa F, Tandil, Vicente Lpez" -Armenia,Yerevan -Australia,Woodridge -Austria,"Graz, Linz, Salzburg" -Azerbaijan,"Baku, Sumqayit" -Bahrain,al-Manama -Bangladesh,"Dhaka, Jamalpur, Tangail" -Belarus,"Mogiljov, Molodetno" -Bolivia,"El Alto, Sucre" -Brazil,"Alvorada, Angra dos Reis, Anpolis, Aparecida de Goinia, Araatuba, Bag, Belm, Blumenau, Boa Vista, Braslia, Goinia, Guaruj, guas Lindas de Gois, Ibirit, Juazeiro do Norte, Juiz de Fora, Luzinia, Maring, Po, Poos de Caldas, Rio Claro, Santa Brbara dOeste, Santo Andr, So Bernardo do Campo, So Leopoldo" -Brunei,Bandar Seri Begawan -Bulgaria,"Ruse, Stara Zagora" -Cambodia,"Battambang, Phnom Penh" -Cameroon,"Bamenda, Yaound" -Canada,"Gatineau, Halifax, Lethbridge, London, Oshawa, Richmond Hill, Vancouver" -Chad,NDjamna -Chile,"Antofagasta, Coquimbo, Rancagua" -China,"Baicheng, Baiyin, Binzhou, Changzhou, Datong, Daxian, Dongying, Emeishan, Enshi, Ezhou, Fuyu, Fuzhou, Haining, Hami, Hohhot, Huaian, Jinchang, Jining, Jinzhou, Junan, Korla, Laiwu, Laohekou, Lengshuijiang, Leshan" -Colombia,"Buenaventura, Dos Quebradas, Florencia, Pereira, Sincelejo, Sogamoso" -"Congo, The Democratic Republic of the","Lubumbashi, Mwene-Ditu" -Czech Republic,Olomouc -Dominican Republic,"La Romana, San Felipe de Puerto Plata, Santiago de los Caballeros" -Ecuador,"Loja, Portoviejo, Robamba" -Egypt,"Bilbays, Idfu, Mit Ghamr, Qalyub, Sawhaj, Shubra al-Khayma" -Estonia,Tartu -Ethiopia,Addis Abeba -Faroe Islands,Trshavn -Finland,Oulu -France,"Brest, Le Mans, Toulon, Toulouse" -French Guiana,Cayenne -French Polynesia,"Faaa, Papeete" -Gambia,Banjul -Germany,"Duisburg, Erlangen, Halle/Saale, Mannheim, Saarbrcken, Siegen, Witten" -Greece,"Athenai, Patras" -Greenland,Nuuk -Holy See (Vatican City State),Citt del Vaticano -Hong Kong,Kowloon and New Kowloon -Hungary,Szkesfehrvr -India,"Adoni, Ahmadnagar, Allappuzha (Alleppey), Ambattur, Amroha, Balurghat, Berhampore (Baharampur), Bhavnagar, Bhilwara, Bhimavaram, Bhopal, Bhusawal, Bijapur, Chandrapur, Chapra, Dhule (Dhulia), Etawah, Firozabad, Gandhinagar, Gulbarga, Haldia, Halisahar, Hoshiarpur, Hubli-Dharwad, Jaipur" -Indonesia,"Cianjur, Ciomas, Ciparay, Gorontalo, Jakarta, Lhokseumawe, Madiun, Pangkal Pinang, Pemalang, Pontianak, Probolinggo, Purwakarta, Surakarta, Tegal" -Iran,"Arak, Esfahan, Kermanshah, Najafabad, Qomsheh, Shahr-e Kord, Sirjan, Tabriz" -Iraq,Mosul -Israel,"Ashdod, Ashqelon, Bat Yam, Tel Aviv-Jaffa" -Italy,"Alessandria, Bergamo, Brescia, Brindisi, Livorno, Syrakusa, Udine" -Japan,"Akishima, Fukuyama, Higashiosaka, Hino, Hiroshima, Isesaki, Iwaki, Iwakuni, Iwatsuki, Izumisano, Kakamigahara, Kamakura, Kanazawa, Koriyama, Kurashiki, Kuwana, Matsue, Miyakonojo, Nagareyama, Okayama, Okinawa, Omiya, Onomichi, Otsu, Sagamihara" -Kazakstan,"Pavlodar, Zhezqazghan" -Kenya,"Kisumu, Nyeri" -Kuwait,Jalib al-Shuyukh -Latvia,"Daugavpils, Liepaja" -Liechtenstein,Vaduz -Lithuania,Vilnius -Madagascar,Mahajanga -Malawi,Lilongwe -Malaysia,"Ipoh, Kuching, Sungai Petani" -Mexico,"Acua, Allende, Atlixco, Carmen, Celaya, Coacalco de Berriozbal, Coatzacoalcos, Cuauhtmoc, Cuautla, Cuernavaca, El Fuerte, Guadalajara, Hidalgo, Huejutla de Reyes, Huixquilucan, Jos Azueta, Jurez, La Paz, Matamoros, Mexicali, Monclova, Nezahualcyotl, Pachuca de Soto, Salamanca, San Felipe del Progreso" -Moldova,Chisinau -Morocco,"Beni-Mellal, Nador, Sal" -Mozambique,"Beira, Naala-Porto, Tete" -Myanmar,"Monywa, Myingyan" -Nauru,Yangor -Nepal,Birgunj -Netherlands,"Amersfoort, Apeldoorn, Ede, Emmen, s-Hertogenbosch" -New Zealand,Hamilton -Nigeria,"Benin City, Deba Habe, Effon-Alaiye, Ife, Ikerre, Ilorin, Kaduna, Ogbomosho, Ondo, Owo, Oyo, Sokoto, Zaria" -North Korea,Pyongyang -Oman,"Masqat, Salala" -Pakistan,"Dadu, Mandi Bahauddin, Mardan, Okara, Shikarpur" -Paraguay,"Asuncin, Ciudad del Este, San Lorenzo" -Peru,"Callao, Hunuco, Lima, Sullana" -Philippines,"Baybay, Bayugan, Bislig, Cabuyao, Cavite, Davao, Gingoog, Hagonoy, Iligan, Imus, Lapu-Lapu, Mandaluyong, Ozamis, Santa Rosa, Taguig, Talavera, Tanauan, Tanza, Tarlac, Tuguegarao" -Poland,"Bydgoszcz, Czestochowa, Jastrzebie-Zdrj, Kalisz, Lublin, Plock, Tychy, Wroclaw" -Puerto Rico,"Arecibo, Ponce" -Romania,"Botosani, Bucuresti" -Runion,Saint-Denis -Russian Federation,"Atinsk, Balaiha, Dzerzinsk, Elista, Ivanovo, Jaroslavl, Jelets, Kaliningrad, Kamyin, Kirovo-Tepetsk, Kolpino, Korolev, Kurgan, Kursk, Lipetsk, Ljubertsy, Maikop, Moscow, Nabereznyje Telny, Niznekamsk, Novoterkassk, Pjatigorsk, Serpuhov, Smolensk, Syktyvkar" -Saint Vincent and the Grenadines,Kingstown -Saudi Arabia,"Abha, al-Hawiya, al-Qatif, Jedda, Tabuk" -Senegal,Ziguinchor -Slovakia,Bratislava -South Africa,"Boksburg, Botshabelo, Chatsworth, Johannesburg, Kimberley, Klerksdorp, Newcastle, Paarl, Rustenburg, Soshanguve, Springs" -South Korea,"Cheju, Kimchon, Naju, Tonghae, Uijongbu" -Spain,"A Corua (La Corua), Donostia-San Sebastin, Gijn, Ourense (Orense), Santiago de Compostela" -Sri Lanka,Jaffna -Sudan,"al-Qadarif, Omdurman" -Sweden,Malm -Switzerland,"Basel, Bern, Lausanne" -Taiwan,"Changhwa, Chiayi, Chungho, Fengshan, Hsichuh, Lungtan, Nantou, Tanshui, Touliu, Tsaotun" -Tanzania,"Mwanza, Tabora, Zanzibar" -Thailand,"Nakhon Sawan, Pak Kret, Songkhla" -Tonga,Nukualofa -Tunisia,Sousse -Turkey,"Adana, Balikesir, Batman, Denizli, Eskisehir, Gaziantep, Inegl, Kilis, Ktahya, Osmaniye, Sivas, Sultanbeyli, Tarsus, Tokat, Usak" -Turkmenistan,Ashgabat -Tuvalu,Funafuti -Ukraine,"Kamjanets-Podilskyi, Konotop, Mukateve, ostka, Simferopol, Sumy" -United Arab Emirates,"Abu Dhabi, al-Ayn, Sharja" -United Kingdom,"Bradford, Dundee, London, Southampton, Southend-on-Sea, Southport, Stockport, York" -United States,"Akron, Arlington, Augusta-Richmond County, Aurora, Bellevue, Brockton, Cape Coral, Citrus Heights, Clarksville, Compton, Dallas, Dayton, El Monte, Fontana, Garden Grove, Garland, Grand Prairie, Greensboro, Joliet, Kansas City, Lancaster, Laredo, Lincoln, Manchester, Memphis" -Venezuela,"Barcelona, Caracas, Cuman, Maracabo, Ocumare del Tuy, Valencia, Valle de la Pascua" -Vietnam,"Cam Ranh, Haiphong, Hanoi, Nam Dinh, Nha Trang, Vinh" -"Virgin Islands, U.S.",Charlotte Amalie -Yemen,"Aden, Hodeida, Sanaa, Taizz" -Yugoslavia,"Kragujevac, Novi Sad" -Zambia,Kitwe \ No newline at end of file diff --git a/tests/playwright/fixtures/expectedData.txt b/tests/playwright/fixtures/expectedData.txt deleted file mode 100644 index 6de66cde96..0000000000 --- a/tests/playwright/fixtures/expectedData.txt +++ /dev/null @@ -1,4 +0,0 @@ -Address,District,PostalCode,Phone,Location,Customer List,Staff List,City,Staff List1 -1661 Abha Drive,Tamil Nadu,14400,270456873752,"{""x"":78.8214191,""y"":10.3812871}",1,,Pudukkottai, -1993 Tabuk Lane,Tamil Nadu,64221,648482415405,"{""x"":80.1270701,""y"":12.9246028}",2,,Tambaram, -381 Kabul Way,Taipei,87272,55477302294,"{""x"":0,""y"":0}",2,,Hsichuh, \ No newline at end of file diff --git a/tests/playwright/fixtures/expectedDataSqlite.txt b/tests/playwright/fixtures/expectedDataSqlite.txt deleted file mode 100644 index cbf8d9cccb..0000000000 --- a/tests/playwright/fixtures/expectedDataSqlite.txt +++ /dev/null @@ -1,19 +0,0 @@ -Address,District,PostalCode,Phone,Customer List,Staff List,City,Staff List1 -1013 Tabuk Boulevard," ",96203," ",2,,Kanchrapara, -1168 Najafabad Parkway," ",40301," ",1,,Kabul, -1294 Firozabad Drive," ",70618," ",2,,Pingxiang, -1342 Abha Boulevard," ",10714," ",2,,Bucuresti, -1368 Maracabo Boulevard," ",32716," ",2,,South Hill, -1427 Tabuk Place," ",31342," ",2,,Cape Coral, -1519 Santiago de los Caballeros Loop," ",22025," ",2,,Mwene-Ditu, -1661 Abha Drive," ",14400," ",1,,Pudukkottai, -17 Kabul Boulevard," ",38594," ",1,,Nagareyama, -1838 Tabriz Lane," ",1195," ",1,,Dhaka, -1888 Kabul Drive," ",20936," ",1,,Ife, -1892 Nabereznyje Telny Lane," ",28396," ",2,,Tafuna, -1993 Tabuk Lane," ",64221," ",2,,Tambaram, -217 Botshabelo Place," ",49521," ",2,,Davao, -381 Kabul Way," ",87272," ",2,,Hsichuh, -44 Najafabad Way," ",61391," ",2,,Donostia-San Sebastin, -48 Maracabo Place," ",1570," ",1,,Talavera, -669 Firozabad Loop," ",92265," ",1,,al-Ayn, \ No newline at end of file diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts b/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts index 7b534a1c17..e5a4b050da 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts +++ b/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts @@ -62,15 +62,15 @@ export class ToolbarViewMenuPage extends BasePage { ]); // Save downloaded file somewhere - await download.saveAs('./output/at.xlsx'); + await download.saveAs('./output/test.xlsx'); // convert xlsx to csv - const wb = XLSX.readFile('./output/at.xlsx'); - XLSX.writeFile(wb, './output/at.txt', { bookType: 'csv' }); + const wb = XLSX.readFile('./output/test.xlsx'); + XLSX.writeFile(wb, './output/test.csv', { bookType: 'csv' }); // verify downloaded content against expected content const expectedData = fs.readFileSync(expectedDataFile, 'utf8'); - const file = fs.readFileSync('./output/at.txt', 'utf8'); + const file = fs.readFileSync('./output/test.csv', 'utf8'); await expect(file).toEqual(expectedData); } @@ -94,14 +94,14 @@ export class ToolbarViewMenuPage extends BasePage { downloadLocator: await this.rootPage .locator(`.ant-dropdown-menu-title-content:has-text("${subMenu}")`) .last(), - expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.txt', + expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.csv', }); } else if (subMenu === 'Download as XLSX') { await this.verifyDownloadAsXLSX({ downloadLocator: await this.rootPage .locator(`.ant-dropdown-menu-title-content:has-text("${subMenu}")`) .last(), - expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.txt', + expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.csv', }); } else { await this.rootPage.locator(`.ant-dropdown-menu-title-content:has-text("${subMenu}")`).last().click(); diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/index.ts b/tests/playwright/pages/Dashboard/common/Toolbar/index.ts index 02c1f6bedb..f33b6bd1bd 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/index.ts +++ b/tests/playwright/pages/Dashboard/common/Toolbar/index.ts @@ -111,7 +111,7 @@ export class ToolbarPage extends BasePage { await this.get().locator(`.nc-toolbar-btn.nc-add-new-row-btn`).click(); } - async clickDownload(type: string, verificationFile = 'expectedData.txt') { + async clickDownload(type: string, verificationFile = 'expectedData.csv') { await this.get().locator(`.nc-toolbar-btn.nc-actions-menu-btn`).click(); const [download] = await Promise.all([ diff --git a/tests/playwright/tests/viewGridShare.spec.ts b/tests/playwright/tests/viewGridShare.spec.ts index 6e6f82baa5..61b6c1f73c 100644 --- a/tests/playwright/tests/viewGridShare.spec.ts +++ b/tests/playwright/tests/viewGridShare.spec.ts @@ -139,7 +139,7 @@ test.describe('Shared view', () => { // verify download await sharedPage.grid.toolbar.clickDownload( 'Download as CSV', - isSqlite(context) || isPg(context) ? 'expectedDataSqlite.txt' : 'expectedData.txt' + isSqlite(context) || isPg(context) ? 'expectedDataSqlite.csv' : 'expectedData.csv' ); }); diff --git a/tests/playwright/tests/viewMenu.spec.ts b/tests/playwright/tests/viewMenu.spec.ts index 94a2b67b51..521549c5ae 100644 --- a/tests/playwright/tests/viewMenu.spec.ts +++ b/tests/playwright/tests/viewMenu.spec.ts @@ -52,12 +52,12 @@ test.describe('Grid view locked', () => { menu: 'Download', subMenu: 'Download as CSV', verificationInfo: { - verificationFile: isPg(context) ? './fixtures/expectedBaseDownloadDataPg.txt' : null, + verificationFile: isPg(context) ? './fixtures/expectedBaseDownloadDataPg.csv' : null, }, }); }); - test.only('Download XLSX', async () => { + test('Download XLSX', async () => { // close 'Team & Auth' tab await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.treeView.openTable({ title: 'Country' }); @@ -72,7 +72,7 @@ test.describe('Grid view locked', () => { menu: 'Download', subMenu: 'Download as XLSX', verificationInfo: { - verificationFile: isPg(context) ? './fixtures/expectedBaseDownloadDataPg.txt' : null, + verificationFile: isPg(context) ? './fixtures/expectedBaseDownloadDataPg.csv' : null, }, }); }); From 32115b17718016968d1c1902fd6ca174de795226 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 3 Dec 2022 23:19:23 +0800 Subject: [PATCH 4/8] fix(playwright): use txt instead of csv for fs reader --- .../fixtures/expectedBaseDownloadData.txt | 110 ++++++++++++++++++ .../fixtures/expectedBaseDownloadDataPg.txt | 110 ++++++++++++++++++ tests/playwright/fixtures/expectedData.txt | 4 + .../fixtures/expectedDataSqlite.txt | 19 +++ .../Dashboard/common/Toolbar/ViewMenu.ts | 8 +- .../pages/Dashboard/common/Toolbar/index.ts | 2 +- tests/playwright/tests/viewGridShare.spec.ts | 2 +- tests/playwright/tests/viewMenu.spec.ts | 4 +- 8 files changed, 251 insertions(+), 8 deletions(-) create mode 100644 tests/playwright/fixtures/expectedBaseDownloadData.txt create mode 100644 tests/playwright/fixtures/expectedBaseDownloadDataPg.txt create mode 100644 tests/playwright/fixtures/expectedData.txt create mode 100644 tests/playwright/fixtures/expectedDataSqlite.txt diff --git a/tests/playwright/fixtures/expectedBaseDownloadData.txt b/tests/playwright/fixtures/expectedBaseDownloadData.txt new file mode 100644 index 0000000000..9002600ee2 --- /dev/null +++ b/tests/playwright/fixtures/expectedBaseDownloadData.txt @@ -0,0 +1,110 @@ +Country,City List +Afghanistan,Kabul +Algeria,"Batna, Bchar, Skikda" +American Samoa,Tafuna +Angola,"Benguela, Namibe" +Anguilla,South Hill +Argentina,"Almirante Brown, Avellaneda, Baha Blanca, Crdoba, Escobar, Ezeiza, La Plata, Merlo, Quilmes, San Miguel de Tucumn, Santa F, Tandil, Vicente Lpez" +Armenia,Yerevan +Australia,Woodridge +Austria,"Graz, Linz, Salzburg" +Azerbaijan,"Baku, Sumqayit" +Bahrain,al-Manama +Bangladesh,"Dhaka, Jamalpur, Tangail" +Belarus,"Mogiljov, Molodetno" +Bolivia,"El Alto, Sucre" +Brazil,"Alvorada, Angra dos Reis, Anpolis, Aparecida de Goinia, Araatuba, Bag, Belm, Blumenau, Boa Vista, Braslia, Goinia, Guaruj, guas Lindas de Gois, Ibirit, Juazeiro do Norte, Juiz de Fora, Luzinia, Maring, Po, Poos de Caldas, Rio Claro, Santa Brbara dOeste, Santo Andr, So Bernardo do Campo, So Leopoldo" +Brunei,Bandar Seri Begawan +Bulgaria,"Ruse, Stara Zagora" +Cambodia,"Battambang, Phnom Penh" +Cameroon,"Bamenda, Yaound" +Canada,"Gatineau, Halifax, Lethbridge, London, Oshawa, Richmond Hill, Vancouver" +Chad,NDjamna +Chile,"Antofagasta, Coquimbo, Rancagua" +China,"Baicheng, Baiyin, Binzhou, Changzhou, Datong, Daxian, Dongying, Emeishan, Enshi, Ezhou, Fuyu, Fuzhou, Haining, Hami, Hohhot, Huaian, Jinchang, Jining, Jinzhou, Junan, Korla, Laiwu, Laohekou, Lengshuijiang, Leshan" +Colombia,"Buenaventura, Dos Quebradas, Florencia, Pereira, Sincelejo, Sogamoso" +"Congo, The Democratic Republic of the","Lubumbashi, Mwene-Ditu" +Czech Republic,Olomouc +Dominican Republic,"La Romana, San Felipe de Puerto Plata, Santiago de los Caballeros" +Ecuador,"Loja, Portoviejo, Robamba" +Egypt,"Bilbays, Idfu, Mit Ghamr, Qalyub, Sawhaj, Shubra al-Khayma" +Estonia,Tartu +Ethiopia,Addis Abeba +Faroe Islands,Trshavn +Finland,Oulu +France,"Brest, Le Mans, Toulon, Toulouse" +French Guiana,Cayenne +French Polynesia,"Faaa, Papeete" +Gambia,Banjul +Germany,"Duisburg, Erlangen, Halle/Saale, Mannheim, Saarbrcken, Siegen, Witten" +Greece,"Athenai, Patras" +Greenland,Nuuk +Holy See (Vatican City State),Citt del Vaticano +Hong Kong,Kowloon and New Kowloon +Hungary,Szkesfehrvr +India,"Adoni, Ahmadnagar, Allappuzha (Alleppey), Ambattur, Amroha, Balurghat, Berhampore (Baharampur), Bhavnagar, Bhilwara, Bhimavaram, Bhopal, Bhusawal, Bijapur, Chandrapur, Chapra, Dhule (Dhulia), Etawah, Firozabad, Gandhinagar, Gulbarga, Haldia, Halisahar, Hoshiarpur, Hubli-Dharwad, Jaipur" +Indonesia,"Cianjur, Ciomas, Ciparay, Gorontalo, Jakarta, Lhokseumawe, Madiun, Pangkal Pinang, Pemalang, Pontianak, Probolinggo, Purwakarta, Surakarta, Tegal" +Iran,"Arak, Esfahan, Kermanshah, Najafabad, Qomsheh, Shahr-e Kord, Sirjan, Tabriz" +Iraq,Mosul +Israel,"Ashdod, Ashqelon, Bat Yam, Tel Aviv-Jaffa" +Italy,"Alessandria, Bergamo, Brescia, Brindisi, Livorno, Syrakusa, Udine" +Japan,"Akishima, Fukuyama, Higashiosaka, Hino, Hiroshima, Isesaki, Iwaki, Iwakuni, Iwatsuki, Izumisano, Kakamigahara, Kamakura, Kanazawa, Koriyama, Kurashiki, Kuwana, Matsue, Miyakonojo, Nagareyama, Okayama, Okinawa, Omiya, Onomichi, Otsu, Sagamihara" +Kazakstan,"Pavlodar, Zhezqazghan" +Kenya,"Kisumu, Nyeri" +Kuwait,Jalib al-Shuyukh +Latvia,"Daugavpils, Liepaja" +Liechtenstein,Vaduz +Lithuania,Vilnius +Madagascar,Mahajanga +Malawi,Lilongwe +Malaysia,"Ipoh, Kuching, Sungai Petani" +Mexico,"Acua, Allende, Atlixco, Carmen, Celaya, Coacalco de Berriozbal, Coatzacoalcos, Cuauhtmoc, Cuautla, Cuernavaca, El Fuerte, Guadalajara, Hidalgo, Huejutla de Reyes, Huixquilucan, Jos Azueta, Jurez, La Paz, Matamoros, Mexicali, Monclova, Nezahualcyotl, Pachuca de Soto, Salamanca, San Felipe del Progreso" +Moldova,Chisinau +Morocco,"Beni-Mellal, Nador, Sal" +Mozambique,"Beira, Naala-Porto, Tete" +Myanmar,"Monywa, Myingyan" +Nauru,Yangor +Nepal,Birgunj +Netherlands,"Amersfoort, Apeldoorn, Ede, Emmen, s-Hertogenbosch" +New Zealand,Hamilton +Nigeria,"Benin City, Deba Habe, Effon-Alaiye, Ife, Ikerre, Ilorin, Kaduna, Ogbomosho, Ondo, Owo, Oyo, Sokoto, Zaria" +North Korea,Pyongyang +Oman,"Masqat, Salala" +Pakistan,"Dadu, Mandi Bahauddin, Mardan, Okara, Shikarpur" +Paraguay,"Asuncin, Ciudad del Este, San Lorenzo" +Peru,"Callao, Hunuco, Lima, Sullana" +Philippines,"Baybay, Bayugan, Bislig, Cabuyao, Cavite, Davao, Gingoog, Hagonoy, Iligan, Imus, Lapu-Lapu, Mandaluyong, Ozamis, Santa Rosa, Taguig, Talavera, Tanauan, Tanza, Tarlac, Tuguegarao" +Poland,"Bydgoszcz, Czestochowa, Jastrzebie-Zdrj, Kalisz, Lublin, Plock, Tychy, Wroclaw" +Puerto Rico,"Arecibo, Ponce" +Romania,"Botosani, Bucuresti" +Runion,Saint-Denis +Russian Federation,"Atinsk, Balaiha, Dzerzinsk, Elista, Ivanovo, Jaroslavl, Jelets, Kaliningrad, Kamyin, Kirovo-Tepetsk, Kolpino, Korolev, Kurgan, Kursk, Lipetsk, Ljubertsy, Maikop, Moscow, Nabereznyje Telny, Niznekamsk, Novoterkassk, Pjatigorsk, Serpuhov, Smolensk, Syktyvkar" +Saint Vincent and the Grenadines,Kingstown +Saudi Arabia,"Abha, al-Hawiya, al-Qatif, Jedda, Tabuk" +Senegal,Ziguinchor +Slovakia,Bratislava +South Africa,"Boksburg, Botshabelo, Chatsworth, Johannesburg, Kimberley, Klerksdorp, Newcastle, Paarl, Rustenburg, Soshanguve, Springs" +South Korea,"Cheju, Kimchon, Naju, Tonghae, Uijongbu" +Spain,"A Corua (La Corua), Donostia-San Sebastin, Gijn, Ourense (Orense), Santiago de Compostela" +Sri Lanka,Jaffna +Sudan,"al-Qadarif, Omdurman" +Sweden,Malm +Switzerland,"Basel, Bern, Lausanne" +Taiwan,"Changhwa, Chiayi, Chungho, Fengshan, Hsichuh, Lungtan, Nantou, Tanshui, Touliu, Tsaotun" +Tanzania,"Mwanza, Tabora, Zanzibar" +Thailand,"Nakhon Sawan, Pak Kret, Songkhla" +Tonga,Nukualofa +Tunisia,Sousse +Turkey,"Adana, Balikesir, Batman, Denizli, Eskisehir, Gaziantep, Inegl, Kilis, Ktahya, Osmaniye, Sivas, Sultanbeyli, Tarsus, Tokat, Usak" +Turkmenistan,Ashgabat +Tuvalu,Funafuti +Ukraine,"Kamjanets-Podilskyi, Konotop, Mukateve, ostka, Simferopol, Sumy" +United Arab Emirates,"Abu Dhabi, al-Ayn, Sharja" +United Kingdom,"Bradford, Dundee, London, Southampton, Southend-on-Sea, Southport, Stockport, York" +United States,"Akron, Arlington, Augusta-Richmond County, Aurora, Bellevue, Brockton, Cape Coral, Citrus Heights, Clarksville, Compton, Dallas, Dayton, El Monte, Fontana, Garden Grove, Garland, Grand Prairie, Greensboro, Joliet, Kansas City, Lancaster, Laredo, Lincoln, Manchester, Memphis" +Venezuela,"Barcelona, Caracas, Cuman, Maracabo, Ocumare del Tuy, Valencia, Valle de la Pascua" +Vietnam,"Cam Ranh, Haiphong, Hanoi, Nam Dinh, Nha Trang, Vinh" +"Virgin Islands, U.S.",Charlotte Amalie +Yemen,"Aden, Hodeida, Sanaa, Taizz" +Yugoslavia,"Kragujevac, Novi Sad" +Zambia,Kitwe \ No newline at end of file diff --git a/tests/playwright/fixtures/expectedBaseDownloadDataPg.txt b/tests/playwright/fixtures/expectedBaseDownloadDataPg.txt new file mode 100644 index 0000000000..ffce972614 --- /dev/null +++ b/tests/playwright/fixtures/expectedBaseDownloadDataPg.txt @@ -0,0 +1,110 @@ +Country,City List +Afghanistan,Kabul +Algeria,"Batna, Bchar, Skikda" +American Samoa,Tafuna +Angola,"Benguela, Namibe" +Anguilla,South Hill +Argentina,"Almirante Brown, Avellaneda, Baha Blanca, Crdoba, Escobar, Ezeiza, La Plata, Merlo, Quilmes, San Miguel de Tucumn, Santa F, Tandil, Vicente Lpez" +Armenia,Yerevan +Australia,Woodridge +Austria,"Graz, Linz, Salzburg" +Azerbaijan,"Baku, Sumqayit" +Bahrain,al-Manama +Bangladesh,"Dhaka, Jamalpur, Tangail" +Belarus,"Mogiljov, Molodetno" +Bolivia,"El Alto, Sucre" +Brazil,"Alvorada, Angra dos Reis, Anpolis, Aparecida de Goinia, Araatuba, Bag, Belm, Blumenau, Boa Vista, Braslia, Goinia, Guaruj, guas Lindas de Gois, Ibirit, Juazeiro do Norte, Juiz de Fora, Luzinia, Maring, Po, Poos de Caldas, Rio Claro, Santa Brbara dOeste, Santo Andr, So Bernardo do Campo, So Leopoldo" +Brunei,Bandar Seri Begawan +Bulgaria,"Ruse, Stara Zagora" +Cambodia,"Battambang, Phnom Penh" +Cameroon,"Bamenda, Yaound" +Canada,"Gatineau, Halifax, Lethbridge, London, Oshawa, Richmond Hill, Vancouver" +Chad,NDjamna +Chile,"Antofagasta, Coquimbo, Rancagua" +China,"Baicheng, Baiyin, Binzhou, Changzhou, Datong, Daxian, Dongying, Emeishan, Enshi, Ezhou, Fuyu, Fuzhou, Haining, Hami, Hohhot, Huaian, Jinchang, Jining, Jinzhou, Junan, Korla, Laiwu, Laohekou, Lengshuijiang, Leshan" +Colombia,"Buenaventura, Dos Quebradas, Florencia, Pereira, Sincelejo, Sogamoso" +"Congo, The Democratic Republic of the","Lubumbashi, Mwene-Ditu" +Czech Republic,Olomouc +Dominican Republic,"La Romana, San Felipe de Puerto Plata, Santiago de los Caballeros" +Ecuador,"Loja, Portoviejo, Robamba" +Egypt,"Bilbays, Idfu, Mit Ghamr, Qalyub, Sawhaj, Shubra al-Khayma" +Estonia,Tartu +Ethiopia,Addis Abeba +Faroe Islands,Trshavn +Finland,Oulu +France,"Brest, Le Mans, Toulon, Toulouse" +French Guiana,Cayenne +French Polynesia,"Faaa, Papeete" +Gambia,Banjul +Germany,"Duisburg, Erlangen, Halle/Saale, Mannheim, Saarbrcken, Siegen, Witten" +Greece,"Athenai, Patras" +Greenland,Nuuk +Holy See (Vatican City State),Citt del Vaticano +Hong Kong,Kowloon and New Kowloon +Hungary,Szkesfehrvr +India,"Adoni, Ahmadnagar, Allappuzha (Alleppey), Ambattur, Amroha, Balurghat, Berhampore (Baharampur), Bhavnagar, Bhilwara, Bhimavaram, Bhopal, Bhusawal, Bijapur, Chandrapur, Chapra, Dhule (Dhulia), Etawah, Firozabad, Gandhinagar, Gulbarga, Haldia, Halisahar, Hoshiarpur, Hubli-Dharwad, Jaipur" +Indonesia,"Cianjur, Ciomas, Ciparay, Gorontalo, Jakarta, Lhokseumawe, Madiun, Pangkal Pinang, Pemalang, Pontianak, Probolinggo, Purwakarta, Surakarta, Tegal" +Iran,"Arak, Esfahan, Kermanshah, Najafabad, Qomsheh, Shahr-e Kord, Sirjan, Tabriz" +Iraq,Mosul +Israel,"Ashdod, Ashqelon, Bat Yam, Tel Aviv-Jaffa" +Italy,"Alessandria, Bergamo, Brescia, Brindisi, Livorno, Syrakusa, Udine" +Japan,"Akishima, Fukuyama, Higashiosaka, Hino, Hiroshima, Isesaki, Iwaki, Iwakuni, Iwatsuki, Izumisano, Kakamigahara, Kamakura, Kanazawa, Koriyama, Kurashiki, Kuwana, Matsue, Miyakonojo, Nagareyama, Okayama, Okinawa, Omiya, Onomichi, Otsu, Sagamihara" +Kazakstan,"Pavlodar, Zhezqazghan" +Kenya,"Kisumu, Nyeri" +Kuwait,Jalib al-Shuyukh +Latvia,"Daugavpils, Liepaja" +Liechtenstein,Vaduz +Lithuania,Vilnius +Madagascar,Mahajanga +Malawi,Lilongwe +Malaysia,"Ipoh, Kuching, Sungai Petani" +Mexico,"Acua, Allende, Atlixco, Carmen, Celaya, Coacalco de Berriozbal, Coatzacoalcos, Cuauhtmoc, Cuautla, Cuernavaca, El Fuerte, Guadalajara, Hidalgo, Huejutla de Reyes, Huixquilucan, Jos Azueta, Jurez, La Paz, Matamoros, Mexicali, Monclova, Nezahualcyotl, Pachuca de Soto, Salamanca, San Felipe del Progreso" +Moldova,Chisinau +Morocco,"Beni-Mellal, Nador, Sal" +Mozambique,"Beira, Naala-Porto, Tete" +Myanmar,"Monywa, Myingyan" +Nauru,Yangor +Nepal,Birgunj +Netherlands,"Amersfoort, Apeldoorn, Ede, Emmen, s-Hertogenbosch" +New Zealand,Hamilton +Nigeria,"Benin City, Deba Habe, Effon-Alaiye, Ife, Ikerre, Ilorin, Kaduna, Ogbomosho, Ondo, Owo, Oyo, Sokoto, Zaria" +North Korea,Pyongyang +Oman,"Masqat, Salala" +Pakistan,"Dadu, Mandi Bahauddin, Mardan, Okara, Shikarpur" +Paraguay,"Asuncin, Ciudad del Este, San Lorenzo" +Peru,"Callao, Hunuco, Lima, Sullana" +Philippines,"Baybay, Bayugan, Bislig, Cabuyao, Cavite, Davao, Gingoog, Hagonoy, Iligan, Imus, Lapu-Lapu, Mandaluyong, Ozamis, Santa Rosa, Taguig, Talavera, Tanauan, Tanza, Tarlac, Tuguegarao" +Poland,"Bydgoszcz, Czestochowa, Jastrzebie-Zdrj, Kalisz, Lublin, Plock, Tychy, Wroclaw" +Puerto Rico,"Arecibo, Ponce" +Romania,"Botosani, Bucuresti" +Runion,Saint-Denis +Russian Federation,"Atinsk, Balaiha, Dzerzinsk, Elista, Ivanovo, Jaroslavl, Jelets, Kaliningrad, Kamyin, Kirovo-Tepetsk, Kolpino, Korolev, Kurgan, Kursk, Lipetsk, Ljubertsy, Maikop, Moscow, Nabereznyje Telny, Niznekamsk, Novoterkassk, Pjatigorsk, Serpuhov, Smolensk, Syktyvkar" +Saint Vincent and the Grenadines,Kingstown +Saudi Arabia,"Abha, al-Hawiya, al-Qatif, Jedda, Tabuk" +Senegal,Ziguinchor +Slovakia,Bratislava +South Africa,"Boksburg, Botshabelo, Chatsworth, Johannesburg, Kimberley, Klerksdorp, Newcastle, Paarl, Rustenburg, Soshanguve, Springs" +South Korea,"Cheju, Kimchon, Naju, Tonghae, Uijongbu" +Spain,"A Corua (La Corua), Donostia-San Sebastin, Gijn, Ourense (Orense), Santiago de Compostela" +Sri Lanka,Jaffna +Sudan,"al-Qadarif, Omdurman" +Sweden,Malm +Switzerland,"Basel, Bern, Lausanne" +Taiwan,"Changhwa, Chiayi, Chungho, Fengshan, Hsichuh, Lungtan, Nantou, Tanshui, Touliu, Tsaotun" +Tanzania,"Mwanza, Tabora, Zanzibar" +Thailand,"Nakhon Sawan, Pak Kret, Songkhla" +Tonga,Nukualofa +Tunisia,Sousse +Turkey,"Adana, Balikesir, Batman, Denizli, Eskisehir, Gaziantep, Inegl, Kilis, Ktahya, Osmaniye, Sivas, Sultanbeyli, Tarsus, Tokat, Usak" +Turkmenistan,Ashgabat +Tuvalu,Funafuti +Ukraine,"Kamjanets-Podilskyi, Konotop, Mukateve, ostka, Simferopol, Sumy" +United Arab Emirates,"Abu Dhabi, al-Ayn, Sharja" +United Kingdom,"Bradford, Dundee, London, Southampton, Southend-on-Sea, Southport, Stockport, York" +United States,"Akron, Arlington, Augusta-Richmond County, Aurora, Bellevue, Brockton, Cape Coral, Citrus Heights, Clarksville, Compton, Dallas, Dayton, El Monte, Fontana, Garden Grove, Garland, Grand Prairie, Greensboro, Joliet, Kansas City, Lancaster, Laredo, Lincoln, Manchester, Memphis" +Venezuela,"Barcelona, Caracas, Cuman, Maracabo, Ocumare del Tuy, Valencia, Valle de la Pascua" +Vietnam,"Cam Ranh, Haiphong, Hanoi, Nam Dinh, Nha Trang, Vinh" +"Virgin Islands, U.S.",Charlotte Amalie +Yemen,"Aden, Hodeida, Sanaa, Taizz" +Yugoslavia,"Kragujevac, Novi Sad" +Zambia,Kitwe \ No newline at end of file diff --git a/tests/playwright/fixtures/expectedData.txt b/tests/playwright/fixtures/expectedData.txt new file mode 100644 index 0000000000..6de66cde96 --- /dev/null +++ b/tests/playwright/fixtures/expectedData.txt @@ -0,0 +1,4 @@ +Address,District,PostalCode,Phone,Location,Customer List,Staff List,City,Staff List1 +1661 Abha Drive,Tamil Nadu,14400,270456873752,"{""x"":78.8214191,""y"":10.3812871}",1,,Pudukkottai, +1993 Tabuk Lane,Tamil Nadu,64221,648482415405,"{""x"":80.1270701,""y"":12.9246028}",2,,Tambaram, +381 Kabul Way,Taipei,87272,55477302294,"{""x"":0,""y"":0}",2,,Hsichuh, \ No newline at end of file diff --git a/tests/playwright/fixtures/expectedDataSqlite.txt b/tests/playwright/fixtures/expectedDataSqlite.txt new file mode 100644 index 0000000000..cbf8d9cccb --- /dev/null +++ b/tests/playwright/fixtures/expectedDataSqlite.txt @@ -0,0 +1,19 @@ +Address,District,PostalCode,Phone,Customer List,Staff List,City,Staff List1 +1013 Tabuk Boulevard," ",96203," ",2,,Kanchrapara, +1168 Najafabad Parkway," ",40301," ",1,,Kabul, +1294 Firozabad Drive," ",70618," ",2,,Pingxiang, +1342 Abha Boulevard," ",10714," ",2,,Bucuresti, +1368 Maracabo Boulevard," ",32716," ",2,,South Hill, +1427 Tabuk Place," ",31342," ",2,,Cape Coral, +1519 Santiago de los Caballeros Loop," ",22025," ",2,,Mwene-Ditu, +1661 Abha Drive," ",14400," ",1,,Pudukkottai, +17 Kabul Boulevard," ",38594," ",1,,Nagareyama, +1838 Tabriz Lane," ",1195," ",1,,Dhaka, +1888 Kabul Drive," ",20936," ",1,,Ife, +1892 Nabereznyje Telny Lane," ",28396," ",2,,Tafuna, +1993 Tabuk Lane," ",64221," ",2,,Tambaram, +217 Botshabelo Place," ",49521," ",2,,Davao, +381 Kabul Way," ",87272," ",2,,Hsichuh, +44 Najafabad Way," ",61391," ",2,,Donostia-San Sebastin, +48 Maracabo Place," ",1570," ",1,,Talavera, +669 Firozabad Loop," ",92265," ",1,,al-Ayn, \ No newline at end of file diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts b/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts index e5a4b050da..838bf6adbf 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts +++ b/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts @@ -66,11 +66,11 @@ export class ToolbarViewMenuPage extends BasePage { // convert xlsx to csv const wb = XLSX.readFile('./output/test.xlsx'); - XLSX.writeFile(wb, './output/test.csv', { bookType: 'csv' }); + XLSX.writeFile(wb, './output/test.txt', { bookType: 'csv' }); // verify downloaded content against expected content const expectedData = fs.readFileSync(expectedDataFile, 'utf8'); - const file = fs.readFileSync('./output/test.csv', 'utf8'); + const file = fs.readFileSync('./output/test.txt', 'utf8'); await expect(file).toEqual(expectedData); } @@ -94,14 +94,14 @@ export class ToolbarViewMenuPage extends BasePage { downloadLocator: await this.rootPage .locator(`.ant-dropdown-menu-title-content:has-text("${subMenu}")`) .last(), - expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.csv', + expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.txt', }); } else if (subMenu === 'Download as XLSX') { await this.verifyDownloadAsXLSX({ downloadLocator: await this.rootPage .locator(`.ant-dropdown-menu-title-content:has-text("${subMenu}")`) .last(), - expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.csv', + expectedDataFile: verificationInfo?.verificationFile ?? './fixtures/expectedBaseDownloadData.txt', }); } else { await this.rootPage.locator(`.ant-dropdown-menu-title-content:has-text("${subMenu}")`).last().click(); diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/index.ts b/tests/playwright/pages/Dashboard/common/Toolbar/index.ts index f33b6bd1bd..02c1f6bedb 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/index.ts +++ b/tests/playwright/pages/Dashboard/common/Toolbar/index.ts @@ -111,7 +111,7 @@ export class ToolbarPage extends BasePage { await this.get().locator(`.nc-toolbar-btn.nc-add-new-row-btn`).click(); } - async clickDownload(type: string, verificationFile = 'expectedData.csv') { + async clickDownload(type: string, verificationFile = 'expectedData.txt') { await this.get().locator(`.nc-toolbar-btn.nc-actions-menu-btn`).click(); const [download] = await Promise.all([ diff --git a/tests/playwright/tests/viewGridShare.spec.ts b/tests/playwright/tests/viewGridShare.spec.ts index 61b6c1f73c..6e6f82baa5 100644 --- a/tests/playwright/tests/viewGridShare.spec.ts +++ b/tests/playwright/tests/viewGridShare.spec.ts @@ -139,7 +139,7 @@ test.describe('Shared view', () => { // verify download await sharedPage.grid.toolbar.clickDownload( 'Download as CSV', - isSqlite(context) || isPg(context) ? 'expectedDataSqlite.csv' : 'expectedData.csv' + isSqlite(context) || isPg(context) ? 'expectedDataSqlite.txt' : 'expectedData.txt' ); }); diff --git a/tests/playwright/tests/viewMenu.spec.ts b/tests/playwright/tests/viewMenu.spec.ts index 521549c5ae..39ac76bd33 100644 --- a/tests/playwright/tests/viewMenu.spec.ts +++ b/tests/playwright/tests/viewMenu.spec.ts @@ -52,7 +52,7 @@ test.describe('Grid view locked', () => { menu: 'Download', subMenu: 'Download as CSV', verificationInfo: { - verificationFile: isPg(context) ? './fixtures/expectedBaseDownloadDataPg.csv' : null, + verificationFile: isPg(context) ? './fixtures/expectedBaseDownloadDataPg.txt' : null, }, }); }); @@ -72,7 +72,7 @@ test.describe('Grid view locked', () => { menu: 'Download', subMenu: 'Download as XLSX', verificationInfo: { - verificationFile: isPg(context) ? './fixtures/expectedBaseDownloadDataPg.csv' : null, + verificationFile: isPg(context) ? './fixtures/expectedBaseDownloadDataPg.txt' : null, }, }); }); From 1268b42eed6dbc1b4888b9cc7c9e70047ea78cad Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sun, 4 Dec 2022 00:58:24 +0800 Subject: [PATCH 5/8] fix(playwright): CRLF -> LF --- .../fixtures/expectedBaseDownloadDataPg.txt | 218 +++++++++--------- tests/playwright/fixtures/expectedData.txt | 6 +- .../fixtures/expectedDataSqlite.txt | 36 +-- 3 files changed, 130 insertions(+), 130 deletions(-) diff --git a/tests/playwright/fixtures/expectedBaseDownloadDataPg.txt b/tests/playwright/fixtures/expectedBaseDownloadDataPg.txt index ffce972614..36d43c36ba 100644 --- a/tests/playwright/fixtures/expectedBaseDownloadDataPg.txt +++ b/tests/playwright/fixtures/expectedBaseDownloadDataPg.txt @@ -1,110 +1,110 @@ -Country,City List -Afghanistan,Kabul -Algeria,"Batna, Bchar, Skikda" -American Samoa,Tafuna -Angola,"Benguela, Namibe" -Anguilla,South Hill -Argentina,"Almirante Brown, Avellaneda, Baha Blanca, Crdoba, Escobar, Ezeiza, La Plata, Merlo, Quilmes, San Miguel de Tucumn, Santa F, Tandil, Vicente Lpez" -Armenia,Yerevan -Australia,Woodridge -Austria,"Graz, Linz, Salzburg" -Azerbaijan,"Baku, Sumqayit" -Bahrain,al-Manama -Bangladesh,"Dhaka, Jamalpur, Tangail" -Belarus,"Mogiljov, Molodetno" -Bolivia,"El Alto, Sucre" -Brazil,"Alvorada, Angra dos Reis, Anpolis, Aparecida de Goinia, Araatuba, Bag, Belm, Blumenau, Boa Vista, Braslia, Goinia, Guaruj, guas Lindas de Gois, Ibirit, Juazeiro do Norte, Juiz de Fora, Luzinia, Maring, Po, Poos de Caldas, Rio Claro, Santa Brbara dOeste, Santo Andr, So Bernardo do Campo, So Leopoldo" -Brunei,Bandar Seri Begawan -Bulgaria,"Ruse, Stara Zagora" -Cambodia,"Battambang, Phnom Penh" -Cameroon,"Bamenda, Yaound" -Canada,"Gatineau, Halifax, Lethbridge, London, Oshawa, Richmond Hill, Vancouver" -Chad,NDjamna -Chile,"Antofagasta, Coquimbo, Rancagua" -China,"Baicheng, Baiyin, Binzhou, Changzhou, Datong, Daxian, Dongying, Emeishan, Enshi, Ezhou, Fuyu, Fuzhou, Haining, Hami, Hohhot, Huaian, Jinchang, Jining, Jinzhou, Junan, Korla, Laiwu, Laohekou, Lengshuijiang, Leshan" -Colombia,"Buenaventura, Dos Quebradas, Florencia, Pereira, Sincelejo, Sogamoso" -"Congo, The Democratic Republic of the","Lubumbashi, Mwene-Ditu" -Czech Republic,Olomouc -Dominican Republic,"La Romana, San Felipe de Puerto Plata, Santiago de los Caballeros" -Ecuador,"Loja, Portoviejo, Robamba" -Egypt,"Bilbays, Idfu, Mit Ghamr, Qalyub, Sawhaj, Shubra al-Khayma" -Estonia,Tartu -Ethiopia,Addis Abeba -Faroe Islands,Trshavn -Finland,Oulu -France,"Brest, Le Mans, Toulon, Toulouse" -French Guiana,Cayenne -French Polynesia,"Faaa, Papeete" -Gambia,Banjul -Germany,"Duisburg, Erlangen, Halle/Saale, Mannheim, Saarbrcken, Siegen, Witten" -Greece,"Athenai, Patras" -Greenland,Nuuk -Holy See (Vatican City State),Citt del Vaticano -Hong Kong,Kowloon and New Kowloon -Hungary,Szkesfehrvr -India,"Adoni, Ahmadnagar, Allappuzha (Alleppey), Ambattur, Amroha, Balurghat, Berhampore (Baharampur), Bhavnagar, Bhilwara, Bhimavaram, Bhopal, Bhusawal, Bijapur, Chandrapur, Chapra, Dhule (Dhulia), Etawah, Firozabad, Gandhinagar, Gulbarga, Haldia, Halisahar, Hoshiarpur, Hubli-Dharwad, Jaipur" -Indonesia,"Cianjur, Ciomas, Ciparay, Gorontalo, Jakarta, Lhokseumawe, Madiun, Pangkal Pinang, Pemalang, Pontianak, Probolinggo, Purwakarta, Surakarta, Tegal" -Iran,"Arak, Esfahan, Kermanshah, Najafabad, Qomsheh, Shahr-e Kord, Sirjan, Tabriz" -Iraq,Mosul -Israel,"Ashdod, Ashqelon, Bat Yam, Tel Aviv-Jaffa" -Italy,"Alessandria, Bergamo, Brescia, Brindisi, Livorno, Syrakusa, Udine" -Japan,"Akishima, Fukuyama, Higashiosaka, Hino, Hiroshima, Isesaki, Iwaki, Iwakuni, Iwatsuki, Izumisano, Kakamigahara, Kamakura, Kanazawa, Koriyama, Kurashiki, Kuwana, Matsue, Miyakonojo, Nagareyama, Okayama, Okinawa, Omiya, Onomichi, Otsu, Sagamihara" -Kazakstan,"Pavlodar, Zhezqazghan" -Kenya,"Kisumu, Nyeri" -Kuwait,Jalib al-Shuyukh -Latvia,"Daugavpils, Liepaja" -Liechtenstein,Vaduz -Lithuania,Vilnius -Madagascar,Mahajanga -Malawi,Lilongwe -Malaysia,"Ipoh, Kuching, Sungai Petani" -Mexico,"Acua, Allende, Atlixco, Carmen, Celaya, Coacalco de Berriozbal, Coatzacoalcos, Cuauhtmoc, Cuautla, Cuernavaca, El Fuerte, Guadalajara, Hidalgo, Huejutla de Reyes, Huixquilucan, Jos Azueta, Jurez, La Paz, Matamoros, Mexicali, Monclova, Nezahualcyotl, Pachuca de Soto, Salamanca, San Felipe del Progreso" -Moldova,Chisinau -Morocco,"Beni-Mellal, Nador, Sal" -Mozambique,"Beira, Naala-Porto, Tete" -Myanmar,"Monywa, Myingyan" -Nauru,Yangor -Nepal,Birgunj -Netherlands,"Amersfoort, Apeldoorn, Ede, Emmen, s-Hertogenbosch" -New Zealand,Hamilton -Nigeria,"Benin City, Deba Habe, Effon-Alaiye, Ife, Ikerre, Ilorin, Kaduna, Ogbomosho, Ondo, Owo, Oyo, Sokoto, Zaria" -North Korea,Pyongyang -Oman,"Masqat, Salala" -Pakistan,"Dadu, Mandi Bahauddin, Mardan, Okara, Shikarpur" -Paraguay,"Asuncin, Ciudad del Este, San Lorenzo" -Peru,"Callao, Hunuco, Lima, Sullana" -Philippines,"Baybay, Bayugan, Bislig, Cabuyao, Cavite, Davao, Gingoog, Hagonoy, Iligan, Imus, Lapu-Lapu, Mandaluyong, Ozamis, Santa Rosa, Taguig, Talavera, Tanauan, Tanza, Tarlac, Tuguegarao" -Poland,"Bydgoszcz, Czestochowa, Jastrzebie-Zdrj, Kalisz, Lublin, Plock, Tychy, Wroclaw" -Puerto Rico,"Arecibo, Ponce" -Romania,"Botosani, Bucuresti" -Runion,Saint-Denis -Russian Federation,"Atinsk, Balaiha, Dzerzinsk, Elista, Ivanovo, Jaroslavl, Jelets, Kaliningrad, Kamyin, Kirovo-Tepetsk, Kolpino, Korolev, Kurgan, Kursk, Lipetsk, Ljubertsy, Maikop, Moscow, Nabereznyje Telny, Niznekamsk, Novoterkassk, Pjatigorsk, Serpuhov, Smolensk, Syktyvkar" -Saint Vincent and the Grenadines,Kingstown -Saudi Arabia,"Abha, al-Hawiya, al-Qatif, Jedda, Tabuk" -Senegal,Ziguinchor -Slovakia,Bratislava -South Africa,"Boksburg, Botshabelo, Chatsworth, Johannesburg, Kimberley, Klerksdorp, Newcastle, Paarl, Rustenburg, Soshanguve, Springs" -South Korea,"Cheju, Kimchon, Naju, Tonghae, Uijongbu" -Spain,"A Corua (La Corua), Donostia-San Sebastin, Gijn, Ourense (Orense), Santiago de Compostela" -Sri Lanka,Jaffna -Sudan,"al-Qadarif, Omdurman" -Sweden,Malm -Switzerland,"Basel, Bern, Lausanne" -Taiwan,"Changhwa, Chiayi, Chungho, Fengshan, Hsichuh, Lungtan, Nantou, Tanshui, Touliu, Tsaotun" -Tanzania,"Mwanza, Tabora, Zanzibar" -Thailand,"Nakhon Sawan, Pak Kret, Songkhla" -Tonga,Nukualofa -Tunisia,Sousse -Turkey,"Adana, Balikesir, Batman, Denizli, Eskisehir, Gaziantep, Inegl, Kilis, Ktahya, Osmaniye, Sivas, Sultanbeyli, Tarsus, Tokat, Usak" -Turkmenistan,Ashgabat -Tuvalu,Funafuti -Ukraine,"Kamjanets-Podilskyi, Konotop, Mukateve, ostka, Simferopol, Sumy" -United Arab Emirates,"Abu Dhabi, al-Ayn, Sharja" -United Kingdom,"Bradford, Dundee, London, Southampton, Southend-on-Sea, Southport, Stockport, York" -United States,"Akron, Arlington, Augusta-Richmond County, Aurora, Bellevue, Brockton, Cape Coral, Citrus Heights, Clarksville, Compton, Dallas, Dayton, El Monte, Fontana, Garden Grove, Garland, Grand Prairie, Greensboro, Joliet, Kansas City, Lancaster, Laredo, Lincoln, Manchester, Memphis" -Venezuela,"Barcelona, Caracas, Cuman, Maracabo, Ocumare del Tuy, Valencia, Valle de la Pascua" -Vietnam,"Cam Ranh, Haiphong, Hanoi, Nam Dinh, Nha Trang, Vinh" -"Virgin Islands, U.S.",Charlotte Amalie -Yemen,"Aden, Hodeida, Sanaa, Taizz" -Yugoslavia,"Kragujevac, Novi Sad" +Country,City List +Afghanistan,Kabul +Algeria,"Batna, Bchar, Skikda" +American Samoa,Tafuna +Angola,"Benguela, Namibe" +Anguilla,South Hill +Argentina,"Almirante Brown, Avellaneda, Baha Blanca, Crdoba, Escobar, Ezeiza, La Plata, Merlo, Quilmes, San Miguel de Tucumn, Santa F, Tandil, Vicente Lpez" +Armenia,Yerevan +Australia,Woodridge +Austria,"Graz, Linz, Salzburg" +Azerbaijan,"Baku, Sumqayit" +Bahrain,al-Manama +Bangladesh,"Dhaka, Jamalpur, Tangail" +Belarus,"Mogiljov, Molodetno" +Bolivia,"El Alto, Sucre" +Brazil,"Alvorada, Angra dos Reis, Anpolis, Aparecida de Goinia, Araatuba, Bag, Belm, Blumenau, Boa Vista, Braslia, Goinia, Guaruj, guas Lindas de Gois, Ibirit, Juazeiro do Norte, Juiz de Fora, Luzinia, Maring, Po, Poos de Caldas, Rio Claro, Santa Brbara dOeste, Santo Andr, So Bernardo do Campo, So Leopoldo" +Brunei,Bandar Seri Begawan +Bulgaria,"Ruse, Stara Zagora" +Cambodia,"Battambang, Phnom Penh" +Cameroon,"Bamenda, Yaound" +Canada,"Gatineau, Halifax, Lethbridge, London, Oshawa, Richmond Hill, Vancouver" +Chad,NDjamna +Chile,"Antofagasta, Coquimbo, Rancagua" +China,"Baicheng, Baiyin, Binzhou, Changzhou, Datong, Daxian, Dongying, Emeishan, Enshi, Ezhou, Fuyu, Fuzhou, Haining, Hami, Hohhot, Huaian, Jinchang, Jining, Jinzhou, Junan, Korla, Laiwu, Laohekou, Lengshuijiang, Leshan" +Colombia,"Buenaventura, Dos Quebradas, Florencia, Pereira, Sincelejo, Sogamoso" +"Congo, The Democratic Republic of the","Lubumbashi, Mwene-Ditu" +Czech Republic,Olomouc +Dominican Republic,"La Romana, San Felipe de Puerto Plata, Santiago de los Caballeros" +Ecuador,"Loja, Portoviejo, Robamba" +Egypt,"Bilbays, Idfu, Mit Ghamr, Qalyub, Sawhaj, Shubra al-Khayma" +Estonia,Tartu +Ethiopia,Addis Abeba +Faroe Islands,Trshavn +Finland,Oulu +France,"Brest, Le Mans, Toulon, Toulouse" +French Guiana,Cayenne +French Polynesia,"Faaa, Papeete" +Gambia,Banjul +Germany,"Duisburg, Erlangen, Halle/Saale, Mannheim, Saarbrcken, Siegen, Witten" +Greece,"Athenai, Patras" +Greenland,Nuuk +Holy See (Vatican City State),Citt del Vaticano +Hong Kong,Kowloon and New Kowloon +Hungary,Szkesfehrvr +India,"Adoni, Ahmadnagar, Allappuzha (Alleppey), Ambattur, Amroha, Balurghat, Berhampore (Baharampur), Bhavnagar, Bhilwara, Bhimavaram, Bhopal, Bhusawal, Bijapur, Chandrapur, Chapra, Dhule (Dhulia), Etawah, Firozabad, Gandhinagar, Gulbarga, Haldia, Halisahar, Hoshiarpur, Hubli-Dharwad, Jaipur" +Indonesia,"Cianjur, Ciomas, Ciparay, Gorontalo, Jakarta, Lhokseumawe, Madiun, Pangkal Pinang, Pemalang, Pontianak, Probolinggo, Purwakarta, Surakarta, Tegal" +Iran,"Arak, Esfahan, Kermanshah, Najafabad, Qomsheh, Shahr-e Kord, Sirjan, Tabriz" +Iraq,Mosul +Israel,"Ashdod, Ashqelon, Bat Yam, Tel Aviv-Jaffa" +Italy,"Alessandria, Bergamo, Brescia, Brindisi, Livorno, Syrakusa, Udine" +Japan,"Akishima, Fukuyama, Higashiosaka, Hino, Hiroshima, Isesaki, Iwaki, Iwakuni, Iwatsuki, Izumisano, Kakamigahara, Kamakura, Kanazawa, Koriyama, Kurashiki, Kuwana, Matsue, Miyakonojo, Nagareyama, Okayama, Okinawa, Omiya, Onomichi, Otsu, Sagamihara" +Kazakstan,"Pavlodar, Zhezqazghan" +Kenya,"Kisumu, Nyeri" +Kuwait,Jalib al-Shuyukh +Latvia,"Daugavpils, Liepaja" +Liechtenstein,Vaduz +Lithuania,Vilnius +Madagascar,Mahajanga +Malawi,Lilongwe +Malaysia,"Ipoh, Kuching, Sungai Petani" +Mexico,"Acua, Allende, Atlixco, Carmen, Celaya, Coacalco de Berriozbal, Coatzacoalcos, Cuauhtmoc, Cuautla, Cuernavaca, El Fuerte, Guadalajara, Hidalgo, Huejutla de Reyes, Huixquilucan, Jos Azueta, Jurez, La Paz, Matamoros, Mexicali, Monclova, Nezahualcyotl, Pachuca de Soto, Salamanca, San Felipe del Progreso" +Moldova,Chisinau +Morocco,"Beni-Mellal, Nador, Sal" +Mozambique,"Beira, Naala-Porto, Tete" +Myanmar,"Monywa, Myingyan" +Nauru,Yangor +Nepal,Birgunj +Netherlands,"Amersfoort, Apeldoorn, Ede, Emmen, s-Hertogenbosch" +New Zealand,Hamilton +Nigeria,"Benin City, Deba Habe, Effon-Alaiye, Ife, Ikerre, Ilorin, Kaduna, Ogbomosho, Ondo, Owo, Oyo, Sokoto, Zaria" +North Korea,Pyongyang +Oman,"Masqat, Salala" +Pakistan,"Dadu, Mandi Bahauddin, Mardan, Okara, Shikarpur" +Paraguay,"Asuncin, Ciudad del Este, San Lorenzo" +Peru,"Callao, Hunuco, Lima, Sullana" +Philippines,"Baybay, Bayugan, Bislig, Cabuyao, Cavite, Davao, Gingoog, Hagonoy, Iligan, Imus, Lapu-Lapu, Mandaluyong, Ozamis, Santa Rosa, Taguig, Talavera, Tanauan, Tanza, Tarlac, Tuguegarao" +Poland,"Bydgoszcz, Czestochowa, Jastrzebie-Zdrj, Kalisz, Lublin, Plock, Tychy, Wroclaw" +Puerto Rico,"Arecibo, Ponce" +Romania,"Botosani, Bucuresti" +Runion,Saint-Denis +Russian Federation,"Atinsk, Balaiha, Dzerzinsk, Elista, Ivanovo, Jaroslavl, Jelets, Kaliningrad, Kamyin, Kirovo-Tepetsk, Kolpino, Korolev, Kurgan, Kursk, Lipetsk, Ljubertsy, Maikop, Moscow, Nabereznyje Telny, Niznekamsk, Novoterkassk, Pjatigorsk, Serpuhov, Smolensk, Syktyvkar" +Saint Vincent and the Grenadines,Kingstown +Saudi Arabia,"Abha, al-Hawiya, al-Qatif, Jedda, Tabuk" +Senegal,Ziguinchor +Slovakia,Bratislava +South Africa,"Boksburg, Botshabelo, Chatsworth, Johannesburg, Kimberley, Klerksdorp, Newcastle, Paarl, Rustenburg, Soshanguve, Springs" +South Korea,"Cheju, Kimchon, Naju, Tonghae, Uijongbu" +Spain,"A Corua (La Corua), Donostia-San Sebastin, Gijn, Ourense (Orense), Santiago de Compostela" +Sri Lanka,Jaffna +Sudan,"al-Qadarif, Omdurman" +Sweden,Malm +Switzerland,"Basel, Bern, Lausanne" +Taiwan,"Changhwa, Chiayi, Chungho, Fengshan, Hsichuh, Lungtan, Nantou, Tanshui, Touliu, Tsaotun" +Tanzania,"Mwanza, Tabora, Zanzibar" +Thailand,"Nakhon Sawan, Pak Kret, Songkhla" +Tonga,Nukualofa +Tunisia,Sousse +Turkey,"Adana, Balikesir, Batman, Denizli, Eskisehir, Gaziantep, Inegl, Kilis, Ktahya, Osmaniye, Sivas, Sultanbeyli, Tarsus, Tokat, Usak" +Turkmenistan,Ashgabat +Tuvalu,Funafuti +Ukraine,"Kamjanets-Podilskyi, Konotop, Mukateve, ostka, Simferopol, Sumy" +United Arab Emirates,"Abu Dhabi, al-Ayn, Sharja" +United Kingdom,"Bradford, Dundee, London, Southampton, Southend-on-Sea, Southport, Stockport, York" +United States,"Akron, Arlington, Augusta-Richmond County, Aurora, Bellevue, Brockton, Cape Coral, Citrus Heights, Clarksville, Compton, Dallas, Dayton, El Monte, Fontana, Garden Grove, Garland, Grand Prairie, Greensboro, Joliet, Kansas City, Lancaster, Laredo, Lincoln, Manchester, Memphis" +Venezuela,"Barcelona, Caracas, Cuman, Maracabo, Ocumare del Tuy, Valencia, Valle de la Pascua" +Vietnam,"Cam Ranh, Haiphong, Hanoi, Nam Dinh, Nha Trang, Vinh" +"Virgin Islands, U.S.",Charlotte Amalie +Yemen,"Aden, Hodeida, Sanaa, Taizz" +Yugoslavia,"Kragujevac, Novi Sad" Zambia,Kitwe \ No newline at end of file diff --git a/tests/playwright/fixtures/expectedData.txt b/tests/playwright/fixtures/expectedData.txt index 6de66cde96..8e6d239482 100644 --- a/tests/playwright/fixtures/expectedData.txt +++ b/tests/playwright/fixtures/expectedData.txt @@ -1,4 +1,4 @@ -Address,District,PostalCode,Phone,Location,Customer List,Staff List,City,Staff List1 -1661 Abha Drive,Tamil Nadu,14400,270456873752,"{""x"":78.8214191,""y"":10.3812871}",1,,Pudukkottai, -1993 Tabuk Lane,Tamil Nadu,64221,648482415405,"{""x"":80.1270701,""y"":12.9246028}",2,,Tambaram, +Address,District,PostalCode,Phone,Location,Customer List,Staff List,City,Staff List1 +1661 Abha Drive,Tamil Nadu,14400,270456873752,"{""x"":78.8214191,""y"":10.3812871}",1,,Pudukkottai, +1993 Tabuk Lane,Tamil Nadu,64221,648482415405,"{""x"":80.1270701,""y"":12.9246028}",2,,Tambaram, 381 Kabul Way,Taipei,87272,55477302294,"{""x"":0,""y"":0}",2,,Hsichuh, \ No newline at end of file diff --git a/tests/playwright/fixtures/expectedDataSqlite.txt b/tests/playwright/fixtures/expectedDataSqlite.txt index cbf8d9cccb..188590b915 100644 --- a/tests/playwright/fixtures/expectedDataSqlite.txt +++ b/tests/playwright/fixtures/expectedDataSqlite.txt @@ -1,19 +1,19 @@ -Address,District,PostalCode,Phone,Customer List,Staff List,City,Staff List1 -1013 Tabuk Boulevard," ",96203," ",2,,Kanchrapara, -1168 Najafabad Parkway," ",40301," ",1,,Kabul, -1294 Firozabad Drive," ",70618," ",2,,Pingxiang, -1342 Abha Boulevard," ",10714," ",2,,Bucuresti, -1368 Maracabo Boulevard," ",32716," ",2,,South Hill, -1427 Tabuk Place," ",31342," ",2,,Cape Coral, -1519 Santiago de los Caballeros Loop," ",22025," ",2,,Mwene-Ditu, -1661 Abha Drive," ",14400," ",1,,Pudukkottai, -17 Kabul Boulevard," ",38594," ",1,,Nagareyama, -1838 Tabriz Lane," ",1195," ",1,,Dhaka, -1888 Kabul Drive," ",20936," ",1,,Ife, -1892 Nabereznyje Telny Lane," ",28396," ",2,,Tafuna, -1993 Tabuk Lane," ",64221," ",2,,Tambaram, -217 Botshabelo Place," ",49521," ",2,,Davao, -381 Kabul Way," ",87272," ",2,,Hsichuh, -44 Najafabad Way," ",61391," ",2,,Donostia-San Sebastin, -48 Maracabo Place," ",1570," ",1,,Talavera, +Address,District,PostalCode,Phone,Customer List,Staff List,City,Staff List1 +1013 Tabuk Boulevard," ",96203," ",2,,Kanchrapara, +1168 Najafabad Parkway," ",40301," ",1,,Kabul, +1294 Firozabad Drive," ",70618," ",2,,Pingxiang, +1342 Abha Boulevard," ",10714," ",2,,Bucuresti, +1368 Maracabo Boulevard," ",32716," ",2,,South Hill, +1427 Tabuk Place," ",31342," ",2,,Cape Coral, +1519 Santiago de los Caballeros Loop," ",22025," ",2,,Mwene-Ditu, +1661 Abha Drive," ",14400," ",1,,Pudukkottai, +17 Kabul Boulevard," ",38594," ",1,,Nagareyama, +1838 Tabriz Lane," ",1195," ",1,,Dhaka, +1888 Kabul Drive," ",20936," ",1,,Ife, +1892 Nabereznyje Telny Lane," ",28396," ",2,,Tafuna, +1993 Tabuk Lane," ",64221," ",2,,Tambaram, +217 Botshabelo Place," ",49521," ",2,,Davao, +381 Kabul Way," ",87272," ",2,,Hsichuh, +44 Najafabad Way," ",61391," ",2,,Donostia-San Sebastin, +48 Maracabo Place," ",1570," ",1,,Talavera, 669 Firozabad Loop," ",92265," ",1,,al-Ayn, \ No newline at end of file From 0bb221760e71efc06ec95b0635757986831a897b Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sun, 4 Dec 2022 01:12:32 +0800 Subject: [PATCH 6/8] fix(playwright): change to UTF-8 --- tests/playwright/fixtures/expectedBaseDownloadData.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/playwright/fixtures/expectedBaseDownloadData.txt b/tests/playwright/fixtures/expectedBaseDownloadData.txt index 9002600ee2..36d43c36ba 100644 --- a/tests/playwright/fixtures/expectedBaseDownloadData.txt +++ b/tests/playwright/fixtures/expectedBaseDownloadData.txt @@ -1,4 +1,4 @@ -Country,City List +Country,City List Afghanistan,Kabul Algeria,"Batna, Bchar, Skikda" American Samoa,Tafuna From 3e90051885ef3ac4ecf51c818214af0c0368d29c Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sun, 4 Dec 2022 01:15:00 +0800 Subject: [PATCH 7/8] fix(playwright): export test --- .../pages/Dashboard/common/Toolbar/ViewMenu.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts b/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts index 838bf6adbf..508e958be9 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts +++ b/tests/playwright/pages/Dashboard/common/Toolbar/ViewMenu.ts @@ -39,11 +39,11 @@ export class ToolbarViewMenuPage extends BasePage { ]); // Save downloaded file somewhere - await download.saveAs('./output/at.txt'); + await download.saveAs('./output/test.txt'); // verify downloaded content against expected content - const expectedData = fs.readFileSync(expectedDataFile, 'utf8'); - const file = fs.readFileSync('./output/at.txt', 'utf8'); + const expectedData = fs.readFileSync(expectedDataFile, 'utf8').replace(/\r/g, '').split('\n'); + const file = fs.readFileSync('./output/test.txt', 'utf8').replace(/\r/g, '').split('\n'); await expect(file).toEqual(expectedData); } @@ -71,7 +71,8 @@ export class ToolbarViewMenuPage extends BasePage { // verify downloaded content against expected content const expectedData = fs.readFileSync(expectedDataFile, 'utf8'); const file = fs.readFileSync('./output/test.txt', 'utf8'); - await expect(file).toEqual(expectedData); + // XLSX writes file with UTF-8 BOM, adds '\ufeff' to cater it + await expect(file).toEqual('\ufeff' + expectedData); } // menu items From acbcc1477131a9583182bccaf1b7361d0689bcb4 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sun, 4 Dec 2022 11:55:56 +0800 Subject: [PATCH 8/8] fix(playwright): remove \r --- tests/playwright/pages/Dashboard/common/Toolbar/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/playwright/pages/Dashboard/common/Toolbar/index.ts b/tests/playwright/pages/Dashboard/common/Toolbar/index.ts index 02c1f6bedb..c97c263051 100644 --- a/tests/playwright/pages/Dashboard/common/Toolbar/index.ts +++ b/tests/playwright/pages/Dashboard/common/Toolbar/index.ts @@ -128,8 +128,8 @@ export class ToolbarPage extends BasePage { await download.saveAs('./output/at.txt'); // verify downloaded content against expected content - const expectedData = fs.readFileSync(`./fixtures/${verificationFile}`, 'utf8'); - const file = fs.readFileSync('./output/at.txt', 'utf8'); + const expectedData = fs.readFileSync(`./fixtures/${verificationFile}`, 'utf8').replace(/\r/g, '').split('\n'); + const file = fs.readFileSync('./output/at.txt', 'utf8').replace(/\r/g, '').split('\n'); await expect(file).toEqual(expectedData); }