Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show total number of votes and maximum number of votes for all users #488

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

kimsey0
Copy link
Contributor

@kimsey0 kimsey0 commented Dec 9, 2022

Pull Request

#484

Description

Added total number of votes cast by all participants plus max number of votes that can be cast by all participants to the Vote phase.

I did not update the screenshot in the README, since I can't recreate the user setup.

user show a "Your Votes: 1" in the feedback card.](https://github.com/microsoft/vsts-extension-retrospectives/raw/main/documentation/images/desktop/vote-feedback-in-progress.png)

I calculate these numbers in the render method, since this avoids duplicating logic across refreshFeedbackItems and onVoteCasted. Alternatively, the logic can be split up across these two places, the logic in onVoteCasted that calculates currentVoteCount could be moved out into the render method, or all of it could be extracted into a new method. Let me know what you prefer.

There is currently no tests for feedbackBoard, but I'm happy to add some that test this logic. Again, let me know.

Lastly, I simplified some lines using the Optional Chaining operator (?.) from TypeScript 3.7 and the null == undefined equality.

Bug or Feature?

  • Bug fix
  • New feature

Fundamentals

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have updated any relevant documentation accordingly.
  • I have included an update blurb (50 words or less) at the top of CHANGELOG.md,
    to be included with the next release.
    • I have included a link to this PR in that blurb.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Accessibility

  • I have tested my changes on both light and dark themes.
  • I have tested my changes on both mobile and desktop views, when needed.
  • I have included image descriptions and aria-labels where I can.

Screenshots and Logs

Before
Screenshot showing "Votes Used: 1 / 5"

After:
Screenshot showing "Votes Used: 1 / 5 (me), 6 / 10 (team)"

@mindlessroman
Copy link
Member

!!! Thank you so much for the PR! I'll try to look at it as soon as possible, @kimsey0 ! We can also tweak the documentation/images to get that updated to match your work!

As for tests, if you are up for writing some, that'd be great. There should be some basic ones in the repo that you can use as a jumping off point.

@polatengin
Copy link
Collaborator

I liked the idea and implementation @kimsey0 🥳 if you can address comments of @mindlessroman, I'd like to merge this PR asap 😄 if you need help with writing tests, etc. please let us know, we can help you out 👍

@kimsey0
Copy link
Contributor Author

kimsey0 commented Feb 3, 2023

Sorry for the long delay here.

I've added the skeleton for a test of the vote count display, but I'm having trouble with mocking all the different services the feedback board component uses. Specifically, I can't find any tests that mock the retrospective extension backend, and I don't know how you'd like it structured. I think properly testing this is a bit too big for me.

I don't know if one of you would like to take over from the skeleton (I've allowed edits by maintainers), if it can merge as-is (with or without the test changes), or if we should abandon this pull request?


jest.mock('../feedbackBoardMetadataForm', () => mocked({}));
jest.mock('azure-devops-extension-api/Work/WorkClient', () => {
const getTeamIterationsMock = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These mocks are copied from feedbackBoardContainer.test.tsx. I don't know if they're general enough to be moved to the __mocks__ folder. It might also be possible to use a simplified version in these tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this chunk is a copy of the other, I think that's a valid thing to move to __mocks__ folder so there's less duplicate code. It's probably okay to remove any bit that's not explicitly called, but that may be worth doing a local test or two to be sure.

@@ -90,7 +89,7 @@ testColumnsObj[testColumnUuidOne] = {
testColumnsObj[testColumnUuidTwo] = {
columnProperties:
{
id: TooltipOverflowMode,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why this was using this random import, but it seemed like a bug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the diligence! Always appreciated :D

}));

jest.mock('azure-devops-extension-api/Common', () => ({
getClient: (clientClass: typeof Object) => new clientClass(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be moved into __mocks__/azure-devops-extension-api/Common/Common.tsx, but there are some of the other tests that depend on the current behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a more overarching issue to maybe get the tests and components tidied eventually - may be a bit of an undertaking. For now, you should be good to go!

@mindlessroman
Copy link
Member

👏 👏 👏 👏 👏 This is such a good start - I'll try to take a look this weekend!

@kimsey0
Copy link
Contributor Author

kimsey0 commented Apr 27, 2023

@mindlessroman, any news on this? 😄

@mindlessroman
Copy link
Member

@mindlessroman, any news on this? 😄

Thank you for the patience here, the 9-5 stuff was occupying a lot of time. Will try to get this looked at as soon as I can.

@@ -4,6 +4,10 @@ You can find the changelog of the Retrospective Extension below.

_PS: Unfortunately, changelog before v1.0.46 is not available_ 🤦‍♂️

## v1.90.X

* Total number of team votes is now shown together with your own vote count. From [GitHub PR #488](https://github.com/microsoft/vsts-extension-retrospectives/pull/488).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -69,7 +69,7 @@ class FeedbackBoard extends React.Component<FeedbackBoardProps, FeedbackBoardSta
defaultActionItemIteration: '',
hasItems: false,
isDataLoaded: false,
currentVoteCount: (props.board.boardVoteCollection === undefined || props.board.boardVoteCollection === null) ? "0" : (props.board.boardVoteCollection[this.props.userId] === undefined || props.board.boardVoteCollection[this.props.userId] === null) ? "0" : props.board.boardVoteCollection[this.props.userId]?.toString()
currentVoteCount: props.board.boardVoteCollection?.[this.props.userId]?.toString() ?? "0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for trimming this down!

@@ -90,7 +89,7 @@ testColumnsObj[testColumnUuidOne] = {
testColumnsObj[testColumnUuidTwo] = {
columnProperties:
{
id: TooltipOverflowMode,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the diligence! Always appreciated :D


jest.mock('../feedbackBoardMetadataForm', () => mocked({}));
jest.mock('azure-devops-extension-api/Work/WorkClient', () => {
const getTeamIterationsMock = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this chunk is a copy of the other, I think that's a valid thing to move to __mocks__ folder so there's less duplicate code. It's probably okay to remove any bit that's not explicitly called, but that may be worth doing a local test or two to be sure.

}));

jest.mock('azure-devops-extension-api/Common', () => ({
getClient: (clientClass: typeof Object) => new clientClass(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a more overarching issue to maybe get the tests and components tidied eventually - may be a bit of an undertaking. For now, you should be good to go!

});

it(`shows correct vote counts`, () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it(`shows correct vote counts`, () => {
it(`shows correct vote counts when no votes have been cast`, () => {

optional: a test for when one or two different people have cast their votes? If not, this can have a TODO or something similar and can be tackled in a later code snippet.

.flatMap((columnId) => this.state.columns[columnId].columnItems);
const participants = new Set(columnItems.flatMap((columnItem) => Object.keys(columnItem.feedbackItem.voteCollection))).size;

const teamVotes = columnItems
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this solution! Great job!

@mindlessroman mindlessroman added feature: Vote Phase These issues are associated with the Vote and its associated functionality enhancement New feature or request labels May 2, 2023
@mindlessroman mindlessroman linked an issue May 2, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature: Vote Phase These issues are associated with the Vote and its associated functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show total votes used by team together with my votes used
3 participants