Skip to content

Commit

Permalink
FP-891 fix external workbench access disrupted by onboarding (#358)
Browse files Browse the repository at this point in the history
* Change only loading part of state when fetching workbench

* Pass context data which has setup_complete

* Handle anonymous users

* Add unit tests

* Build/install client during CI to generate templates

* Add build client step for template generation to CI

* Refactor github actions to client install is defined in standalone action

* Run actions/checkout in local action

* Fix action name/path

* Revert attempt at composite action

Not supported yet: actions/runner#646

* Copy template for unit testing instead of client building it

* Fix copy command
  • Loading branch information
nathanfranklin authored and wesleyboar committed Jan 7, 2022
1 parent 525fc34 commit 1ea3a60
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client/src/redux/reducers/workbench.reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
6 changes: 5 additions & 1 deletion server/portal/apps/site_search/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.views.generic.base import TemplateView
from django.utils.decorators import method_decorator


class IndexView(TemplateView):
Expand All @@ -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
18 changes: 18 additions & 0 deletions server/portal/apps/site_search/views_unit_test.py
Original file line number Diff line number Diff line change
@@ -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']

0 comments on commit 1ea3a60

Please sign in to comment.