-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CaseStatusSelect group tests, refactor to script setup, and fix a…
… couple bugs
- Loading branch information
Showing
2 changed files
with
169 additions
and
70 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
75 changes: 75 additions & 0 deletions
75
src/dispatch/static/dispatch/src/tests/CaseStatusSelectGroup.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,75 @@ | ||
import { mount } from "@vue/test-utils" | ||
import { createStore } from "vuex" | ||
import { createVuetify } from "vuetify" | ||
import * as components from "vuetify/components" | ||
import * as directives from "vuetify/directives" | ||
import { describe, expect, it, vi, afterEach, beforeEach } from "vitest" | ||
import CaseStatusSelectGroup from "@/case/CaseStatusSelectGroup.vue" | ||
import CaseApi from "@/case/api" | ||
|
||
const vuetify = createVuetify({ | ||
components, | ||
directives, | ||
}) | ||
|
||
global.ResizeObserver = require("resize-observer-polyfill") | ||
|
||
describe("CaseStatusSelectGroup", () => { | ||
let actions | ||
let mockStore | ||
let wrapper | ||
|
||
beforeEach(() => { | ||
// Mock the store and actions | ||
actions = { | ||
addBeNotification: vi.fn(), | ||
} | ||
|
||
mockStore = createStore({ | ||
modules: { | ||
notification_backend: { | ||
namespaced: true, | ||
actions, | ||
}, | ||
case_management: { | ||
namespaced: true, | ||
state: { | ||
selected: { | ||
id: 1, | ||
status: "New", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
// Mock the API | ||
mockUpdate = vi.spyOn(CaseApi, "update").mockImplementation(() => Promise.resolve()) | ||
|
||
// Mount the component | ||
wrapper = mount(CaseStatusSelectGroup, { | ||
props: { | ||
modelValue: { | ||
status: "New", | ||
created_at: "2022-01-01", | ||
}, | ||
}, | ||
global: { | ||
plugins: [mockStore, vuetify], // 👈 | ||
}, | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
vi.restoreAllMocks() | ||
}) | ||
|
||
it("mounts correctly", () => { | ||
expect(wrapper.exists()).toBe(true) | ||
}) | ||
|
||
it("opens dialog on status click", async () => { | ||
await wrapper.find(".overlap-card").trigger("click") | ||
expect(wrapper.vm.dialogVisible).toBe(true) | ||
}) | ||
}) |