diff --git a/frontend/specs/admin/reward.spec.ts b/frontend/specs/admin/reward.spec.ts index 24660a7c0..283e4289a 100644 --- a/frontend/specs/admin/reward.spec.ts +++ b/frontend/specs/admin/reward.spec.ts @@ -12,10 +12,20 @@ test('can add/update/delete rewards', async ({ browser }) => { // Update const updatedPrize = faker.random.words(2) + + await adminPage.waitForSelector('text=Edit', { state: 'visible' }); await adminPage.getByText('Edit').first().click() + await adminPage.waitForLoadState('networkidle'); + + await adminPage.waitForSelector('input[placeholder="Prize"]', { state: 'visible' }); await adminPage.getByPlaceholder('Prize').fill(updatedPrize) + + await adminPage.waitForSelector('text=Update reward', { state: 'visible' }); await adminPage.getByText('Update reward').click() + await adminPage.waitForLoadState('networkidle'); // Delete + await adminPage.waitForSelector('text=Delete', { state: 'visible' }); await adminPage.getByText('Delete').first().click() -}) + await adminPage.waitForLoadState('networkidle'); +}) \ No newline at end of file diff --git a/frontend/src/screens/study-landing.tsx b/frontend/src/screens/study-landing.tsx index daf3e6780..e5b7f80c1 100644 --- a/frontend/src/screens/study-landing.tsx +++ b/frontend/src/screens/study-landing.tsx @@ -1,5 +1,5 @@ import { Navigate, NavLink, useLoaderData } from 'react-router-dom' -import { React } from '@common' +import { React, useEffect } from '@common' import { colors } from '@theme' import { LearningPath, ParticipantStudy } from '@api' import { Page } from '@components' @@ -18,16 +18,40 @@ import { Text, Title, } from '@mantine/core'; +import { IconCheck } from '@tabler/icons-react' import Markdown from 'react-markdown' import { useLearningPathStudies } from './learner/studies'; import { CompactStudyCard } from '../components/study/compact-study-card'; +import { notifications } from '@mantine/notifications'; export default function StudyLanding() { const env = useEnvironment() - const study = useLoaderData() as ParticipantStudy const learningPathStudies = useLearningPathStudies(study?.learningPath) + const showEarnedPointsNotification = (points: number) => { + notifications.show({ + title: `You just earned ${points} points!`, + message: 'The longer the study, the more points you earn. Reach 200 points to unlock additional rewards.', + icon: , + color: 'teal', + autoClose: 5000, + styles: () => ({ + description: { fontSize: '12px' }, + }), + }); + }; + + useEffect(() => { + if (study.totalPoints > 0) { + const timer = setTimeout(() => { + showEarnedPointsNotification(study.totalPoints); + }, 100); + + return () => clearTimeout(timer); + } + }, [study.totalPoints]); + if (!study || !study.learningPath) { return } @@ -44,6 +68,7 @@ export default function StudyLanding() { } + ) }