diff --git a/backend/experiment/actions/tests/test_action_utils.py b/backend/experiment/actions/tests/test_action_utils.py index 18d84c89d..8ab2f9173 100644 --- a/backend/experiment/actions/tests/test_action_utils.py +++ b/backend/experiment/actions/tests/test_action_utils.py @@ -19,9 +19,9 @@ def setUp(self) -> None: def test_collection_url(self): self.assertEqual(get_current_collection_url(self.session), None) self.session.save_json_data({COLLECTION_KEY: 'superdupercollection'}) - self.assertEqual(get_current_collection_url(self.session), '/collection/superdupercollection') + self.assertEqual(get_current_collection_url(self.session), '/superdupercollection') self.participant.participant_id_url = 'participant42' - self.assertEqual(get_current_collection_url(self.session), '/collection/superdupercollection?participant_id=participant42') + self.assertEqual(get_current_collection_url(self.session), '/superdupercollection?participant_id=participant42') def test_randomize_playhead(self): min_jitter = 5 diff --git a/backend/experiment/actions/utils.py b/backend/experiment/actions/utils.py index 652b50272..3fe14a035 100644 --- a/backend/experiment/actions/utils.py +++ b/backend/experiment/actions/utils.py @@ -18,9 +18,9 @@ def get_current_collection_url(session: Session) -> str: if session.participant.participant_id_url: participant_id_url = session.participant.participant_id_url - return f'/collection/{collection_slug}?participant_id={participant_id_url}' + return f'/{collection_slug}?participant_id={participant_id_url}' else: - return f'/collection/{collection_slug}' + return f'/{collection_slug}' def final_action_with_optional_button(session, final_text='', title=_('End'), button_text=_('Continue')): diff --git a/backend/experiment/admin.py b/backend/experiment/admin.py index 53ebe2277..65fb05f5b 100644 --- a/backend/experiment/admin.py +++ b/backend/experiment/admin.py @@ -225,7 +225,7 @@ class ExperimentCollectionAdmin( def slug_link(self, obj): dev_mode = settings.DEBUG is True - url = f"http://localhost:3000/collection/{obj.slug}" if dev_mode else f"/collection/{obj.slug}" + url = f"http://localhost:3000/{obj.slug}" if dev_mode else f"/{obj.slug}" return format_html( f'{obj.slug} ') diff --git a/backend/experiment/rules/tests/test_beat_alignment.py b/backend/experiment/rules/tests/test_beat_alignment.py index 9c44d39e7..b78fc3a7a 100644 --- a/backend/experiment/rules/tests/test_beat_alignment.py +++ b/backend/experiment/rules/tests/test_beat_alignment.py @@ -43,7 +43,7 @@ def load_json(self, response): return json.loads(response.content) def test_block(self): - response = self.client.get('/experiment/ba/') + response = self.client.get('/experiment/block/ba/') response_json = self.load_json(response) self.assertTrue({'id', 'slug', 'name', 'class_name', 'rounds', 'playlists', 'next_round', 'loading_text'} <= response_json.keys()) diff --git a/backend/experiment/tests/test_views.py b/backend/experiment/tests/test_views.py index 7e10b934e..f9a2c0f8a 100644 --- a/backend/experiment/tests/test_views.py +++ b/backend/experiment/tests/test_views.py @@ -78,7 +78,7 @@ def test_get_experiment_collection(self): session['participant_id'] = self.participant.id session.save() # check that first_experiments is returned correctly - response = self.client.get('/experiment/collection/test_series/') + response = self.client.get('/experiment/test_series/') self.assertEqual(response.json().get( 'nextBlock').get('slug'), 'block1') # create session @@ -87,7 +87,7 @@ def test_get_experiment_collection(self): participant=self.participant, finished_at=timezone.now() ) - response = self.client.get('/experiment/collection/test_series/') + response = self.client.get('/experiment/test_series/') self.assertIn(response.json().get('nextBlock').get( 'slug'), ('block2', 'block3')) self.assertEqual(response.json().get('dashboard'), []) @@ -101,7 +101,7 @@ def test_get_experiment_collection(self): participant=self.participant, finished_at=timezone.now() ) - response = self.client.get('/experiment/collection/test_series/') + response = self.client.get('/experiment/test_series/') response_json = response.json() self.assertEqual(response_json.get( 'nextBlock').get('slug'), 'block4') @@ -117,7 +117,7 @@ def test_get_experiment_collection(self): def test_get_experiment_collection_not_found(self): # if ExperimentCollection does not exist, return 404 - response = self.client.get('/experiment/collection/not_found/') + response = self.client.get('/experiment/not_found/') self.assertEqual(response.status_code, 404) def test_get_experiment_collection_inactive(self): @@ -125,7 +125,7 @@ def test_get_experiment_collection_inactive(self): collection = ExperimentCollection.objects.get(slug='test_series') collection.active = False collection.save() - response = self.client.get('/experiment/collection/test_series/') + response = self.client.get('/experiment/test_series/') self.assertEqual(response.status_code, 404) def test_experiment_collection_with_dashboard(self): @@ -144,7 +144,7 @@ def test_experiment_collection_with_dashboard(self): intermediate_phase.dashboard = True intermediate_phase.save() # check that first_experiments is returned correctly - response = self.client.get('/experiment/collection/test_series/') + response = self.client.get('/experiment/test_series/') self.assertEqual(type(response.json().get('dashboard')), list) def test_experiment_collection_total_score(self): @@ -246,7 +246,7 @@ def test_get_block(self): Session(block=block, participant=participant, finished_at=timezone.now()) for index in range(3) ]) - response = self.client.get('/experiment/test-block/') + response = self.client.get('/experiment/block/test-block/') self.assertEqual( response.json()['slug'], 'test-block' diff --git a/backend/experiment/urls.py b/backend/experiment/urls.py index 0892c56fc..940c8aea8 100644 --- a/backend/experiment/urls.py +++ b/backend/experiment/urls.py @@ -9,9 +9,9 @@ # Experiment path('render_markdown/', render_markdown, name='render_markdown'), path('validate_playlist/', validate_block_playlist, name='validate_block_playlist'), - path('/', get_block, name='experiment'), - path('/feedback/', post_feedback, name='feedback'), - path('collection//', get_experiment_collection, + path('block//', get_block, name='block'), + path('block//feedback/', post_feedback, name='feedback'), + path('/', get_experiment_collection, name='experiment_collection'), # Robots.txt diff --git a/e2e/tests/smoke/test_thkids.py b/e2e/tests/smoke/test_thkids.py index e382ada13..886e511e7 100644 --- a/e2e/tests/smoke/test_thkids.py +++ b/e2e/tests/smoke/test_thkids.py @@ -7,7 +7,7 @@ class TestTHKids(BaseTest): def test_th_kids(self): - self.driver.get(f"{self.base_url}/collection/thkids") + self.driver.get(f"{self.base_url}/thkids") dashboard = WebDriverWait(self.driver, 5).until(expected_conditions.presence_of_element_located((By.CLASS_NAME, "dashboard"))) print("\nāœ… The frontend is working and the thkids collection page is working!") diff --git a/frontend/src/API.ts b/frontend/src/API.ts index 48c8519b4..134fee6e0 100644 --- a/frontend/src/API.ts +++ b/frontend/src/API.ts @@ -14,11 +14,11 @@ axios.defaults.withCredentials = true; // API endpoints export const URLS = { block: { - get: (slug: string) => "/experiment/" + slug + "/", - feedback: (slug: string) => "/experiment/" + slug + "/feedback/", + get: (slug: string) => "/experiment/block/" + slug + "/", + feedback: (slug: string) => "/experiment/block/" + slug + "/feedback/", }, experiment_collection: { - get: (slug: string) => `/experiment/collection/${slug}/` + get: (slug: string) => `/experiment/${slug}/` }, participant: { current: "/participant/", diff --git a/frontend/src/components/App/App.tsx b/frontend/src/components/App/App.tsx index afdda65bc..29990116c 100644 --- a/frontend/src/components/App/App.tsx +++ b/frontend/src/components/App/App.tsx @@ -80,12 +80,12 @@ const App = () => { - {/* Experiment Collection */} - - {/* Block */} + {/* Experiment */} + + {/* Store profile */} diff --git a/frontend/src/components/ExperimentCollection/ExperimentCollection.test.tsx b/frontend/src/components/ExperimentCollection/ExperimentCollection.test.tsx index 8d6a5fc82..5f6ceb2e7 100644 --- a/frontend/src/components/ExperimentCollection/ExperimentCollection.test.tsx +++ b/frontend/src/components/ExperimentCollection/ExperimentCollection.test.tsx @@ -1,6 +1,6 @@ -import React from 'react'; import { MemoryRouter } from 'react-router-dom'; import { render, screen, waitFor } from '@testing-library/react'; +import { it, expect, describe } from 'vitest'; import MockAdapter from "axios-mock-adapter"; import axios from 'axios'; diff --git a/frontend/src/components/ExperimentCollection/ExperimentCollectionAbout/ExperimentCollectionAbout.test.tsx b/frontend/src/components/ExperimentCollection/ExperimentCollectionAbout/ExperimentCollectionAbout.test.tsx index 779e537f6..f237032a0 100644 --- a/frontend/src/components/ExperimentCollection/ExperimentCollectionAbout/ExperimentCollectionAbout.test.tsx +++ b/frontend/src/components/ExperimentCollection/ExperimentCollectionAbout/ExperimentCollectionAbout.test.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import { BrowserRouter as Router } from 'react-router-dom'; +import { it, expect, describe } from 'vitest'; import ExperimentCollectionAbout from './ExperimentCollectionAbout'; @@ -29,6 +30,6 @@ describe('ExperimentCollectionAbout', () => { ) expect(screen.getByRole('link').innerHTML).toContain('Terug'); - expect(screen.getByRole('link').getAttribute('href')).toBe('/collection/some_slug'); + expect(screen.getByRole('link').getAttribute('href')).toBe('/some_slug'); }); -}) \ No newline at end of file +}) diff --git a/frontend/src/components/ExperimentCollection/ExperimentCollectionAbout/ExperimentCollectionAbout.tsx b/frontend/src/components/ExperimentCollection/ExperimentCollectionAbout/ExperimentCollectionAbout.tsx index 8e01b1ab1..a6c229406 100644 --- a/frontend/src/components/ExperimentCollection/ExperimentCollectionAbout/ExperimentCollectionAbout.tsx +++ b/frontend/src/components/ExperimentCollection/ExperimentCollectionAbout/ExperimentCollectionAbout.tsx @@ -13,7 +13,7 @@ export const ExperimentCollectionAbout: React.FC return (
- + Terug @@ -24,4 +24,4 @@ export const ExperimentCollectionAbout: React.FC ); }; -export default ExperimentCollectionAbout; \ No newline at end of file +export default ExperimentCollectionAbout; diff --git a/frontend/src/components/ExperimentCollection/ExperimentCollectionDashboard/ExperimentCollectionDashboard.test.tsx b/frontend/src/components/ExperimentCollection/ExperimentCollectionDashboard/ExperimentCollectionDashboard.test.tsx index 0ba321263..a81456f4b 100644 --- a/frontend/src/components/ExperimentCollection/ExperimentCollectionDashboard/ExperimentCollectionDashboard.test.tsx +++ b/frontend/src/components/ExperimentCollection/ExperimentCollectionDashboard/ExperimentCollectionDashboard.test.tsx @@ -89,7 +89,7 @@ describe('ExperimentCollectionDashboard', () => { ); await waitFor(() => { expect(screen.getByRole('menu')).toBeTruthy(); - expect(screen.getByRole('menu').querySelector('a').getAttribute('href')).toBe('/some_slug'); + expect(screen.getByRole('menu').querySelector('a').getAttribute('href')).toBe('/block/some_slug'); }); }); @@ -101,7 +101,7 @@ describe('ExperimentCollectionDashboard', () => { ); await waitFor(() => { expect(screen.getByRole('menu')).toBeTruthy(); - expect(screen.getByRole('menu').querySelector('a').getAttribute('href')).toBe('/some_slug?participant_id=some_id'); + expect(screen.getByRole('menu').querySelector('a').getAttribute('href')).toBe('/block/some_slug?participant_id=some_id'); }); }); diff --git a/frontend/src/components/ExperimentCollection/ExperimentCollectionDashboard/ExperimentCollectionDashboard.tsx b/frontend/src/components/ExperimentCollection/ExperimentCollectionDashboard/ExperimentCollectionDashboard.tsx index dfb572d93..1738ba0a1 100644 --- a/frontend/src/components/ExperimentCollection/ExperimentCollectionDashboard/ExperimentCollectionDashboard.tsx +++ b/frontend/src/components/ExperimentCollection/ExperimentCollectionDashboard/ExperimentCollectionDashboard.tsx @@ -23,7 +23,7 @@ export const ExperimentCollectionDashboard: React.FC `/${slug}${participantIdUrl ? `?participant_id=${participantIdUrl}` : ""}`; + const getExperimentHref = (slug: string) => `/block/${slug}${participantIdUrl ? `?participant_id=${participantIdUrl}` : ""}`; return (
diff --git a/frontend/src/components/ExperimentCollection/Header/Header.tsx b/frontend/src/components/ExperimentCollection/Header/Header.tsx index 4c6a40297..900a9dfee 100644 --- a/frontend/src/components/ExperimentCollection/Header/Header.tsx +++ b/frontend/src/components/ExperimentCollection/Header/Header.tsx @@ -45,8 +45,8 @@ export const Header: React.FC = ({
{scoreDisplayConfig && totalScore !== 0 && ( diff --git a/frontend/src/components/Question/__snapshots__/Question.test.tsx.snap b/frontend/src/components/Question/__snapshots__/Question.test.tsx.snap new file mode 100644 index 000000000..ecd6b023b --- /dev/null +++ b/frontend/src/components/Question/__snapshots__/Question.test.tsx.snap @@ -0,0 +1,473 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Question Component > renders different question views based on the view prop 1`] = ` +
+

+ Test Question +

+
+
+
+ + +
+
+
+
+`; + +exports[`Question Component > renders different question views based on the view prop 2`] = ` +
+

+ Test Question +

+
+
+
+ + + One + +
+
+ + + Two + +
+
+
+
+`; + +exports[`Question Component > renders different question views based on the view prop 3`] = ` +
+

+ Test Question +

+
+
+ +
+
+
+`; + +exports[`Question Component > renders different question views based on the view prop 4`] = ` +
+

+ Test Question +

+
+
+
+
+ + +
+
+
+ Select... +
+
+ +
+
+
+ + +
+
+
+
+
+
+
+`; + +exports[`Question Component > renders different question views based on the view prop 5`] = ` +
+

+ Test Question +

+
+
+
+ + + One + +
+
+ + + Two + +
+
+
+
+`; + +exports[`Question Component > renders different question views based on the view prop 6`] = ` +
+

+ Test Question +

+
+
+

+ ā†” +

+
+
+
+
+
+
    +
+
+ + +
+
+
+
+`; + +exports[`Question Component > renders different question views based on the view prop 7`] = ` +
+

+ Test Question +

+
+
+
+

+ +

+
+
+
+
+
+
+
    +
+
+
+ + One + + + Two + +
+
+
+
+
+`; + +exports[`Question Component > renders different question views based on the view prop 8`] = ` +
+

+ Test Question +

+
+
+
+

+ +

+
+
+
+
+
+
+
    +
+
+
+
+`; + +exports[`Question Component > renders different question views based on the view prop 9`] = ` +
+

+ Test Question +

+
+
+ +
+
+
+`; diff --git a/frontend/src/config.ts b/frontend/src/config.ts index b66ac6241..71322e29e 100644 --- a/frontend/src/config.ts +++ b/frontend/src/config.ts @@ -28,9 +28,9 @@ export const URLS = { about: "/about", profile: "/profile", storeProfile: "/profile/store", - block: "/:slug", - experimentCollectionAbout: "/collection/:slug/about", - experimentCollection: "/collection/:slug", + block: "/block/:slug", + experimentCollectionAbout: "/:slug/about", + experimentCollection: "/:slug", internalRedirect: "/redirect/:path", reloadParticipant: "/participant/reload/:id/:hash", theme: "/theme/:id", diff --git a/frontend/src/stories/Header.stories.tsx b/frontend/src/stories/Header.stories.tsx index 37b54b517..2d8ba7fee 100644 --- a/frontend/src/stories/Header.stories.tsx +++ b/frontend/src/stories/Header.stories.tsx @@ -15,7 +15,7 @@ function getHeaderData(overrides = {}) { description: "

Experiment ABC

This is the experiment description

", nextBlockSlug: '/th1-mozart', nextBlockButtonText: 'Volgende experiment', - collectionSlug: '/collection/thkids', + collectionSlug: '/thkids', aboutButtonText: 'Over ons', totalScore: 420, scoreDisplayConfig: {