-
Notifications
You must be signed in to change notification settings - Fork 326
/
Copy pathexpressionUpdates.ts
42 lines (38 loc) · 1.23 KB
/
expressionUpdates.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import type { Page } from '@playwright/test'
import type { ExpressionUpdate, MethodCall } from 'ydoc-shared/languageServerTypes'
export type ExpressionLocator = string | { binding: string; expr: string }
/** Provide method call info for collapsed function call. */
export async function mockCollapsedFunctionInfo(
page: Page,
expression: ExpressionLocator,
functionName: string,
notAppliedArguments: number[] = [],
) {
await mockMethodCallInfo(page, expression, {
methodPointer: {
module: 'local.Mock_Project.Main',
definedOnType: 'local.Mock_Project.Main',
name: functionName,
},
notAppliedArguments,
})
}
/** Provide custom method call info for the specific node. */
export async function mockMethodCallInfo(
page: Page,
expression: ExpressionLocator,
methodCallInfo: MethodCall,
) {
await mockExpressionUpdate(page, expression, { methodCall: methodCallInfo })
}
/** Provide custom expression update for the specific node. */
export async function mockExpressionUpdate(
page: Page,
expression: ExpressionLocator,
update: Partial<ExpressionUpdate>,
) {
await page.evaluate(
({ expression, update }) => (window as any)._mockExpressionUpdate(expression, update),
{ expression, update },
)
}