first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,310 @@
import * as create from '../../../actions/session/create.operation';
import { ERROR_MESSAGES, SESSION_STATUS } from '../../../constants';
import * as transport from '../../../transport';
import { createMockExecuteFunction } from '../helpers';
const mockCreatedSession = {
data: { id: 'test-session-123', status: SESSION_STATUS.RUNNING },
};
const baseNodeParameters = {
resource: 'session',
operation: 'create',
profileName: 'test-profile',
record: false,
timeoutMinutes: 10,
saveProfileOnTermination: false,
};
jest.mock('../../../transport', () => {
const originalModule = jest.requireActual<typeof transport>('../../../transport');
return {
...originalModule,
apiRequest: jest.fn(async function () {
return {
...mockCreatedSession,
};
}),
};
});
describe('Test Airtop, session create operation', () => {
afterAll(() => {
jest.unmock('../../../transport');
});
afterEach(() => {
jest.clearAllMocks();
});
/**
* Minimal parameters
*/
it('should create a session with minimal parameters', async () => {
const nodeParameters = {
...baseNodeParameters,
proxy: 'none',
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith('POST', '/sessions', {
configuration: {
profileName: 'test-profile',
solveCaptcha: false,
timeoutMinutes: 10,
record: false,
proxy: false,
},
});
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
data: { ...mockCreatedSession.data },
},
},
]);
});
/**
* Profiles
*/
it('should create a session with save profile enabled', async () => {
const nodeParameters = {
...baseNodeParameters,
saveProfileOnTermination: true,
proxy: 'none',
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(2);
expect(transport.apiRequest).toHaveBeenNthCalledWith(1, 'POST', '/sessions', {
configuration: {
profileName: 'test-profile',
solveCaptcha: false,
timeoutMinutes: 10,
record: false,
proxy: false,
},
});
expect(transport.apiRequest).toHaveBeenNthCalledWith(
2,
'PUT',
'/sessions/test-session-123/save-profile-on-termination/test-profile',
);
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
data: { ...mockCreatedSession.data },
},
},
]);
});
/**
* Proxy
*/
it('should create a session with integrated proxy and empty config', async () => {
const nodeParameters = {
...baseNodeParameters,
proxy: 'integrated',
proxyConfig: {}, // simulate integrated proxy with empty config
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith('POST', '/sessions', {
configuration: {
profileName: 'test-profile',
solveCaptcha: false,
timeoutMinutes: 10,
record: false,
proxy: true,
},
});
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
data: { ...mockCreatedSession.data },
},
},
]);
});
it('should create a session with integrated proxy and proxy configuration', async () => {
const nodeParameters = {
...baseNodeParameters,
proxy: 'integrated',
proxyConfig: { country: 'US', sticky: true },
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith('POST', '/sessions', {
configuration: {
profileName: 'test-profile',
solveCaptcha: false,
timeoutMinutes: 10,
record: false,
proxy: { country: 'US', sticky: true },
},
});
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
data: { ...mockCreatedSession.data },
},
},
]);
});
it('should create a session with proxy URL', async () => {
const nodeParameters = {
...baseNodeParameters,
proxy: 'proxyUrl',
proxyUrl: 'http://proxy.example.com:8080',
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith('POST', '/sessions', {
configuration: {
profileName: 'test-profile',
solveCaptcha: false,
timeoutMinutes: 10,
record: false,
proxy: 'http://proxy.example.com:8080',
},
});
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
data: { ...mockCreatedSession.data },
},
},
]);
});
it('should throw error when custom proxy URL is empty', async () => {
const nodeParameters = {
...baseNodeParameters,
proxy: 'proxyUrl',
proxyUrl: '',
};
await expect(create.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
ERROR_MESSAGES.PROXY_URL_REQUIRED,
);
});
/**
* Auto solve captcha
*/
it('should create a session with auto solve captcha enabled', async () => {
const nodeParameters = {
...baseNodeParameters,
additionalFields: {
solveCaptcha: true,
},
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith('POST', '/sessions', {
configuration: {
profileName: 'test-profile',
solveCaptcha: true,
timeoutMinutes: 10,
record: false,
proxy: false,
},
});
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
data: { ...mockCreatedSession.data },
},
},
]);
});
/**
* Chrome extensions
*/
it('should create a session with chrome extensions enabled', async () => {
const nodeParameters = {
...baseNodeParameters,
additionalFields: {
extensionIds: 'extId1, extId2',
},
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith('POST', '/sessions', {
configuration: {
profileName: 'test-profile',
solveCaptcha: false,
timeoutMinutes: 10,
record: false,
proxy: false,
extensionIds: ['extId1', 'extId2'],
},
});
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
data: { ...mockCreatedSession.data },
},
},
]);
});
/**
* Session recording
*/
it('should create a session with recording enabled', async () => {
const nodeParameters = {
...baseNodeParameters,
record: true,
proxy: 'none',
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith('POST', '/sessions', {
configuration: {
profileName: 'test-profile',
solveCaptcha: false,
timeoutMinutes: 10,
record: true,
proxy: false,
},
});
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
data: { ...mockCreatedSession.data },
},
},
]);
});
});
@@ -0,0 +1,103 @@
import * as save from '../../../actions/session/save.operation';
import { ERROR_MESSAGES } from '../../../constants';
import * as transport from '../../../transport';
import { createMockExecuteFunction } from '../helpers';
jest.mock('../../../transport', () => {
const originalModule = jest.requireActual<typeof transport>('../../../transport');
return {
...originalModule,
apiRequest: jest.fn(async function () {
return {
status: 'success',
message: 'Profile will be saved on session termination',
};
}),
};
});
const baseParameters = {
resource: 'session',
operation: 'save',
sessionId: 'test-session-123',
profileName: 'test-profile',
};
describe('Test Airtop, session save operation', () => {
afterAll(() => {
jest.unmock('../../../transport');
});
afterEach(() => {
jest.clearAllMocks();
});
it('should save a profile on session termination successfully', async () => {
const nodeParameters = {
...baseParameters,
};
const result = await save.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith(
'PUT',
'/sessions/test-session-123/save-profile-on-termination/test-profile',
);
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
profileName: 'test-profile',
status: 'success',
message: 'Profile will be saved on session termination',
},
},
]);
});
it('should throw error when sessionId is empty', async () => {
const nodeParameters = {
...baseParameters,
sessionId: '',
};
await expect(save.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
ERROR_MESSAGES.SESSION_ID_REQUIRED,
);
});
it('should throw error when sessionId is whitespace', async () => {
const nodeParameters = {
...baseParameters,
sessionId: ' ',
};
await expect(save.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
ERROR_MESSAGES.SESSION_ID_REQUIRED,
);
});
it('should throw error when profileName is empty', async () => {
const nodeParameters = {
...baseParameters,
profileName: '',
};
await expect(save.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
"Please fill the 'Profile Name' parameter",
);
});
it('should throw error when profileName is whitespace', async () => {
const nodeParameters = {
...baseParameters,
profileName: ' ',
};
await expect(save.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
"Please fill the 'Profile Name' parameter",
);
});
});
@@ -0,0 +1,71 @@
import * as terminate from '../../../actions/session/terminate.operation';
import { ERROR_MESSAGES } from '../../../constants';
import * as transport from '../../../transport';
import { createMockExecuteFunction } from '../helpers';
jest.mock('../../../transport', () => {
const originalModule = jest.requireActual<typeof transport>('../../../transport');
return {
...originalModule,
apiRequest: jest.fn(async function () {
return {
status: 'success',
};
}),
};
});
describe('Test Airtop, session terminate operation', () => {
afterAll(() => {
jest.unmock('../../../transport');
});
afterEach(() => {
jest.clearAllMocks();
});
it('should terminate a session successfully', async () => {
const nodeParameters = {
resource: 'session',
operation: 'terminate',
sessionId: 'test-session-123',
};
const result = await terminate.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith('DELETE', '/sessions/test-session-123');
expect(result).toEqual([
{
json: {
success: true,
},
},
]);
});
it('should throw error when sessionId is empty', async () => {
const nodeParameters = {
resource: 'session',
operation: 'terminate',
sessionId: '',
};
await expect(
terminate.execute.call(createMockExecuteFunction(nodeParameters), 0),
).rejects.toThrow(ERROR_MESSAGES.SESSION_ID_REQUIRED);
});
it('should throw error when sessionId is whitespace', async () => {
const nodeParameters = {
resource: 'session',
operation: 'terminate',
sessionId: ' ',
};
await expect(
terminate.execute.call(createMockExecuteFunction(nodeParameters), 0),
).rejects.toThrow(ERROR_MESSAGES.SESSION_ID_REQUIRED);
});
});
@@ -0,0 +1,85 @@
import * as waitForDownload from '../../../actions/session/waitForDownload.operation';
import { ERROR_MESSAGES } from '../../../constants';
import * as GenericFunctions from '../../../GenericFunctions';
import { createMockExecuteFunction } from '../helpers';
jest.mock('../../../GenericFunctions', () => {
const originalModule = jest.requireActual<typeof GenericFunctions>('../../../GenericFunctions');
return {
...originalModule,
waitForSessionEvent: jest.fn(),
};
});
describe('Test Airtop, session waitForDownload operation', () => {
afterAll(() => {
jest.unmock('../../../GenericFunctions');
});
afterEach(() => {
jest.clearAllMocks();
});
it('should wait for download successfully', async () => {
const mockEvent = {
event: 'file_status',
status: 'available',
fileId: 'test-file-123',
downloadUrl: 'https://example.com/download/test-file-123',
};
(GenericFunctions.waitForSessionEvent as jest.Mock).mockResolvedValue(mockEvent);
const nodeParameters = {
resource: 'session',
operation: 'waitForDownload',
sessionId: 'test-session-123',
timeout: 1,
};
const result = await waitForDownload.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(GenericFunctions.waitForSessionEvent).toHaveBeenCalledTimes(1);
expect(GenericFunctions.waitForSessionEvent).toHaveBeenCalledWith(
'test-session-123',
expect.any(Function),
1,
);
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
data: {
fileId: 'test-file-123',
downloadUrl: 'https://example.com/download/test-file-123',
},
},
},
]);
});
it('should throw error when sessionId is empty', async () => {
const nodeParameters = {
resource: 'session',
operation: 'waitForDownload',
sessionId: '',
};
await expect(
waitForDownload.execute.call(createMockExecuteFunction(nodeParameters), 0),
).rejects.toThrow(ERROR_MESSAGES.SESSION_ID_REQUIRED);
});
it('should throw error when sessionId is whitespace', async () => {
const nodeParameters = {
resource: 'session',
operation: 'waitForDownload',
sessionId: ' ',
};
await expect(
waitForDownload.execute.call(createMockExecuteFunction(nodeParameters), 0),
).rejects.toThrow(ERROR_MESSAGES.SESSION_ID_REQUIRED);
});
});