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,92 @@
import nock from 'nock';
import * as close from '../../../actions/window/close.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',
data: {
closed: true,
},
};
}),
};
});
describe('Test Airtop, window close operation', () => {
beforeAll(() => {
nock.disableNetConnect();
});
afterAll(() => {
nock.restore();
jest.unmock('../../../transport');
});
afterEach(() => {
jest.clearAllMocks();
});
it('should close a window successfully', async () => {
const nodeParameters = {
resource: 'window',
operation: 'close',
sessionId: 'test-session-123',
windowId: 'win-123',
};
const result = await close.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith(
'DELETE',
'/sessions/test-session-123/windows/win-123',
);
expect(result).toEqual([
{
json: {
sessionId: 'test-session-123',
windowId: 'win-123',
status: 'success',
data: {
closed: true,
},
},
},
]);
});
it('should throw error when sessionId is empty', async () => {
const nodeParameters = {
resource: 'window',
operation: 'close',
sessionId: '',
windowId: 'win-123',
};
await expect(close.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
ERROR_MESSAGES.SESSION_ID_REQUIRED,
);
});
it('should throw error when windowId is empty', async () => {
const nodeParameters = {
resource: 'window',
operation: 'close',
sessionId: 'test-session-123',
windowId: '',
};
await expect(close.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
ERROR_MESSAGES.WINDOW_ID_REQUIRED,
);
});
});
@@ -0,0 +1,308 @@
import nock from 'nock';
import * as create from '../../../actions/window/create.operation';
import { ERROR_MESSAGES } from '../../../constants';
import * as transport from '../../../transport';
import { createMockExecuteFunction } from '../helpers';
const baseNodeParameters = {
resource: 'window',
operation: 'create',
sessionId: 'test-session-123',
url: 'https://example.com',
getLiveView: false,
disableResize: false,
additionalFields: {},
};
jest.mock('../../../transport', () => {
const originalModule = jest.requireActual<typeof transport>('../../../transport');
return {
...originalModule,
apiRequest: jest.fn(async function (method: string) {
if (method === 'GET') {
return {
status: 'success',
data: {
liveViewUrl: 'https://live.airtop.ai/123-abcd',
},
};
}
return {
status: 'success',
data: {
windowId: 'win-123',
},
};
}),
};
});
describe('Test Airtop, window create operation', () => {
beforeAll(() => {
nock.disableNetConnect();
});
afterAll(() => {
nock.restore();
jest.unmock('../../../transport');
});
afterEach(() => {
jest.clearAllMocks();
});
it('should create a window with minimal parameters', async () => {
const result = await create.execute.call(createMockExecuteFunction(baseNodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith(
'POST',
'/sessions/test-session-123/windows',
{
url: 'https://example.com',
},
);
expect(result).toEqual([
{
json: {
sessionId: baseNodeParameters.sessionId,
windowId: 'win-123',
status: 'success',
data: {
windowId: 'win-123',
},
},
},
]);
});
it('should create a window with live view', async () => {
const nodeParameters = {
...baseNodeParameters,
getLiveView: true,
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(2);
expect(transport.apiRequest).toHaveBeenNthCalledWith(
1,
'POST',
'/sessions/test-session-123/windows',
{
url: 'https://example.com',
},
);
expect(transport.apiRequest).toHaveBeenNthCalledWith(
2,
'GET',
'/sessions/test-session-123/windows/win-123',
undefined,
{},
);
expect(result).toEqual([
{
json: {
sessionId: baseNodeParameters.sessionId,
windowId: 'win-123',
status: 'success',
data: {
liveViewUrl: 'https://live.airtop.ai/123-abcd',
},
},
},
]);
});
it('should create a window with live view and disabled resize', async () => {
const nodeParameters = {
...baseNodeParameters,
getLiveView: true,
disableResize: true,
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(2);
expect(transport.apiRequest).toHaveBeenNthCalledWith(
1,
'POST',
'/sessions/test-session-123/windows',
{
url: 'https://example.com',
},
);
expect(transport.apiRequest).toHaveBeenNthCalledWith(
2,
'GET',
'/sessions/test-session-123/windows/win-123',
undefined,
{ disableResize: true },
);
expect(result).toEqual([
{
json: {
sessionId: baseNodeParameters.sessionId,
windowId: 'win-123',
status: 'success',
data: {
liveViewUrl: 'https://live.airtop.ai/123-abcd',
},
},
},
]);
});
it('should create a window with live view and navigation bar', async () => {
const nodeParameters = {
...baseNodeParameters,
getLiveView: true,
includeNavigationBar: true,
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(2);
expect(transport.apiRequest).toHaveBeenNthCalledWith(
1,
'POST',
'/sessions/test-session-123/windows',
{
url: 'https://example.com',
},
);
expect(transport.apiRequest).toHaveBeenNthCalledWith(
2,
'GET',
'/sessions/test-session-123/windows/win-123',
undefined,
{ includeNavigationBar: true },
);
expect(result).toEqual([
{
json: {
sessionId: baseNodeParameters.sessionId,
windowId: 'win-123',
status: 'success',
data: {
liveViewUrl: 'https://live.airtop.ai/123-abcd',
},
},
},
]);
});
it('should create a window with live view and screen resolution', async () => {
const nodeParameters = {
...baseNodeParameters,
getLiveView: true,
screenResolution: '1280x720',
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(2);
expect(transport.apiRequest).toHaveBeenNthCalledWith(
1,
'POST',
'/sessions/test-session-123/windows',
{
url: 'https://example.com',
},
);
expect(transport.apiRequest).toHaveBeenNthCalledWith(
2,
'GET',
'/sessions/test-session-123/windows/win-123',
undefined,
{ screenResolution: '1280x720' },
);
expect(result).toEqual([
{
json: {
sessionId: baseNodeParameters.sessionId,
windowId: 'win-123',
status: 'success',
data: {
liveViewUrl: 'https://live.airtop.ai/123-abcd',
},
},
},
]);
});
it('should create a window with all live view options', async () => {
const nodeParameters = {
...baseNodeParameters,
getLiveView: true,
includeNavigationBar: true,
screenResolution: '1920x1080',
disableResize: true,
};
const result = await create.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(2);
expect(transport.apiRequest).toHaveBeenNthCalledWith(
1,
'POST',
'/sessions/test-session-123/windows',
{
url: 'https://example.com',
},
);
expect(transport.apiRequest).toHaveBeenNthCalledWith(
2,
'GET',
'/sessions/test-session-123/windows/win-123',
undefined,
{
includeNavigationBar: true,
screenResolution: '1920x1080',
disableResize: true,
},
);
expect(result).toEqual([
{
json: {
sessionId: baseNodeParameters.sessionId,
windowId: 'win-123',
status: 'success',
data: {
liveViewUrl: 'https://live.airtop.ai/123-abcd',
},
},
},
]);
});
it("should throw error when 'sessionId' parameter is empty", async () => {
const nodeParameters = {
...baseNodeParameters,
sessionId: '',
};
await expect(create.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
ERROR_MESSAGES.SESSION_ID_REQUIRED,
);
});
it('should throw error when screen resolution format is invalid', async () => {
const nodeParameters = {
...baseNodeParameters,
getLiveView: true,
screenResolution: 'invalid-format',
};
await expect(create.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
ERROR_MESSAGES.SCREEN_RESOLUTION_INVALID,
);
});
});
@@ -0,0 +1,115 @@
import nock from 'nock';
import * as load from '../../../actions/window/load.operation';
import { ERROR_MESSAGES } from '../../../constants';
import * as transport from '../../../transport';
import { createMockExecuteFunction } from '../helpers';
const baseNodeParameters = {
resource: 'window',
operation: 'load',
sessionId: 'test-session-123',
windowId: 'win-123',
url: 'https://example.com',
additionalFields: {},
};
const mockResponse = {
success: true,
message: 'Page loaded successfully',
};
jest.mock('../../../transport', () => {
const originalModule = jest.requireActual<typeof transport>('../../../transport');
return {
...originalModule,
apiRequest: jest.fn(async function () {
return {
status: 'success',
data: mockResponse,
};
}),
};
});
describe('Test Airtop, window load operation', () => {
beforeAll(() => {
nock.disableNetConnect();
});
afterAll(() => {
nock.restore();
jest.unmock('../../../transport');
});
afterEach(() => {
jest.clearAllMocks();
});
it('should load URL with minimal parameters', async () => {
const result = await load.execute.call(createMockExecuteFunction(baseNodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith(
'POST',
'/sessions/test-session-123/windows/win-123',
{
url: 'https://example.com',
},
);
expect(result).toEqual([
{
json: {
sessionId: baseNodeParameters.sessionId,
windowId: baseNodeParameters.windowId,
status: 'success',
data: mockResponse,
},
},
]);
});
it('should throw error when URL is empty', async () => {
const nodeParameters = {
...baseNodeParameters,
url: '',
};
const errorMessage = ERROR_MESSAGES.REQUIRED_PARAMETER.replace('{{field}}', 'URL');
await expect(load.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
errorMessage,
);
});
it('should throw error when URL is invalid', async () => {
const nodeParameters = {
...baseNodeParameters,
url: 'not-a-valid-url',
};
await expect(load.execute.call(createMockExecuteFunction(nodeParameters), 0)).rejects.toThrow(
ERROR_MESSAGES.URL_INVALID,
);
});
it("should include 'waitUntil' parameter when specified", async () => {
const nodeParameters = {
...baseNodeParameters,
additionalFields: {
waitUntil: 'domContentLoaded',
},
};
await load.execute.call(createMockExecuteFunction(nodeParameters), 0);
expect(transport.apiRequest).toHaveBeenCalledWith(
'POST',
'/sessions/test-session-123/windows/win-123',
{
url: 'https://example.com',
waitUntil: 'domContentLoaded',
},
);
});
});
@@ -0,0 +1,135 @@
import * as takeScreenshot from '../../../actions/window/takeScreenshot.operation';
import { ERROR_MESSAGES } from '../../../constants';
import * as GenericFunctions from '../../../GenericFunctions';
import * as transport from '../../../transport';
import { createMockExecuteFunction } from '../helpers';
const baseNodeParameters = {
resource: 'window',
operation: 'takeScreenshot',
sessionId: 'test-session-123',
windowId: 'win-123',
};
const mockResponse = {
meta: {
screenshots: [{ dataUrl: 'base64-encoded-image-data' }],
},
};
const mockBinaryBuffer = Buffer.from('mock-binary-data');
const expectedJsonResult = {
json: {
sessionId: 'test-session-123',
windowId: 'win-123',
image: 'base64-encoded-image-data',
},
};
const expectedBinaryResult = {
binary: {
data: {
mimeType: 'image/jpeg',
fileType: 'jpg',
fileName: 'screenshot.jpg',
data: mockBinaryBuffer.toString('base64'),
},
},
};
jest.mock('../../../transport', () => {
const originalModule = jest.requireActual<typeof transport>('../../../transport');
return {
...originalModule,
apiRequest: jest.fn(async function () {
return {
status: 'success',
...mockResponse,
};
}),
};
});
jest.mock('../../../GenericFunctions', () => {
const originalModule = jest.requireActual<typeof GenericFunctions>('../../../GenericFunctions');
return {
...originalModule,
convertScreenshotToBinary: jest.fn(() => mockBinaryBuffer),
};
});
describe('Test Airtop, take screenshot operation', () => {
afterAll(() => {
jest.unmock('../../../transport');
jest.unmock('../../../GenericFunctions');
});
afterEach(() => {
jest.clearAllMocks();
});
it('should take screenshot in base64 format', async () => {
const result = await takeScreenshot.execute.call(
createMockExecuteFunction({ ...baseNodeParameters }),
0,
);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith(
'POST',
'/sessions/test-session-123/windows/win-123/screenshot',
);
expect(result).toEqual([{ ...expectedJsonResult }]);
});
it('should take screenshot in binary format', async () => {
const result = await takeScreenshot.execute.call(
createMockExecuteFunction({
...baseNodeParameters,
outputImageAsBinary: true,
}),
0,
);
expect(transport.apiRequest).toHaveBeenCalledTimes(1);
expect(transport.apiRequest).toHaveBeenCalledWith(
'POST',
'/sessions/test-session-123/windows/win-123/screenshot',
);
expect(GenericFunctions.convertScreenshotToBinary).toHaveBeenCalledWith(
mockResponse.meta.screenshots[0],
);
expect(result).toEqual([
{
json: { ...expectedJsonResult.json, image: '' },
...expectedBinaryResult,
},
]);
});
it('should throw error when sessionId is empty', async () => {
const nodeParameters = {
...baseNodeParameters,
sessionId: '',
};
await expect(
takeScreenshot.execute.call(createMockExecuteFunction(nodeParameters), 0),
).rejects.toThrow(ERROR_MESSAGES.SESSION_ID_REQUIRED);
});
it('should throw error when windowId is empty', async () => {
const nodeParameters = {
...baseNodeParameters,
windowId: '',
};
await expect(
takeScreenshot.execute.call(createMockExecuteFunction(nodeParameters), 0),
).rejects.toThrow(ERROR_MESSAGES.WINDOW_ID_REQUIRED);
});
});