This repository was archived by the owner on Sep 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 629
Only display active roles in CaseParticipantsTab component, add Vitest, and unit test(s) #2960
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
27e71f6
Change commaSeperated filter to only show active participant roles
wssheldon 4fe35c1
Add vitest and add unit tests for ParticipantsTab
wssheldon 8b23027
Try running w/o coverage to resolve error
wssheldon 36f05ad
try to update various componenets in gh actions workflow
wssheldon 73e24f2
add another test case for renouncedRoles not being displayed
wssheldon 78690c2
Run coverage again
wssheldon 6083a37
Fix tests to actually test things
wssheldon 4b3a1d1
Only display active participant roles for incidents
wssheldon d5b3f36
correctly import component
wssheldon 76ae9b5
Merge branch 'master' into ui/active-roles
wssheldon 74f01d7
remove debug log lines
wssheldon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/dispatch/static/dispatch/tests/participants-tab.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /** | ||
| * @vitest-environment jsdom | ||
| */ | ||
|
|
||
| import { describe, expect, it, vi } from "vitest" | ||
| import { createLocalVue, shallowMount } from "@vue/test-utils" | ||
| import CaseParticipantsTab from "src/case/ParticipantsTab.vue" | ||
| import { activeRoles } from "src/filters" | ||
|
|
||
| describe("CaseParticipantsTab", () => { | ||
| const localVue = createLocalVue() | ||
| localVue.filter("activeRoles", activeRoles) | ||
|
|
||
| vi.mock("vuex-map-fields", () => ({ | ||
| getterType: vi.fn(), | ||
| mapFields: vi.fn(), | ||
| })) | ||
|
|
||
| const participants = [ | ||
| { | ||
| id: 1, | ||
| individual: { | ||
| name: "John Doe", | ||
| weblink: "https://example.com/john-doe", | ||
| }, | ||
| participant_roles: [ | ||
| { role: "Participant", renounced_at: null }, | ||
| { role: "Reporter", renounced_at: "2022-01-01T00:00:00.000Z" }, | ||
| ], | ||
| team: "Team A", | ||
| location: "Location A", | ||
| }, | ||
| { | ||
| id: 2, | ||
| individual: { | ||
| name: "Jane Doe", | ||
| weblink: "https://example.com/jane-doe", | ||
| }, | ||
| participant_roles: [{ role: "Assignee", renounced_at: null }], | ||
| team: "Team B", | ||
| location: "Location B", | ||
| }, | ||
| ] | ||
|
|
||
| const computed = { | ||
| participants: () => participants, | ||
| } | ||
|
|
||
| it("assert if there's participants that we render them", () => { | ||
| const wrapper = shallowMount(CaseParticipantsTab, { localVue, computed }) | ||
| const participantListItems = wrapper.findAll("v-list-item-title").wrappers | ||
| expect(participantListItems).to.have.lengthOf(2) | ||
| }) | ||
|
|
||
| it("displays active roles", () => { | ||
| const wrapper = shallowMount(CaseParticipantsTab, { localVue, computed }) | ||
| const participantListItems = wrapper.findAll("v-list-item-title").wrappers | ||
|
|
||
| participantListItems.forEach((participantListItem, index) => { | ||
| const participant = participants[index] | ||
| const activeRoles = participant.participant_roles | ||
| .filter((role) => !role.renounced_at) | ||
| .map((role) => role.role) | ||
| .join(", ") | ||
|
|
||
| expect(participantListItem.text()).to.include(activeRoles) | ||
| }) | ||
| }) | ||
|
|
||
| it("does not display renounced roles", () => { | ||
| const wrapper = shallowMount(CaseParticipantsTab, { localVue, computed }) | ||
| const participantListItems = wrapper.findAll("v-list-item-title").wrappers | ||
|
|
||
| participantListItems.forEach((participantListItem, index) => { | ||
| const participant = participants[index] | ||
| const renouncedRoles = participant.participant_roles | ||
| .filter((role) => role.renounced_at) | ||
| .map((role) => role.role) | ||
| .join(", ") | ||
|
|
||
| if (renouncedRoles) { | ||
| expect(participantListItem.text()).to.not.include(renouncedRoles) | ||
| } | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from "vite" | ||
| import vue from "@vitejs/plugin-vue2" | ||
|
|
||
| // https://vitejs.dev/config/ | ||
| export default defineConfig({ | ||
| plugins: [vue()], | ||
| test: { | ||
| globals: true, | ||
| }, | ||
| }) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.