Skip to content

Commit

Permalink
chore: example of an embedded player
Browse files Browse the repository at this point in the history
  • Loading branch information
agoldis committed Oct 5, 2024
1 parent fd07721 commit 17f88fe
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion apps/web/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { debuggerPlugin } = require('cypress-debugger');

module.exports = defineConfig({
e2e: {
baseUrl: 'https://todomvc.com/examples/backbone',
baseUrl: 'https://todomvc.com/examples/backbone/dist/',
specPattern: 'cypress/e2e/*.spec.js',
supportFile: 'cypress/support/e2e.ts',
setupNodeEvents(on, config) {
Expand Down
4 changes: 4 additions & 0 deletions apps/web/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@radix-ui/react-tooltip": "^1.0.5",
"class-variance-authority": "^0.5.2",
"clsx": "^1.2.1",
"cypress": "^12.8.1",
"cypress": "^12.17.4",
"cypress-debugger": "*",
"lodash": "^4.17.21",
"lucide-react": "^0.162.0",
Expand Down
33 changes: 25 additions & 8 deletions apps/web/src/components/PayloadHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestExecutionResult } from 'cypress-debugger';
import { Loader2 } from 'lucide-react';
import { useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { useCypressEventsContext } from '../context/cypressEvents';
import { useHttpArchiveContext } from '../context/httpArchiveEntries';
import { useReplayerContext } from '../context/replayer';
Expand All @@ -26,13 +26,16 @@ function PayloadHandler() {
)
);

const handleDataChange = (payload: TestExecutionResult | null) => {
setEvents(payload?.cy || []);
setReplayerData(payload?.rr || []);
setHttpArchiveLog(payload?.har || null);
setMeta(payload?.meta ?? null);
setBrowserLogs(payload?.browserLogs || null);
};
const handleDataChange = useCallback(
(payload: TestExecutionResult | null) => {
setEvents(payload?.cy || []);
setReplayerData(payload?.rr || []);
setHttpArchiveLog(payload?.har || null);
setMeta(payload?.meta ?? null);
setBrowserLogs(payload?.browserLogs || null);
},
[setEvents, setReplayerData, setHttpArchiveLog, setMeta, setBrowserLogs]
);

const handleFileChange = ({
filename,
Expand Down Expand Up @@ -71,6 +74,20 @@ function PayloadHandler() {
}
}, [queryParam]); // eslint-disable-line

useEffect(() => {
if (typeof window === 'undefined') return;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if ((window as any).trace) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// handleDataChange((window as any).trace);
// parse base64
const str = (window as any).trace;
const payload = JSON.parse(str);
handleDataChange(payload);
setOrigin('trace');
}
}, []);

if (loading) {
return (
<div className="flex items-center justify-center h-full">
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 17f88fe

Please sign in to comment.