From 572d69615f4e50cfbb17471c572271db34dfcdfc Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Mon, 13 Dec 2021 11:18:23 +0000 Subject: [PATCH] fix: show add review/request button to community members This change returns community information for a user's default persona, which allows the button to be displayed. Without it, the user appears as not being a member of any community, so the app would never show the button. I'm not sure if there's any other logic that depends on this information, so there's a chance it might fix/create bugs in untested code. Fixes #429 --- integration/src/browser/add-a-request-to-a-community.spec.ts | 4 +--- integration/src/browser/add-a-review-to-a-community.spec.ts | 4 +--- src/backend/controllers/user.js | 1 + 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/integration/src/browser/add-a-request-to-a-community.spec.ts b/integration/src/browser/add-a-request-to-a-community.spec.ts index d3bc718f..85714f76 100644 --- a/integration/src/browser/add-a-request-to-a-community.spec.ts +++ b/integration/src/browser/add-a-request-to-a-community.spec.ts @@ -3,7 +3,7 @@ import { screenshot } from './utils'; test.asACommunityMember( 'can add a request to a community', - async ({ community, page, preprint }, { fixme }) => { + async ({ community, page, preprint }) => { await page.goto(`/communities/${community.slug}`); const addRequestButton = page.locator('button:has-text("Add Request")'); @@ -11,8 +11,6 @@ test.asACommunityMember( '.MuiPaper-root:has-text("Preprints with PREreviews or requests for PREreviews")', ); - fixme(true, '"Add Request" button is not shown for members'); - await expect(addRequestButton).toBeVisible(); expect(await screenshot(preprints)).toMatchSnapshot( 'empty-with-button.png', diff --git a/integration/src/browser/add-a-review-to-a-community.spec.ts b/integration/src/browser/add-a-review-to-a-community.spec.ts index ec332c0c..ec5794ad 100644 --- a/integration/src/browser/add-a-review-to-a-community.spec.ts +++ b/integration/src/browser/add-a-review-to-a-community.spec.ts @@ -3,7 +3,7 @@ import { screenshot } from './utils'; test.asACommunityMember( 'can add a review to a community', - async ({ community, page, preprint }, { fixme }) => { + async ({ community, page, preprint }) => { await page.goto(`/communities/${community.slug}`); const addReviewButton = page.locator('button:has-text("Add PREreview")'); @@ -11,8 +11,6 @@ test.asACommunityMember( '.MuiPaper-root:has-text("Preprints with PREreviews")', ); - fixme(true, '"Add PREreview" button is not shown for members'); - await expect(addReviewButton).toBeVisible(); expect(await screenshot(preprints)).toMatchSnapshot( 'empty-with-button.png', diff --git a/src/backend/controllers/user.js b/src/backend/controllers/user.js index 3e02ccee..bc09b70f 100644 --- a/src/backend/controllers/user.js +++ b/src/backend/controllers/user.js @@ -77,6 +77,7 @@ export default function controller(users, contacts, keys, thisUser) { 'contacts', 'keys', 'defaultPersona.badges', + 'defaultPersona.communities', ]); } catch (err) { log.debug(err);