-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from andrewiggins/mock-fetch-ui
Add UI for controlling mock fetch requests
- Loading branch information
Showing
14 changed files
with
1,219 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const isDebug = process.env.PPTR_DEBUG === "true"; | ||
|
||
module.exports = { | ||
launch: { | ||
headless: !isDebug, | ||
devtools: isDebug | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
type Children = undefined | string | JSX.Element | Array<Children>; | ||
|
||
interface JSXAttributes { | ||
children?: Children; | ||
|
||
// Attributes that this JSX allows | ||
class?: string; | ||
for?: string; | ||
id?: string; | ||
} | ||
|
||
type JSXHTMLElement<T> = Partial<Omit<HTMLElementTagNameMap[T], "children">>; | ||
|
||
type HTMLElementsMap = { | ||
[K in keyof HTMLElementTagNameMap]: JSXHTMLElement<K> & JSXAttributes; | ||
}; | ||
|
||
declare namespace JSX { | ||
interface Element extends HTMLElement {} | ||
interface ElementChildrenAttribute { | ||
children?: Children; | ||
} | ||
interface IntrinsicElements extends HTMLElementsMap { | ||
// Custom elements | ||
"draggable-dialog": JSXAttributes; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
interface Timer { | ||
expiresAt: number; | ||
timeoutId: number; | ||
} | ||
|
||
type RequestId = string; | ||
|
||
interface Request { | ||
id: RequestId; | ||
/** When this request should resolve. If null, request is paused and not scheduled to complete */ | ||
expiresAt: number | null; | ||
/** Total time this request should wait */ | ||
duration: number; | ||
/** Tracks how much time of duration has elapsed when a request is paused/resumed */ | ||
elapsedTime: number; | ||
/** Display name of request */ | ||
name: string; | ||
url: string; | ||
options: RequestInit; | ||
promise: Promise<void>; | ||
resolve: () => void; | ||
reject: () => void; | ||
} | ||
|
||
type MockFetchEventType = "update"; | ||
|
||
interface Config { | ||
durationMs: number; | ||
areNewRequestsPaused: boolean; | ||
mode: "auto" | "manual"; | ||
timer: Timer | null; | ||
requests: Map<string, Request>; | ||
newId(): string; | ||
pause(id: RequestId): void; | ||
resume(id: RequestId): void; | ||
on(type: MockFetchEventType, handler: () => void): void; | ||
off(type: MockFetchEventType, handler: () => void): void; | ||
log(...msg: any[]): void; | ||
_emit(type: MockFetchEventType): void; | ||
} | ||
|
||
declare class MockFetchDebugger extends HTMLElement { | ||
config: Config; | ||
show: boolean; | ||
dialog: boolean; | ||
} | ||
|
||
export function createMockFetchConfig(): Config; | ||
export function createMockFetch( | ||
config: Config | ||
): (url: string, options?: RequestInit) => Promise<void>; |
Oops, something went wrong.