diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 262ff405e9..9bfb5561fa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,6 +40,7 @@ jobs: - name: Run Server-side unit tests and generate coverage report run: | cd server + cp portal/apps/workbench/templates/portal/apps/workbench/index.j2 portal/apps/workbench/templates/portal/apps/workbench/index.html poetry run pytest --cov-config=.coveragerc --cov=portal --cov-report=xml -ra - name: Upload coverage to Codecov diff --git a/client/src/redux/reducers/workbench.reducers.js b/client/src/redux/reducers/workbench.reducers.js index bdd295601f..15c45002ee 100644 --- a/client/src/redux/reducers/workbench.reducers.js +++ b/client/src/redux/reducers/workbench.reducers.js @@ -8,7 +8,7 @@ export default function workbench(state = initialState, action) { switch (action.type) { case 'WORKBENCH_INIT': return { - ...initialState, + ...state, loading: true }; case 'WORKBENCH_SUCCESS': diff --git a/server/portal/apps/site_search/views.py b/server/portal/apps/site_search/views.py index 5e3bc89e38..8117fe3e46 100644 --- a/server/portal/apps/site_search/views.py +++ b/server/portal/apps/site_search/views.py @@ -1,5 +1,4 @@ from django.views.generic.base import TemplateView -from django.utils.decorators import method_decorator class IndexView(TemplateView): @@ -10,3 +9,8 @@ class IndexView(TemplateView): def dispatch(self, request, *args, **kwargs): return super(IndexView, self).dispatch(request, *args, **kwargs) + + def get_context_data(self, **kwargs): + context = super(IndexView, self).get_context_data(**kwargs) + context['setup_complete'] = False if self.request.user.is_anonymous else self.request.user.profile.setup_complete + return context diff --git a/server/portal/apps/site_search/views_unit_test.py b/server/portal/apps/site_search/views_unit_test.py new file mode 100644 index 0000000000..aa775a49fd --- /dev/null +++ b/server/portal/apps/site_search/views_unit_test.py @@ -0,0 +1,18 @@ +def test_search_unauthenticated(client, regular_user): + response = client.get('/search/') + assert response.status_code == 200 + assert response.context['setup_complete'] is False + + +def test_search_authenticated_without_setup_complete(client, authenticated_user): + response = client.get('/search/') + assert response.status_code == 200 + assert response.context['setup_complete'] is False + + +def test_search_authenticated_with_setup_complete(client, authenticated_user): + authenticated_user.profile.setup_complete = True + authenticated_user.profile.save() + response = client.get('/search/') + assert response.status_code == 200 + assert response.context['setup_complete']