-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only display active roles in CaseParticipantsTab component, add Vites…
…t, and unit test(s) (#2960) * Change commaSeperated filter to only show active participant roles * Add vitest and add unit tests for ParticipantsTab * Try running w/o coverage to resolve error * try to update various componenets in gh actions workflow * add another test case for renouncedRoles not being displayed * Run coverage again * Fix tests to actually test things * Only display active participant roles for incidents * correctly import component * remove debug log lines
- Loading branch information
Showing
9 changed files
with
3,610 additions
and
1,017 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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, | ||
}, | ||
}) |