diff --git a/frontend/app/components/UsabilityTesting/TestEdit.tsx b/frontend/app/components/UsabilityTesting/TestEdit.tsx index aa79655c4..8e732c7c1 100644 --- a/frontend/app/components/UsabilityTesting/TestEdit.tsx +++ b/frontend/app/components/UsabilityTesting/TestEdit.tsx @@ -50,6 +50,11 @@ function TestEdit() { const history = useHistory(); usePageTitle(`Usability Tests | ${uxtestingStore.instance ? 'Edit' : 'Create'}`); + React.useEffect(() => { + if (siteId !== uxtestingStore.instanceCreationSiteId) { + history.push(withSiteId(usabilityTesting(), siteId)); + } + }, [siteId]); React.useEffect(() => { if (testId && testId !== 'new') { uxtestingStore.getTestData(testId).then((inst) => { @@ -76,7 +81,11 @@ function TestEdit() { if (testId && testId !== 'new') { uxtestingStore.updateTest(uxtestingStore.instance!, isPreview).then((testId) => { if (isPreview) { - window.open(`${uxtestingStore.instance!.startingPath}?oruxt=${testId}`, '_blank', 'noopener,noreferrer'); + window.open( + `${uxtestingStore.instance!.startingPath}?oruxt=${testId}`, + '_blank', + 'noopener,noreferrer' + ); } else { toast.success('The usability test is now live and accessible to participants.'); history.push(withSiteId(usabilityTestingView(testId!.toString()), siteId)); @@ -421,14 +430,18 @@ export function Step({ hover?: boolean; }) { const safeTitle = title.length > 120 ? title.slice(0, 120) + '...' : title; - const safeDescription = description && description?.length > 300 ? description.slice(0, 300) + '...' : description; + const safeDescription = + description && description?.length > 300 ? description.slice(0, 300) + '...' : description; return (
-
+
{ind + 1}
@@ -439,7 +452,7 @@ export function Step({
- {buttons} + {buttons}
); diff --git a/frontend/app/components/UsabilityTesting/TestOverview.tsx b/frontend/app/components/UsabilityTesting/TestOverview.tsx index f990a15f0..f9ecae875 100644 --- a/frontend/app/components/UsabilityTesting/TestOverview.tsx +++ b/frontend/app/components/UsabilityTesting/TestOverview.tsx @@ -59,11 +59,20 @@ function TestOverview() { // @ts-ignore const { siteId, testId } = useParams(); const { showModal, hideModal } = useModal(); + const history = useHistory(); const { uxtestingStore } = useStore(); React.useEffect(() => { - uxtestingStore.getTest(testId); - }, [testId]); + const getData = async () => { + try { + await uxtestingStore.getTest(testId); + } catch { + history.push(withSiteId(usabilityTesting(), siteId)); + } + } + + void getData(); + }, [testId, siteId]); if (!uxtestingStore.instance) { return No data.; @@ -390,6 +399,7 @@ const Title = observer(({ testId, siteId }: any) => { // @ts-ignore const getColor = (status) => colors[status]; + const isActive = ['in-progress', 'preview'].includes(uxtestingStore.instance!.status); return (
@@ -423,39 +433,41 @@ const Title = observer(({ testId, siteId }: any) => { {uxtestingStore.instance!.tasks.length} Tasks {' '} - -
- Distribute following link via email or other methods to share the survey with test - participants. + {isActive ? + +
+ Distribute following link via email or other methods to share the survey with test + participants. +
+
+ {`${uxtestingStore.instance!.startingPath}?oruxt=${ + uxtestingStore.instance!.testId + }`} +
+
-
- {`${uxtestingStore.instance!.startingPath}?oruxt=${ - uxtestingStore.instance!.testId - }`} -
- -
- } - > - - + } + > + + + : null} { if (confirmed) { - uxtestingStore.initNewTest(newTestTitle, newTestDescription); + uxtestingStore.initNewTest(newTestTitle, newTestDescription, siteId); setNewTestDescription(''); setNewTestTitle(''); redirect('new'); @@ -212,7 +212,6 @@ function Row({ test, siteId }: { test: UxTListEntry; siteId: string }) { >
- {/*} />*/}
diff --git a/frontend/app/mstore/uxtestingStore.ts b/frontend/app/mstore/uxtestingStore.ts index a46c556f6..bd8e4f0fa 100644 --- a/frontend/app/mstore/uxtestingStore.ts +++ b/frontend/app/mstore/uxtestingStore.ts @@ -53,6 +53,7 @@ export default class UxtestingStore { client = uxtestingService; tests: UxTListEntry[] = []; instance: UxTestInst | null = null; + instanceCreationSiteId = ''; page: number = 1; total: number = 0; pageSize: number = 10; @@ -145,7 +146,8 @@ export default class UxtestingStore { } }; - initNewTest(title: string, description: string) { + initNewTest(title: string, description: string, siteId: string) { + this.instanceCreationSiteId = siteId; const initialData = { title: title, startingPath: 'https://', @@ -265,12 +267,14 @@ export default class UxtestingStore { const statsPr = this.client.fetchTestStats(testId); const taskStatsPr = this.client.fetchTestTaskStats(testId); const sessionsPr = this.client.fetchTestSessions(testId, this.testSessions.page, 10); - Promise.allSettled([testPr, statsPr, taskStatsPr, sessionsPr]).then((results) => { + return Promise.allSettled([testPr, statsPr, taskStatsPr, sessionsPr]).then((results) => { if (results[0].status === 'fulfilled') { const test = results[0].value; if (test) { this.setInstance(new UxTestInst(test)); } + } else { + throw 'Test not found' } if (results[1].status === 'fulfilled') { const stats = results[1].value; @@ -295,9 +299,10 @@ export default class UxtestingStore { this.setTestSessions(result); } } - }); + }).then(() => true) } catch (e) { console.error(e); + return false; } finally { this.setLoading(false); } diff --git a/tracker/tracker/src/main/modules/userTesting/index.ts b/tracker/tracker/src/main/modules/userTesting/index.ts index 09daf5014..2b8a2b36b 100644 --- a/tracker/tracker/src/main/modules/userTesting/index.ts +++ b/tracker/tracker/src/main/modules/userTesting/index.ts @@ -264,6 +264,7 @@ export default class UserTestManager { this.userRecorder.discard() void this.signalTest('skipped') document.body.removeChild(this.bg) + window.close() } if (!inProgress) { this.hideTaskSection()