-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add schema infrastructure and switch CDP client to be passed i…
…nto protocol directly (#26222) Co-authored-by: Matt Schile <mschile@cypress.io>
- Loading branch information
1 parent
369f3d4
commit c08b827
Showing
10 changed files
with
96 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
packages/server/test/support/fixtures/cloud/protocol/test-protocol.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
import type { SpecFile } from '.' | ||
import type { Database } from 'better-sqlite3' | ||
import type ProtocolMapping from 'devtools-protocol/types/protocol-mapping' | ||
|
||
type Commands = ProtocolMapping.Commands | ||
type Command<T extends keyof Commands> = Commands[T] | ||
type Events = ProtocolMapping.Events | ||
type Event<T extends keyof Events> = Events[T] | ||
|
||
interface CDPClient { | ||
send<T extends Extract<keyof Commands, string>> (command: T, params?: Command<T>['paramsType'][0]): Promise<Command<T>['returnType']> | ||
on<T extends Extract<keyof Events, string>> (eventName: T, cb: (event: Event<T>[0]) => void): void | ||
} | ||
|
||
// TODO(protocol): This is basic for now but will evolve as we progress with the protocol work | ||
|
||
export interface AppCaptureProtocolInterface { | ||
addRunnables (runnables: any): void | ||
connectToBrowser (options: { target: string, host: string, port: number }): Promise<void> | ||
beforeSpec (spec: SpecFile & { instanceId: string }): void | ||
connectToBrowser (cdpClient: CDPClient): Promise<void> | ||
beforeSpec (db: Database): void | ||
afterSpec (): void | ||
beforeTest(test: Record<string, any>): void | ||
afterTest(test: Record<string, any>): void | ||
close(): void | ||
} | ||
|
||
export interface ProtocolManager extends AppCaptureProtocolInterface { | ||
export interface ProtocolManager { | ||
setupProtocol(url?: string): Promise<void> | ||
protocolEnabled(): boolean | ||
addRunnables (runnables: any): void | ||
connectToBrowser (cdpClient: CDPClient): Promise<void> | ||
beforeSpec (spec: { instanceId: string}): void | ||
afterSpec (): void | ||
beforeTest(test: Record<string, any>): void | ||
afterTest(test: Record<string, any>): void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters