Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created August 19, 2023 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonLaster/a36d5024b8324dce6c3c1ac388435c57 to your computer and use it in GitHub Desktop.
Save jasonLaster/a36d5024b8324dce6c3c1ac388435c57 to your computer and use it in GitHub Desktop.
diff --git a/packages/protocol/graphics.ts b/packages/protocol/graphics.ts
index 1f625051c..64e268d85 100644
--- a/packages/protocol/graphics.ts
+++ b/packages/protocol/graphics.ts
@@ -144,6 +144,7 @@ export const timeIsBeyondKnownPaints = (time: number) =>
export function setupGraphics() {
replayClient.waitForSession().then(async (sessionId: string) => {
+ console.log("session setup");
let paintedGraphics = false;
const maybePaintGraphics = async () => {
if (!paintedGraphics) {
@@ -157,6 +158,7 @@ export function setupGraphics() {
const { client } = await import("./socket");
client.Graphics.addPaintPointsListener(async ({ paints }) => {
+ console.log("Received paints", paints);
onPaints(paints);
if (gPaintPoints.length >= INITIAL_PAINT_COUNT) {
initialPaintsReceivedWaiter.resolve(null);
diff --git a/packages/shared/graphql/generated/GetTestsForWorkspace.ts b/packages/shared/graphql/generated/GetTestsForWorkspace.ts
index 1990c97e6..b2ac221e6 100644
--- a/packages/shared/graphql/generated/GetTestsForWorkspace.ts
+++ b/packages/shared/graphql/generated/GetTestsForWorkspace.ts
@@ -42,7 +42,9 @@ export interface GetTestsForWorkspace_node_Workspace {
tests: GetTestsForWorkspace_node_Workspace_tests[] | null;
}
-export type GetTestsForWorkspace_node = GetTestsForWorkspace_node_Recording | GetTestsForWorkspace_node_Workspace;
+export type GetTestsForWorkspace_node =
+ | GetTestsForWorkspace_node_Recording
+ | GetTestsForWorkspace_node_Workspace;
export interface GetTestsForWorkspace {
node: GetTestsForWorkspace_node | null;
diff --git a/src/ui/actions/session.ts b/src/ui/actions/session.ts
index 260c7c2c0..6f9b08c7b 100644
--- a/src/ui/actions/session.ts
+++ b/src/ui/actions/session.ts
@@ -192,7 +192,7 @@ export function createSocket(
const experimentalSettings: ExperimentalSettings = {
disableScanDataCache: userData.get("backend_disableScanDataCache"),
- disableCache: userData.get("backend_disableCache"),
+ disableCache: true, //userData.get("backend_disableCache"),
listenForMetrics: userData.get("backend_listenForMetrics"),
profileWorkerThreads: userData.get("backend_profileWorkerThreads"),
enableRoutines: userData.get("backend_enableRoutines"),
diff --git a/src/ui/components/Library/Team/View/TestRuns/graphql/TestRunsGraphQL.ts b/src/ui/components/Library/Team/View/TestRuns/graphql/TestRunsGraphQL.ts
index 8984e9dc2..c8f607656 100644
--- a/src/ui/components/Library/Team/View/TestRuns/graphql/TestRunsGraphQL.ts
+++ b/src/ui/components/Library/Team/View/TestRuns/graphql/TestRunsGraphQL.ts
@@ -42,6 +42,30 @@ const GET_TEST_RUN_RECORDINGS = gql`
}
`;
+const GET_TESTS_FOR_WORKSPACE = gql`
+ query GetTestsForWorkspace($workspaceId: ID!) {
+ node(id: $workspaceId) {
+ ... on Workspace {
+ id
+ tests {
+ title
+ path
+ recordings {
+ edges {
+ node {
+ uuid
+ duration
+ createdAt
+ metadata
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+`;
+
const GET_TEST_RUNS = gql`
query GetTestsRunsForWorkspace($workspaceId: ID!) {
node(id: $workspaceId) {
@@ -129,3 +153,28 @@ export async function getTestRunsGraphQL(
) ?? []
);
}
+
+export async function getTestsGraphQL(
+ graphQLClient: GraphQLClientInterface,
+ accessToken: string | null,
+ workspaceId: string
+): Promise<GetTestsForWorkspace_node_Workspace_tests_edges_node[]> {
+ const response = await graphQLClient.send<GetTestsForWorkspace>(
+ {
+ operationName: "GetTestsForWorkspace",
+ query: GET_TESTS_FOR_WORKSPACE,
+ variables: { workspaceId },
+ },
+ accessToken
+ );
+
+ if (response?.node == null) {
+ return [];
+ }
+
+ return (
+ (response.node as GetTestsRunsForWorkspace_node_Workspace).testRuns?.edges.map(
+ edge => edge.node
+ ) ?? []
+ );
+}
diff --git a/src/ui/components/Library/Team/View/TestRuns/hooks/useTestRuns.ts b/src/ui/components/Library/Team/View/TestRuns/hooks/useTestRuns.ts
index 847c47e74..c8262d167 100644
--- a/src/ui/components/Library/Team/View/TestRuns/hooks/useTestRuns.ts
+++ b/src/ui/components/Library/Team/View/TestRuns/hooks/useTestRuns.ts
@@ -5,6 +5,7 @@ import { GraphQLClientContext } from "replay-next/src/contexts/GraphQLClientCont
import { TestRun } from "shared/test-suites/TestRun";
import { TeamContext } from "ui/components/Library/Team/TeamContextRoot";
import { testRunsCache } from "ui/components/Library/Team/View/TestRuns/suspense/TestRunsCache";
+import { testsCache } from "ui/components/Library/Team/View/TestRuns/suspense/TestsCache";
import useToken from "ui/utils/useToken";
const EMPTY_ARRAY: any[] = [];
@@ -21,5 +22,14 @@ export function useTestRuns(): TestRun[] {
accessToken?.token ?? null,
teamId
);
+
+ const { value: testsResults } = useImperativeCacheValue(
+ testsCache,
+ graphQLClient,
+ accessToken?.token ?? null,
+ teamId
+ );
+
+ console.log("tests", testsResults);
return value;
}
diff --git a/src/ui/setup/dynamic/devtools.ts b/src/ui/setup/dynamic/devtools.ts
index 2bdf8a8d9..63d3c3f9f 100644
--- a/src/ui/setup/dynamic/devtools.ts
+++ b/src/ui/setup/dynamic/devtools.ts
@@ -264,6 +264,11 @@ export default async function setupDevtools(store: AppStore, replayClient: Repla
const onPointsReceived = debounce(() => {
store.dispatch(pointsReceived(points.map(({ point, time }) => ({ point, time }))));
store.dispatch(paintsReceived(points.filter(p => "screenShots" in p)));
+ console.log(
+ "onPointsReceived",
+ points.filter(p => "screenShots" in p),
+ points
+ );
points = [];
}, 1_000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment