Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

remove sekila from get list data api v3

Fendy Heryantocd342ede32dd
diff --git a/packages/nocodb/tests/unit/init/index.ts b/packages/nocodb/tests/unit/init/index.ts
index a6aa343174..d580d4b06c 100644
--- a/packages/nocodb/tests/unit/init/index.ts
+++ b/packages/nocodb/tests/unit/init/index.ts
@@ -5,6 +5,7 @@ import nocobuild from '../../../src/nocobuild';
import { createUser } from '../factory/user';
import cleanupMeta from './cleanupMeta';
import { cleanUpSakila, resetAndSeedSakila } from './cleanupSakila';
+import type { Base } from '../../../src/models';
import type { INestApplication } from '@nestjs/common';
let server;
@@ -28,7 +29,7 @@ const serverInit = async () => {
const isFirstTimeRun = () => !server;
-export default async function (forceReset = false, roles = 'editor') {
+export default async function init(forceReset = false, roles = 'editor') {
const { default: TestDbMngr } = await import('../TestDbMngr');
if (isFirstTimeRun()) {
@@ -82,3 +83,14 @@ export default async function (forceReset = false, roles = 'editor') {
...extra,
};
}
+
+export type IInitContext = Awaited<ReturnType<typeof init>>;
+
+export interface ITestContext {
+ context: IInitContext;
+ ctx: {
+ workspace_id: any;
+ base_id: any;
+ };
+ base: Base;
+}
diff --git a/packages/nocodb/tests/unit/init/initTblCountry.ts b/packages/nocodb/tests/unit/init/initTblCountry.ts
new file mode 100644
index 0000000000..e361218c02
--- /dev/null
+++ b/packages/nocodb/tests/unit/init/initTblCountry.ts
@@ -0,0 +1,627 @@
+import { UITypes } from 'nocodb-sdk';
+import { createTable } from '../factory/table';
+import { createBulkRows } from '../factory/row';
+import { createLtarColumn } from '../factory/column';
+import { ncAxios } from '../utils/ncAxios';
+import type { IInitContext } from './index';
+import type { Base } from '../../../src/models';
+
+const countries = [
+ 'Afghanistan',
+ 'Algeria',
+ 'American Samoa',
+ 'Angola',
+ 'Anguilla',
+ 'Argentina',
+ 'Armenia',
+ 'Australia',
+ 'Austria',
+ 'Azerbaijan',
+ 'Bahrain',
+ 'Bangladesh',
+ 'Belarus',
+ 'Bolivia',
+ 'Brazil',
+ 'Brunei',
+ 'Bulgaria',
+ 'Cambodia',
+ 'Cameroon',
+ 'Canada',
+ 'Chad',
+ 'Chile',
+ 'China',
+ 'Colombia',
+ 'Congo, The Democratic Republic of the',
+ 'Czech Republic',
+ 'Dominican Republic',
+ 'Ecuador',
+ 'Egypt',
+ 'Estonia',
+ 'Ethiopia',
+ 'Faroe Islands',
+ 'Finland',
+ 'France',
+ 'French Guiana',
+ 'French Polynesia',
+ 'Gambia',
+ 'Germany',
+ 'Greece',
+ 'Greenland',
+ 'Holy See (Vatican City State)',
+ 'Hong Kong',
+ 'Hungary',
+ 'India',
+ 'Indonesia',
+ 'Iran',
+ 'Iraq',
+ 'Israel',
+ 'Italy',
+ 'Japan',
+ 'Kazakstan',
+ 'Kenya',
+ 'Kuwait',
+ 'Latvia',
+ 'Liechtenstein',
+ 'Lithuania',
+ 'Madagascar',
+ 'Malawi',
+ 'Malaysia',
+ 'Mexico',
+ 'Moldova',
+ 'Morocco',
+ 'Mozambique',
+ 'Myanmar',
+ 'Nauru',
+ 'Nepal',
+ 'Netherlands',
+ 'New Zealand',
+ 'Nigeria',
+ 'North Korea',
+ 'Oman',
+ 'Pakistan',
+ 'Paraguay',
+ 'Peru',
+ 'Philippines',
+ 'Poland',
+ 'Puerto Rico',
+ 'Romania',
+ 'Runion',
+ 'Russian Federation',
+ 'Saint Vincent and the Grenadines',
+ 'Saudi Arabia',
+ 'Senegal',
+ 'Slovakia',
+ 'South Africa',
+ 'South Korea',
+ 'Spain',
+ 'Sri Lanka',
+ 'Sudan',
+ 'Sweden',
+ 'Switzerland',
+ 'Taiwan',
+ 'Tanzania',
+ 'Thailand',
+ 'Tonga',
+ 'Tunisia',
+ 'Turkey',
+ 'Turkmenistan',
+ 'Tuvalu',
+ 'Ukraine',
+ 'United Arab Emirates',
+ 'United Kingdom',
+ 'United States',
+ 'Venezuela',
+ 'Vietnam',
+ 'Virgin Islands, U.S.',
+ 'Yemen',
+ 'Yugoslavia',
+ 'Zambia',
+];
+
+const cities = [
+ { City: 'A Corua (La Corua)', CountryId: '87' },
+ { City: 'Abha', CountryId: '82' },
+ { City: 'Abu Dhabi', CountryId: '101' },
+ { City: 'Acua', CountryId: '60' },
+ { City: 'Adana', CountryId: '97' },
+ { City: 'Addis Abeba', CountryId: '31' },
+ { City: 'Aden', CountryId: '107' },
+ { City: 'Adoni', CountryId: '44' },
+ { City: 'Ahmadnagar', CountryId: '44' },
+ { City: 'Akishima', CountryId: '50' },
+ { City: 'Akron', CountryId: '103' },
+ { City: 'al-Ayn', CountryId: '101' },
+ { City: 'al-Hawiya', CountryId: '82' },
+ { City: 'al-Manama', CountryId: '11' },
+ { City: 'al-Qadarif', CountryId: '89' },
+ { City: 'al-Qatif', CountryId: '82' },
+ { City: 'Alessandria', CountryId: '49' },
+ { City: 'Allappuzha (Alleppey)', CountryId: '44' },
+ { City: 'Allende', CountryId: '60' },
+ { City: 'Almirante Brown', CountryId: '6' },
+ { City: 'Alvorada', CountryId: '15' },
+ { City: 'Ambattur', CountryId: '44' },
+ { City: 'Amersfoort', CountryId: '67' },
+ { City: 'Amroha', CountryId: '44' },
+ { City: 'Angra dos Reis', CountryId: '15' },
+ { City: 'Anpolis', CountryId: '15' },
+ { City: 'Antofagasta', CountryId: '22' },
+ { City: 'Aparecida de Goinia', CountryId: '15' },
+ { City: 'Apeldoorn', CountryId: '67' },
+ { City: 'Araatuba', CountryId: '15' },
+ { City: 'Arak', CountryId: '46' },
+ { City: 'Arecibo', CountryId: '77' },
+ { City: 'Arlington', CountryId: '103' },
+ { City: 'Ashdod', CountryId: '48' },
+ { City: 'Ashgabat', CountryId: '98' },
+ { City: 'Ashqelon', CountryId: '48' },
+ { City: 'Asuncin', CountryId: '73' },
+ { City: 'Athenai', CountryId: '39' },
+ { City: 'Atinsk', CountryId: '80' },
+ { City: 'Atlixco', CountryId: '60' },
+ { City: 'Augusta-Richmond County', CountryId: '103' },
+ { City: 'Aurora', CountryId: '103' },
+ { City: 'Avellaneda', CountryId: '6' },
+ { City: 'Bag', CountryId: '15' },
+ { City: 'Baha Blanca', CountryId: '6' },
+ { City: 'Baicheng', CountryId: '23' },
+ { City: 'Baiyin', CountryId: '23' },
+ { City: 'Baku', CountryId: '10' },
+ { City: 'Balaiha', CountryId: '80' },
+ { City: 'Balikesir', CountryId: '97' },
+ { City: 'Balurghat', CountryId: '44' },
+ { City: 'Bamenda', CountryId: '19' },
+ { City: 'Bandar Seri Begawan', CountryId: '16' },
+ { City: 'Banjul', CountryId: '37' },
+ { City: 'Barcelona', CountryId: '104' },
+ { City: 'Basel', CountryId: '91' },
+ { City: 'Bat Yam', CountryId: '48' },
+ { City: 'Batman', CountryId: '97' },
+ { City: 'Batna', CountryId: '2' },
+ { City: 'Battambang', CountryId: '18' },
+ { City: 'Baybay', CountryId: '75' },
+ { City: 'Bayugan', CountryId: '75' },
+ { City: 'Bchar', CountryId: '2' },
+ { City: 'Beira', CountryId: '63' },
+ { City: 'Bellevue', CountryId: '103' },
+ { City: 'Belm', CountryId: '15' },
+ { City: 'Benguela', CountryId: '4' },
+ { City: 'Beni-Mellal', CountryId: '62' },
+ { City: 'Benin City', CountryId: '69' },
+ { City: 'Bergamo', CountryId: '49' },
+ { City: 'Berhampore (Baharampur)', CountryId: '44' },
+ { City: 'Bern', CountryId: '91' },
+ { City: 'Bhavnagar', CountryId: '44' },
+ { City: 'Bhilwara', CountryId: '44' },
+ { City: 'Bhimavaram', CountryId: '44' },
+ { City: 'Bhopal', CountryId: '44' },
+ { City: 'Bhusawal', CountryId: '44' },
+ { City: 'Bijapur', CountryId: '44' },
+ { City: 'Bilbays', CountryId: '29' },
+ { City: 'Binzhou', CountryId: '23' },
+ { City: 'Birgunj', CountryId: '66' },
+ { City: 'Bislig', CountryId: '75' },
+ { City: 'Blumenau', CountryId: '15' },
+ { City: 'Boa Vista', CountryId: '15' },
+ { City: 'Boksburg', CountryId: '85' },
+ { City: 'Botosani', CountryId: '78' },
+ { City: 'Botshabelo', CountryId: '85' },
+ { City: 'Bradford', CountryId: '102' },
+ { City: 'Braslia', CountryId: '15' },
+ { City: 'Bratislava', CountryId: '84' },
+ { City: 'Brescia', CountryId: '49' },
+ { City: 'Brest', CountryId: '34' },
+ { City: 'Brindisi', CountryId: '49' },
+ { City: 'Brockton', CountryId: '103' },
+ { City: 'Bucuresti', CountryId: '78' },
+ { City: 'Buenaventura', CountryId: '24' },
+ { City: 'Bydgoszcz', CountryId: '76' },
+ { City: 'Cabuyao', CountryId: '75' },
+ { City: 'Callao', CountryId: '74' },
+ { City: 'Cam Ranh', CountryId: '105' },
+ { City: 'Cape Coral', CountryId: '103' },
+ { City: 'Caracas', CountryId: '104' },
+ { City: 'Carmen', CountryId: '60' },
+ { City: 'Cavite', CountryId: '75' },
+ { City: 'Cayenne', CountryId: '35' },
+ { City: 'Celaya', CountryId: '60' },
+ { City: 'Chandrapur', CountryId: '44' },
+ { City: 'Changhwa', CountryId: '92' },
+ { City: 'Changzhou', CountryId: '23' },
+ { City: 'Chapra', CountryId: '44' },
+ { City: 'Charlotte Amalie', CountryId: '106' },
+ { City: 'Chatsworth', CountryId: '85' },
+ { City: 'Cheju', CountryId: '86' },
+ { City: 'Chiayi', CountryId: '92' },
+ { City: 'Chisinau', CountryId: '61' },
+ { City: 'Chungho', CountryId: '92' },
+ { City: 'Cianjur', CountryId: '45' },
+ { City: 'Ciomas', CountryId: '45' },
+ { City: 'Ciparay', CountryId: '45' },
+ { City: 'Citrus Heights', CountryId: '103' },
+ { City: 'Citt del Vaticano', CountryId: '41' },
+ { City: 'Ciudad del Este', CountryId: '73' },
+ { City: 'Clarksville', CountryId: '103' },
+ { City: 'Coacalco de Berriozbal', CountryId: '60' },
+ { City: 'Coatzacoalcos', CountryId: '60' },
+ { City: 'Compton', CountryId: '103' },
+ { City: 'Coquimbo', CountryId: '22' },
+ { City: 'Crdoba', CountryId: '6' },
+ { City: 'Cuauhtmoc', CountryId: '60' },
+ { City: 'Cuautla', CountryId: '60' },
+ { City: 'Cuernavaca', CountryId: '60' },
+ { City: 'Cuman', CountryId: '104' },
+ { City: 'Czestochowa', CountryId: '76' },
+ { City: 'Dadu', CountryId: '72' },
+ { City: 'Dallas', CountryId: '103' },
+ { City: 'Datong', CountryId: '23' },
+ { City: 'Daugavpils', CountryId: '54' },
+ { City: 'Davao', CountryId: '75' },
+ { City: 'Daxian', CountryId: '23' },
+ { City: 'Dayton', CountryId: '103' },
+ { City: 'Deba Habe', CountryId: '69' },
+ { City: 'Denizli', CountryId: '97' },
+ { City: 'Dhaka', CountryId: '12' },
+ { City: 'Dhule (Dhulia)', CountryId: '44' },
+ { City: 'Dongying', CountryId: '23' },
+ { City: 'Donostia-San Sebastin', CountryId: '87' },
+ { City: 'Dos Quebradas', CountryId: '24' },
+ { City: 'Duisburg', CountryId: '38' },
+ { City: 'Dundee', CountryId: '102' },
+ { City: 'Dzerzinsk', CountryId: '80' },
+ { City: 'Ede', CountryId: '67' },
+ { City: 'Effon-Alaiye', CountryId: '69' },
+ { City: 'El Alto', CountryId: '14' },
+ { City: 'El Fuerte', CountryId: '60' },
+ { City: 'El Monte', CountryId: '103' },
+ { City: 'Elista', CountryId: '80' },
+ { City: 'Emeishan', CountryId: '23' },
+ { City: 'Emmen', CountryId: '67' },
+ { City: 'Enshi', CountryId: '23' },
+ { City: 'Erlangen', CountryId: '38' },
+ { City: 'Escobar', CountryId: '6' },
+ { City: 'Esfahan', CountryId: '46' },
+ { City: 'Eskisehir', CountryId: '97' },
+ { City: 'Etawah', CountryId: '44' },
+ { City: 'Ezeiza', CountryId: '6' },
+ { City: 'Ezhou', CountryId: '23' },
+ { City: 'Faaa', CountryId: '36' },
+ { City: 'Fengshan', CountryId: '92' },
+ { City: 'Firozabad', CountryId: '44' },
+ { City: 'Florencia', CountryId: '24' },
+ { City: 'Fontana', CountryId: '103' },
+ { City: 'Fukuyama', CountryId: '50' },
+ { City: 'Funafuti', CountryId: '99' },
+ { City: 'Fuyu', CountryId: '23' },
+ { City: 'Fuzhou', CountryId: '23' },
+ { City: 'Gandhinagar', CountryId: '44' },
+ { City: 'Garden Grove', CountryId: '103' },
+ { City: 'Garland', CountryId: '103' },
+ { City: 'Gatineau', CountryId: '20' },
+ { City: 'Gaziantep', CountryId: '97' },
+ { City: 'Gijn', CountryId: '87' },
+ { City: 'Gingoog', CountryId: '75' },
+ { City: 'Goinia', CountryId: '15' },
+ { City: 'Gorontalo', CountryId: '45' },
+ { City: 'Grand Prairie', CountryId: '103' },
+ { City: 'Graz', CountryId: '9' },
+ { City: 'Greensboro', CountryId: '103' },
+ { City: 'Guadalajara', CountryId: '60' },
+ { City: 'Guaruj', CountryId: '15' },
+ { City: 'guas Lindas de Gois', CountryId: '15' },
+ { City: 'Gulbarga', CountryId: '44' },
+ { City: 'Hagonoy', CountryId: '75' },
+ { City: 'Haining', CountryId: '23' },
+ { City: 'Haiphong', CountryId: '105' },
+ { City: 'Haldia', CountryId: '44' },
+ { City: 'Halifax', CountryId: '20' },
+ { City: 'Halisahar', CountryId: '44' },
+ { City: 'Halle/Saale', CountryId: '38' },
+ { City: 'Hami', CountryId: '23' },
+ { City: 'Hamilton', CountryId: '68' },
+ { City: 'Hanoi', CountryId: '105' },
+ { City: 'Hidalgo', CountryId: '60' },
+ { City: 'Higashiosaka', CountryId: '50' },
+ { City: 'Hino', CountryId: '50' },
+ { City: 'Hiroshima', CountryId: '50' },
+ { City: 'Hodeida', CountryId: '107' },
+ { City: 'Hohhot', CountryId: '23' },
+ { City: 'Hoshiarpur', CountryId: '44' },
+ { City: 'Hsichuh', CountryId: '92' },
+ { City: 'Huaian', CountryId: '23' },
+ { City: 'Hubli-Dharwad', CountryId: '44' },
+ { City: 'Huejutla de Reyes', CountryId: '60' },
+ { City: 'Huixquilucan', CountryId: '60' },
+ { City: 'Hunuco', CountryId: '74' },
+ { City: 'Ibirit', CountryId: '15' },
+ { City: 'Idfu', CountryId: '29' },
+ { City: 'Ife', CountryId: '69' },
+ { City: 'Ikerre', CountryId: '69' },
+ { City: 'Iligan', CountryId: '75' },
+ { City: 'Ilorin', CountryId: '69' },
+ { City: 'Imus', CountryId: '75' },
+ { City: 'Inegl', CountryId: '97' },
+ { City: 'Ipoh', CountryId: '59' },
+ { City: 'Isesaki', CountryId: '50' },
+ { City: 'Ivanovo', CountryId: '80' },
+ { City: 'Iwaki', CountryId: '50' },
+ { City: 'Iwakuni', CountryId: '50' },
+ { City: 'Iwatsuki', CountryId: '50' },
+ { City: 'Izumisano', CountryId: '50' },
+ { City: 'Jaffna', CountryId: '88' },
+ { City: 'Jaipur', CountryId: '44' },
+ { City: 'Jakarta', CountryId: '45' },
+ { City: 'Jalib al-Shuyukh', CountryId: '53' },
+ { City: 'Jamalpur', CountryId: '12' },
+ { City: 'Jaroslavl', CountryId: '80' },
+ { City: 'Jastrzebie-Zdrj', CountryId: '76' },
+ { City: 'Jedda', CountryId: '82' },
+ { City: 'Jelets', CountryId: '80' },
+ { City: 'Jhansi', CountryId: '44' },
+ { City: 'Jinchang', CountryId: '23' },
+ { City: 'Jining', CountryId: '23' },
+ { City: 'Jinzhou', CountryId: '23' },
+ { City: 'Jodhpur', CountryId: '44' },
+ { City: 'Johannesburg', CountryId: '85' },
+ { City: 'Joliet', CountryId: '103' },
+ { City: 'Jos Azueta', CountryId: '60' },
+ { City: 'Juazeiro do Norte', CountryId: '15' },
+ { City: 'Juiz de Fora', CountryId: '15' },
+ { City: 'Junan', CountryId: '23' },
+ { City: 'Jurez', CountryId: '60' },
+ { City: 'Kabul', CountryId: '1' },
+ { City: 'Kaduna', CountryId: '69' },
+ { City: 'Kakamigahara', CountryId: '50' },
+ { City: 'Kaliningrad', CountryId: '80' },
+ { City: 'Kalisz', CountryId: '76' },
+ { City: 'Kamakura', CountryId: '50' },
+ { City: 'Kamarhati', CountryId: '44' },
+ { City: 'Kamjanets-Podilskyi', CountryId: '100' },
+ { City: 'Kamyin', CountryId: '80' },
+ { City: 'Kanazawa', CountryId: '50' },
+ { City: 'Kanchrapara', CountryId: '44' },
+ { City: 'Kansas City', CountryId: '103' },
+ { City: 'Karnal', CountryId: '44' },
+ { City: 'Katihar', CountryId: '44' },
+ { City: 'Kermanshah', CountryId: '46' },
+ { City: 'Kilis', CountryId: '97' },
+ { City: 'Kimberley', CountryId: '85' },
+ { City: 'Kimchon', CountryId: '86' },
+ { City: 'Kingstown', CountryId: '81' },
+ { City: 'Kirovo-Tepetsk', CountryId: '80' },
+ { City: 'Kisumu', CountryId: '52' },
+ { City: 'Kitwe', CountryId: '109' },
+ { City: 'Klerksdorp', CountryId: '85' },
+ { City: 'Kolpino', CountryId: '80' },
+ { City: 'Konotop', CountryId: '100' },
+ { City: 'Koriyama', CountryId: '50' },
+ { City: 'Korla', CountryId: '23' },
+ { City: 'Korolev', CountryId: '80' },
+ { City: 'Kowloon and New Kowloon', CountryId: '42' },
+ { City: 'Kragujevac', CountryId: '108' },
+ { City: 'Ktahya', CountryId: '97' },
+ { City: 'Kuching', CountryId: '59' },
+ { City: 'Kumbakonam', CountryId: '44' },
+ { City: 'Kurashiki', CountryId: '50' },
+ { City: 'Kurgan', CountryId: '80' },
+ { City: 'Kursk', CountryId: '80' },
+ { City: 'Kuwana', CountryId: '50' },
+ { City: 'La Paz', CountryId: '60' },
+ { City: 'La Plata', CountryId: '6' },
+ { City: 'La Romana', CountryId: '27' },
+ { City: 'Laiwu', CountryId: '23' },
+ { City: 'Lancaster', CountryId: '103' },
+ { City: 'Laohekou', CountryId: '23' },
+ { City: 'Lapu-Lapu', CountryId: '75' },
+ { City: 'Laredo', CountryId: '103' },
+ { City: 'Lausanne', CountryId: '91' },
+ { City: 'Le Mans', CountryId: '34' },
+ { City: 'Lengshuijiang', CountryId: '23' },
+ { City: 'Leshan', CountryId: '23' },
+ { City: 'Lethbridge', CountryId: '20' },
+ { City: 'Lhokseumawe', CountryId: '45' },
+ { City: 'Liaocheng', CountryId: '23' },
+ { City: 'Liepaja', CountryId: '54' },
+ { City: 'Lilongwe', CountryId: '58' },
+ { City: 'Lima', CountryId: '74' },
+ { City: 'Lincoln', CountryId: '103' },
+ { City: 'Linz', CountryId: '9' },
+ { City: 'Lipetsk', CountryId: '80' },
+ { City: 'Livorno', CountryId: '49' },
+ { City: 'Ljubertsy', CountryId: '80' },
+ { City: 'Loja', CountryId: '28' },
+ { City: 'London', CountryId: '102' },
+ { City: 'London', CountryId: '20' },
+ { City: 'Lublin', CountryId: '76' },
+ { City: 'Lubumbashi', CountryId: '25' },
+ { City: 'Lungtan', CountryId: '92' },
+ { City: 'Luzinia', CountryId: '15' },
+ { City: 'Madiun', CountryId: '45' },
+ { City: 'Mahajanga', CountryId: '57' },
+ { City: 'Maikop', CountryId: '80' },
+ { City: 'Malm', CountryId: '90' },
+ { City: 'Manchester', CountryId: '103' },
+ { City: 'Mandaluyong', CountryId: '75' },
+ { City: 'Mandi Bahauddin', CountryId: '72' },
+ { City: 'Mannheim', CountryId: '38' },
+ { City: 'Maracabo', CountryId: '104' },
+ { City: 'Mardan', CountryId: '72' },
+ { City: 'Maring', CountryId: '15' },
+ { City: 'Masqat', CountryId: '71' },
+ { City: 'Matamoros', CountryId: '60' },
+ { City: 'Matsue', CountryId: '50' },
+ { City: 'Meixian', CountryId: '23' },
+ { City: 'Memphis', CountryId: '103' },
+ { City: 'Merlo', CountryId: '6' },
+ { City: 'Mexicali', CountryId: '60' },
+ { City: 'Miraj', CountryId: '44' },
+ { City: 'Mit Ghamr', CountryId: '29' },
+ { City: 'Miyakonojo', CountryId: '50' },
+ { City: 'Mogiljov', CountryId: '13' },
+ { City: 'Molodetno', CountryId: '13' },
+ { City: 'Monclova', CountryId: '60' },
+ { City: 'Monywa', CountryId: '64' },
+ { City: 'Moscow', CountryId: '80' },
+ { City: 'Mosul', CountryId: '47' },
+ { City: 'Mukateve', CountryId: '100' },
+ { City: 'Munger (Monghyr)', CountryId: '44' },
+ { City: 'Mwanza', CountryId: '93' },
+ { City: 'Mwene-Ditu', CountryId: '25' },
+ { City: 'Myingyan', CountryId: '64' },
+ { City: 'Mysore', CountryId: '44' },
+ { City: 'Naala-Porto', CountryId: '63' },
+ { City: 'Nabereznyje Telny', CountryId: '80' },
+ { City: 'Nador', CountryId: '62' },
+ { City: 'Nagaon', CountryId: '44' },
+ { City: 'Nagareyama', CountryId: '50' },
+ { City: 'Najafabad', CountryId: '46' },
+ { City: 'Naju', CountryId: '86' },
+ { City: 'Nakhon Sawan', CountryId: '94' },
+ { City: 'Nam Dinh', CountryId: '105' },
+ { City: 'Namibe', CountryId: '4' },
+ { City: 'Nantou', CountryId: '92' },
+ { City: 'Nanyang', CountryId: '23' },
+ { City: 'NDjamna', CountryId: '21' },
+ { City: 'Newcastle', CountryId: '85' },
+ { City: 'Nezahualcyotl', CountryId: '60' },
+ { City: 'Nha Trang', CountryId: '105' },
+ { City: 'Niznekamsk', CountryId: '80' },
+ { City: 'Novi Sad', CountryId: '108' },
+ { City: 'Novoterkassk', CountryId: '80' },
+ { City: 'Nukualofa', CountryId: '95' },
+ { City: 'Nuuk', CountryId: '40' },
+ { City: 'Nyeri', CountryId: '52' },
+ { City: 'Ocumare del Tuy', CountryId: '104' },
+ { City: 'Ogbomosho', CountryId: '69' },
+ { City: 'Okara', CountryId: '72' },
+ { City: 'Okayama', CountryId: '50' },
+ { City: 'Okinawa', CountryId: '50' },
+ { City: 'Olomouc', CountryId: '26' },
+ { City: 'Omdurman', CountryId: '89' },
+ { City: 'Omiya', CountryId: '50' },
+ { City: 'Ondo', CountryId: '69' },
+ { City: 'Onomichi', CountryId: '50' },
+ { City: 'Oshawa', CountryId: '20' },
+ { City: 'Osmaniye', CountryId: '97' },
+ { City: 'ostka', CountryId: '100' },
+ { City: 'Otsu', CountryId: '50' },
+ { City: 'Oulu', CountryId: '33' },
+ { City: 'Ourense (Orense)', CountryId: '87' },
+ { City: 'Owo', CountryId: '69' },
+ { City: 'Oyo', CountryId: '69' },
+ { City: 'Ozamis', CountryId: '75' },
+ { City: 'Paarl', CountryId: '85' },
+ { City: 'Pachuca de Soto', CountryId: '60' },
+ { City: 'Pak Kret', CountryId: '94' },
+ { City: 'Palghat (Palakkad)', CountryId: '44' },
+ { City: 'Pangkal Pinang', CountryId: '45' },
+ { City: 'Papeete', CountryId: '36' },
+ { City: 'Parbhani', CountryId: '44' },
+ { City: 'Pathankot', CountryId: '44' },
+ { City: 'Patiala', CountryId: '44' },
+ { City: 'Patras', CountryId: '39' },
+ { City: 'Pavlodar', CountryId: '51' },
+ { City: 'Pemalang', CountryId: '45' },
+ { City: 'Peoria', CountryId: '103' },
+ { City: 'Pereira', CountryId: '24' },
+ { City: 'Phnom Penh', CountryId: '18' },
+ { City: 'Pingxiang', CountryId: '23' },
+ { City: 'Pjatigorsk', CountryId: '80' },
+ { City: 'Plock', CountryId: '76' },
+ { City: 'Po', CountryId: '15' },
+ { City: 'Ponce', CountryId: '77' },
+ { City: 'Pontianak', CountryId: '45' },
+ { City: 'Poos de Caldas', CountryId: '15' },
+ { City: 'Portoviejo', CountryId: '28' },
+ { City: 'Probolinggo', CountryId: '45' },
+ { City: 'Pudukkottai', CountryId: '44' },
+ { City: 'Pune', CountryId: '44' },
+ { City: 'Purnea (Purnia)', CountryId: '44' },
+ { City: 'Purwakarta', CountryId: '45' },
+ { City: 'Pyongyang', CountryId: '70' },
+ { City: 'Qalyub', CountryId: '29' },
+ { City: 'Qinhuangdao', CountryId: '23' },
+];
+
+export const initTblCountry = async (context: IInitContext, base: Base) => {
+ const countryColumns = [
+ {
+ title: 'id',
+ uidt: UITypes.ID,
+ },
+ {
+ title: 'Country',
+ uidt: UITypes.SingleLineText,
+ },
+ ];
+ const countryTable = await createTable(context, base, {
+ table_name: 'country',
+ title: 'Country',
+ columns: countryColumns,
+ });
+ const cityColumns = [
+ {
+ title: 'id',
+ uidt: UITypes.ID,
+ },
+ {
+ title: 'City',
+ uidt: UITypes.SingleLineText,
+ },
+ ];
+ const cityTable = await createTable(context, base, {
+ table_name: 'city',
+ title: 'City',
+ columns: cityColumns,
+ });
+ const ltarColumn = await createLtarColumn(context, {
+ title: 'Cities',
+ parentTable: countryTable,
+ childTable: cityTable,
+ type: 'hm',
+ });
+
+ // insert records
+ // creating bulk records using older set of APIs
+ await createBulkRows(context, {
+ base: base,
+ table: countryTable,
+ values: countries.map((c) => ({ Country: c })),
+ });
+ await createBulkRows(context, {
+ base: base,
+ table: cityTable,
+ values: cities.slice(0, 100),
+ });
+ await createBulkRows(context, {
+ base: base,
+ table: cityTable,
+ values: cities.slice(100, 200),
+ });
+ const ncAxiosLinkAdd = (await ncAxios(context, base.id)).ncAxiosLinkAdd;
+ const linkToLtar = (rowId: string, body: any[]) => {
+ return ncAxiosLinkAdd({
+ urlParams: {
+ tableId: countryTable.id,
+ linkId: ltarColumn.id,
+ rowId: rowId,
+ },
+ body: body,
+ status: 200,
+ });
+ };
+
+ for (let i = 1; i <= 10; i++) {
+ await linkToLtar(
+ i.toString(),
+ cities
+ .map((c, idx) => ({ ...c, id: idx + 1 }))
+ .filter((k) => k.id <= 200 && k.CountryId === i.toString())
+ .sort((a, b) => a.id - b.id),
+ );
+ }
+ return {
+ countryTable,
+ cityTable,
+ };
+};
diff --git a/packages/nocodb/tests/unit/rest/tests/dataApiV3/beforeEach.ts b/packages/nocodb/tests/unit/rest/tests/dataApiV3/beforeEach.ts
index 33e211d469..f43bcff501 100644
--- a/packages/nocodb/tests/unit/rest/tests/dataApiV3/beforeEach.ts
+++ b/packages/nocodb/tests/unit/rest/tests/dataApiV3/beforeEach.ts
@@ -1,25 +1,24 @@
-import fs from 'fs';
-import path from 'path';
-import { NcApiVersion, UITypes } from 'nocodb-sdk';
import { expect } from 'chai';
-import { createProject, createSakilaProject } from '../../../factory/base';
+import { NcApiVersion, UITypes } from 'nocodb-sdk';
+import { createProject } from '../../../factory/base';
import {
createLtarColumn,
createLtarColumn2,
customColumns,
} from '../../../factory/column';
import { createBulkRows, listRow, rowMixedValue } from '../../../factory/row';
-import { createTable, getTable } from '../../../factory/table';
+import { createTable } from '../../../factory/table';
import init from '../../../init';
+import { initTblCountry } from '../../../init/initTblCountry';
import { addUsers, getUsers, prepareRecords } from './helpers';
+import type { ITestContext } from '../../../init';
import type { Model } from '../../../../../src/models';
import type { ColumnType } from 'nocodb-sdk';
-import type { ITestContext } from './helpers';
export const beforeEach = async () => {
const context = await init();
- const sakilaProject = await createSakilaProject(context);
+ // const sakilaProject = await createSakilaProject(context);
const base = await createProject(context);
const ctx = {
@@ -27,23 +26,10 @@ export const beforeEach = async () => {
base_id: base.id,
};
- const countryTable = await getTable({
- base: sakilaProject,
- name: 'country',
- });
-
- const cityTable = await getTable({
- base: sakilaProject,
- name: 'city',
- });
-
return {
context,
ctx,
- sakilaProject,
base,
- countryTable,
- cityTable,
} as ITestContext;
};
diff --git a/packages/nocodb/tests/unit/rest/tests/dataApiV3/get-list.test.ts b/packages/nocodb/tests/unit/rest/tests/dataApiV3/get-list.test.ts
index 648f791402..21deff1bc5 100644
--- a/packages/nocodb/tests/unit/rest/tests/dataApiV3/get-list.test.ts
+++ b/packages/nocodb/tests/unit/rest/tests/dataApiV3/get-list.test.ts
@@ -13,6 +13,7 @@ import {
import { createView, updateView } from '../../../factory/view';
import { createTable } from '../../../factory/table';
import { createBulkRows, createBulkRowsV3 } from '../../../factory/row';
+import { initTblCountry } from '../../../init/initTblCountry';
import {
beforeEachNumberBased,
beforeEachTextBased,
@@ -20,7 +21,7 @@ import {
} from './beforeEach';
import { ncAxios } from './ncAxios';
import { normalizeObject, verifyColumnsInRsp } from './helpers';
-import type { ITestContext } from './helpers';
+import type { ITestContext } from '../../../init';
import type { Column, Model } from '../../../../../src/models';
import type { INcAxios } from './ncAxios';
@@ -48,7 +49,7 @@ describe('dataApiV3', () => {
beforeEach(async () => {
testContext = await dataApiV3BeforeEach();
testAxios = ncAxios(testContext);
- urlPrefix = `/api/${API_VERSION}/data/${testContext.sakilaProject.id}`;
+ urlPrefix = `/api/${API_VERSION}/data/${testContext.base.id}`;
ncAxiosGet = testAxios.ncAxiosGet;
ncAxiosPost = testAxios.ncAxiosPost;
@@ -60,9 +61,19 @@ describe('dataApiV3', () => {
});
describe('general-based', () => {
+ let countryTable: Model;
+ let cityTable: Model;
+ beforeEach(async () => {
+ const tables = await initTblCountry(
+ testContext.context,
+ testContext.base,
+ );
+ countryTable = tables.countryTable;
+ cityTable = tables.cityTable;
+ });
it('get list country with limit 4 and next offset', async function () {
const response = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
limit: 4,
},
@@ -71,7 +82,7 @@ describe('dataApiV3', () => {
expect(result.records.length).to.eq(4);
const nextResponse = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
limit: 4,
page: 2,
@@ -86,7 +97,7 @@ describe('dataApiV3', () => {
it('get list country with 1 field', async function () {
const response = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
fields: 'Country',
},
@@ -105,9 +116,9 @@ describe('dataApiV3', () => {
it('get list country with primary key field included', async function () {
const response = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
- fields: ['CountryId', 'Country'],
+ fields: ['id', 'Country'],
},
});
const result = response.body as ListResult;
@@ -125,7 +136,7 @@ describe('dataApiV3', () => {
it.skip('get list country with 2 fields on same query param', async function () {
const response = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
fields: 'CountryId,Country',
},
@@ -136,7 +147,7 @@ describe('dataApiV3', () => {
// TODO: handle space between fields
// with space after delimiter
const nextResponse = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
fields: 'CountryId, Country',
},
@@ -147,9 +158,9 @@ describe('dataApiV3', () => {
it('get list country with 2 fields on different query param (array)', async function () {
const response = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
- fields: ['CountryId', 'Country'],
+ fields: ['id', 'Country'],
},
});
const result = response.body as ListResult;
@@ -158,7 +169,7 @@ describe('dataApiV3', () => {
it('get list country with name like Ind', async function () {
const response = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
filter: '(Country,like,Ind)',
},
@@ -173,15 +184,15 @@ describe('dataApiV3', () => {
});
it('Nested List - Link to another record', async function () {
- const expectedRecords = [1, 3, 1, 2, 1, 13, 1, 1, 3, 2];
+ const expectedRecords = [0, 2, 0, 1, 0, 6, 0, 0, 1, 1];
+
const records = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
limit: 10,
},
});
expect(records.body.records.length).to.equal(expectedRecords.length);
-
const cityList = records.body.records.map(
(r: any) => r.fields['Cities'],
);
@@ -190,43 +201,36 @@ describe('dataApiV3', () => {
it('Nested List - Lookup', async function () {
await createLookupColumn(testContext.context, {
- base: testContext.sakilaProject,
+ base: testContext.base,
title: 'Lookup',
- table: testContext.countryTable,
- relatedTableName: testContext.cityTable.table_name,
+ table: countryTable,
+ relatedTableName: cityTable!.table_name,
relatedTableColumnTitle: 'City',
});
const expectedRecords = [
- ['Kabul'],
- ['Batna', 'Bchar', 'Skikda'],
- ['Tafuna'],
- ['Benguela', 'Namibe'],
- ['South Hill'],
+ [],
+ ['Batna', 'Bchar'],
+ [],
+ ['Benguela'],
+ [],
[
'Almirante Brown',
- 'Avellaneda',
- 'Baha Blanca',
'Crdoba',
'Escobar',
'Ezeiza',
- 'La Plata',
- 'Merlo',
- 'Quilmes',
- 'San Miguel de Tucumn',
- 'Santa F',
- 'Tandil',
- 'Vicente Lpez',
+ 'Avellaneda',
+ 'Baha Blanca',
],
- ['Yerevan'],
- ['Woodridge'],
- ['Graz', 'Linz', 'Salzburg'],
- ['Baku', 'Sumqayit'],
+ [],
+ [],
+ ['Graz'],
+ ['Baku'],
];
// read first 10 records
const records = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
limit: 10,
},
@@ -242,17 +246,17 @@ describe('dataApiV3', () => {
it('Nested List - Rollup', async function () {
await createRollupColumn(testContext.context, {
- base: testContext.sakilaProject,
+ base: testContext.base,
title: 'Rollup',
- table: testContext.countryTable,
- relatedTableName: testContext.cityTable.table_name,
+ table: countryTable,
+ relatedTableName: cityTable!.table_name,
relatedTableColumnTitle: 'City',
rollupFunction: 'count',
});
- const expectedRecords = [1, 3, 1, 2, 1, 13, 1, 1, 3, 2];
+ const expectedRecords = [0, 2, 0, 1, 0, 6, 0, 0, 1, 1];
const records = await ncAxiosGet({
- url: `${urlPrefix}/${testContext.countryTable.id}/records`,
+ url: `${urlPrefix}/${countryTable!.id}/records`,
query: {
limit: 10,
},
diff --git a/packages/nocodb/tests/unit/rest/tests/dataApiV3/helpers.ts b/packages/nocodb/tests/unit/rest/tests/dataApiV3/helpers.ts
index 830c086bff..f261b4f544 100644
--- a/packages/nocodb/tests/unit/rest/tests/dataApiV3/helpers.ts
+++ b/packages/nocodb/tests/unit/rest/tests/dataApiV3/helpers.ts
@@ -2,20 +2,7 @@ import { expect } from 'chai';
import request from 'supertest';
import { type ColumnType, WorkspaceUserRoles } from 'nocodb-sdk';
import { defaultUserArgs } from '../../../factory/user';
-import type init from '../../../init';
-import type { Base, Model } from '../../../../../src/models';
-
-export interface ITestContext {
- context: Awaited<ReturnType<typeof init>>;
- ctx: {
- workspace_id: any;
- base_id: any;
- };
- sakilaProject: Base;
- base: Base;
- countryTable: Model;
- cityTable: Model;
-}
+import type { ITestContext } from '../../../init';
export const normalizeObject = (obj) => {
return Object.keys(obj)
@@ -34,7 +21,7 @@ export const verifyColumnsInRsp = (
const fieldsObject = row.fields || row;
const responseColumnsListStr = Object.keys(fieldsObject).sort().join(',');
const expectedColumnsListStr = columns
- .filter((c) => !c.system && !c.pk) // Exclude both system columns and primary key
+ .filter((c) => !c.system && !c.pk) // Exclude both system columns and primary key
.map((c) => c.title)
.sort()
.join(',');
diff --git a/packages/nocodb/tests/unit/utils/ncAxios.ts b/packages/nocodb/tests/unit/utils/ncAxios.ts
new file mode 100644
index 0000000000..9d804c2d89
--- /dev/null
+++ b/packages/nocodb/tests/unit/utils/ncAxios.ts
@@ -0,0 +1,238 @@
+import request from 'supertest';
+import { expect } from 'chai';
+import type { IInitContext } from '../init';
+
+export interface INcAxios {
+ ncAxiosGet: ({
+ url,
+ query,
+ status,
+ }: {
+ url: string;
+ query?: any;
+ status?: number;
+ }) => Promise<request.Response>;
+ ncAxiosPost: ({
+ url,
+ body,
+ status,
+ query,
+ }: {
+ url: string;
+ body?: any;
+ status?: number;
+ query?: any;
+ }) => Promise<request.Response>;
+ ncAxiosPatch: ({
+ url,
+ body,
+ status,
+ }: {
+ url: string;
+ body?: any;
+ status?: number;
+ }) => Promise<request.Response>;
+ ncAxiosDelete: ({
+ url,
+ body,
+ status,
+ }: {
+ url: string;
+ body?: any;
+ status?: number;
+ }) => Promise<request.Response>;
+ ncAxiosLinkGet: ({
+ urlParams,
+ query,
+ status,
+ msg,
+ }: {
+ urlParams: { tableId: string; linkId: string; rowId: string };
+ query?: any;
+ status?: number;
+ msg?: string;
+ }) => Promise<request.Response>;
+
+ ncAxiosLinkAdd: ({
+ urlParams,
+ body,
+ status,
+ msg,
+ }: {
+ urlParams: { tableId: string; linkId: string; rowId: string };
+ body?: any;
+ status?: number;
+ msg?: string;
+ }) => Promise<request.Response>;
+
+ ncAxiosLinkRemove: ({
+ urlParams,
+ body,
+ status,
+ msg,
+ }: {
+ urlParams: { tableId: string; linkId: string; rowId: string };
+ body?: any;
+ status?: number;
+ msg?: string;
+ }) => Promise<request.Response>;
+}
+
+export const ncAxios = (testContext: IInitContext, baseId: string) => {
+ async function ncAxiosGet({
+ url,
+ query = {},
+ status = 200,
+ }: {
+ url: string;
+ query?: any;
+ status?: number;
+ }) {
+ const response = await request(testContext.app)
+ .get(url)
+ .set('xc-auth', testContext.token)
+ .query(query)
+ .send({});
+
+ expect(response.status).to.equal(status);
+ return response;
+ }
+
+ async function ncAxiosPost({
+ url,
+ body = {},
+ status = 200,
+ query = {},
+ }: {
+ url: string;
+ body?: any;
+ status?: number;
+ query?: any;
+ }) {
+ const response = await request(testContext.app)
+ .post(url)
+ .set('xc-auth', testContext.token)
+ .query(query)
+ .send(body);
+ expect(response.status).to.equal(status);
+ return response;
+ }
+
+ async function ncAxiosPatch({
+ url,
+ body = {},
+ status = 200,
+ }: {
+ url: string;
+ body?: any;
+ status?: number;
+ }) {
+ const response = await request(testContext.app)
+ .patch(url)
+ .set('xc-auth', testContext.token)
+ .send(body);
+ expect(response.status).to.equal(status);
+ return response;
+ }
+
+ async function ncAxiosDelete({
+ url,
+ body = {},
+ status = 200,
+ }: {
+ url: string;
+ body?: any;
+ status?: number;
+ }) {
+ const response = await request(testContext.app)
+ .delete(url)
+ .set('xc-auth', testContext.token)
+ .send(body);
+ expect(response.status).to.equal(status);
+ return response;
+ }
+
+ async function ncAxiosLinkGet({
+ urlParams,
+ query = {},
+ status = 200,
+ msg,
+ }: {
+ urlParams: { tableId: string; linkId: string; rowId: string };
+ query?: any;
+ status?: number;
+ msg?: string;
+ }) {
+ const url = `/api/v3/data/${baseId}/${urlParams.tableId}/links/${urlParams.linkId}/${urlParams.rowId}`;
+ const response = await request(testContext.app)
+ .get(url)
+ .set('xc-auth', testContext.token)
+ .query(query)
+ .send({});
+ expect(response.status).to.equal(status);
+
+ if (msg) {
+ expect(response.body.message || response.body.msg).to.equal(msg);
+ }
+
+ return response;
+ }
+
+ async function ncAxiosLinkAdd({
+ urlParams,
+ body = {},
+ status = 200,
+ msg,
+ }: {
+ urlParams: { tableId: string; linkId: string; rowId: string };
+ body?: any;
+ status?: number;
+ msg?: string;
+ }) {
+ const url = `/api/v3/data/${baseId}/${urlParams.tableId}/links/${urlParams.linkId}/${urlParams.rowId}`;
+ const response = await request(testContext.app)
+ .post(url)
+ .set('xc-auth', testContext.token)
+ .send(body);
+
+ expect(response.status).to.equal(status);
+ if (msg) {
+ expect(response.body.message || response.body.msg).to.equal(msg);
+ }
+ return response;
+ }
+
+ async function ncAxiosLinkRemove({
+ urlParams,
+ body = {},
+ status = 200,
+ msg,
+ }: {
+ urlParams: { tableId: string; linkId: string; rowId: string };
+ body?: any;
+ status?: number;
+ msg?: string;
+ }) {
+ const url = `/api/v3/data/${baseId}/${urlParams.tableId}/links/${urlParams.linkId}/${urlParams.rowId}`;
+ const response = await request(testContext.app)
+ .delete(url)
+ .set('xc-auth', testContext.token)
+ .send(body);
+
+ expect(response.status).to.equal(status);
+ if (msg) {
+ expect(response.body.message || response.body.msg).to.equal(msg);
+ }
+ return response;
+ }
+
+ return {
+ ncAxiosGet,
+ ncAxiosPost,
+ ncAxiosPatch,
+ ncAxiosDelete,
+ ncAxiosLinkGet,
+ ncAxiosLinkAdd,
+ ncAxiosLinkRemove,
+ } as INcAxios;
+};