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: {
|
|
|
|
module: 'local.Mock.Main',
|
|
|
|
definedOnType: 'local.Mock.Main',
|
|
|
|
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-01-26 20:18:27 +03:00
|
|
|
({ expression, update }) => (window as any).mockExpressionUpdate(expression, update),
|
|
|
|
{ expression, update },
|
2024-01-18 16:45:18 +03:00
|
|
|
)
|
|
|
|
}
|