UNPKG

idea-at

Version:

Automated Testing suite for IDEA projects

34 lines (33 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApiStatus = exports.mockJSONResponse = exports.goToPage = void 0; const test_1 = require("@playwright/test"); /** * Navigates to a specified URL and verifies the navigation * @param page - The Playwright Page object * @param url - The URL to navigate to * @returns Promise that resolves when navigation is complete and verified */ const goToPage = async (page, url) => { await page.goto(url); await page.waitForURL(url); (0, test_1.expect)(page.url()).toBe(url); }; exports.goToPage = goToPage; /** * Mocks an API JSON response for a specific route * @param page - The Playwright Page object * @param path - The API path/route to mock * @param status - The HTTP status code to return * @param data - The response data to return (object or array) * @returns Promise that resolves when the mock is set up */ const mockJSONResponse = async (page, path, status, data) => await page.route(path, async (route) => route.fulfill({ status, contentType: 'application/json', body: JSON.stringify(data) })); exports.mockJSONResponse = mockJSONResponse; /** * Enum representing common HTTP API status codes */ var ApiStatus; (function (ApiStatus) { ApiStatus[ApiStatus["SUCCESS"] = 200] = "SUCCESS"; })(ApiStatus || (exports.ApiStatus = ApiStatus = {}));