2024-01-18 16:45:18 +03:00
|
|
|
import type { Page } from '@playwright/test'
|
|
|
|
import type { ExpressionUpdate, MethodCall } from 'shared/languageServerTypes'
|
|
|
|
|
2024-01-26 20:18:27 +03:00
|
|
|
export type ExpressionLocator = string | { binding: string; expr: string }
|
|
|
|
|
2024-01-18 16:45:18 +03:00
|
|
|
/** Provide method call info for collapsed function call. */
|
2024-01-26 20:18:27 +03:00
|
|
|
export async function mockCollapsedFunctionInfo(
|
|
|
|
page: Page,
|
|
|
|
expression: ExpressionLocator,
|
|
|
|
functionName: string,
|
|
|
|
) {
|
|
|
|
await mockMethodCallInfo(page, expression, {
|
2024-01-18 16:45:18 +03:00
|
|
|
methodPointer: {
|
2024-05-22 18:07:39 +03:00
|
|
|
module: 'local.Mock_Project.Main',
|
|
|
|
definedOnType: 'local.Mock_Project.Main',
|
2024-01-18 16:45:18 +03:00
|
|
|
name: functionName,
|
|
|
|
},
|
|
|
|
notAppliedArguments: [],
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Provide custom method call info for the specific node. */
|
2024-01-26 20:18:27 +03:00
|
|
|
export async function mockMethodCallInfo(
|
|
|
|
page: Page,
|
|
|
|
expression: ExpressionLocator,
|
|
|
|
methodCallInfo: MethodCall,
|
|
|
|
) {
|
|
|
|
await mockExpressionUpdate(page, expression, { methodCall: methodCallInfo })
|
2024-01-18 16:45:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Provide custom expression update for the specific node. */
|
|
|
|
export async function mockExpressionUpdate(
|
|
|
|
page: Page,
|
2024-01-26 20:18:27 +03:00
|
|
|
expression: ExpressionLocator,
|
2024-01-18 16:45:18 +03:00
|
|
|
update: Partial<ExpressionUpdate>,
|
|
|
|
) {
|
|
|
|
await page.evaluate(
|
2024-05-27 20:32:42 +03:00
|
|
|
({ expression, update }) => (window as any)._mockExpressionUpdate(expression, update),
|
2024-01-26 20:18:27 +03:00
|
|
|
{ expression, update },
|
2024-01-18 16:45:18 +03:00
|
|
|
)
|
|
|
|
}
|