Merge branch 'develop' of https://github.com/wh1te909/tacticalrmm into develop

This commit is contained in:
wh1te909 2020-06-01 03:05:55 +00:00
commit f91afbf872
3 changed files with 42 additions and 29 deletions

View File

@ -249,6 +249,7 @@ export default {
methods: {
checkAlert(id, alert_type, action) {
const data = {};
if (alert_type === "Email") {
data.email_alert = action;
} else {
@ -258,7 +259,7 @@ export default {
const act = action ? "enabled" : "disabled";
const color = action ? "positive" : "warning";
this.$store
.dispatch("editCheckAlert", id, data)
.dispatch("editCheckAlert", { pk: id, data })
.then(r => {
this.$q.notify({
color: color,

View File

@ -159,7 +159,7 @@ export const store = new Vuex.Store({
loadAgentServices(context, agentpk) {
return axios.get(`/services/${agentpk}/services/`);
},
editCheckAlert(context, pk, data) {
editCheckAlert(context, {pk, data}) {
return axios.patch(`/checks/${pk}/check/`, data);
},
deleteCheck(context, pk) {

View File

@ -190,7 +190,6 @@ describe("PolicyChecksTab.vue with policy selected and checks", () => {
// Runs before every test
beforeEach(() => {
// Create the Test store
// Create the Test store
state = {
checks: [
@ -219,7 +218,7 @@ describe("PolicyChecksTab.vue with policy selected and checks", () => {
};
rootActions = {
editCheckAlertAction: jest.fn(),
editCheckAlert: jest.fn(),
deleteCheck: jest.fn()
};
@ -330,7 +329,7 @@ describe("PolicyChecksTab.vue with policy selected and checks", () => {
//Get OK button on confirmation dialog and click it
await bodyWrapper.findAll(".q-btn").wrappers[1].trigger("click");
expect(rootActions.deleteCheck).toHaveBeenCalledWith(expect.anything(), {pk: 1, checktype:"diskspace"});
expect(rootActions.deleteCheck).toHaveBeenCalledWith(expect.anything(), 1);
expect(actions.loadPolicyChecks).toHaveBeenCalled();
});
@ -343,22 +342,29 @@ describe("PolicyChecksTab.vue with policy selected and checks", () => {
//Enable Text Alert
await row.trigger("click");
expect(rootActions.editCheckAlertAction).toHaveBeenCalledWith(expect.anything(), {
alertType: "text",
checkid: 1,
category: "diskspace",
action: "enabled"
});
expect(rootActions.editCheckAlert).toHaveBeenCalledWith(
expect.anything(),
{
pk: 1,
data: {
text_alert: true
}
}
);
//Disable Text Alert
await row.trigger("click");
expect(rootActions.editCheckAlertAction).toHaveBeenCalledWith(expect.anything(), {
alertType: "text",
checkid: 1,
category: "diskspace",
action: "disabled"
});
expect(rootActions.editCheckAlert).toHaveBeenCalledWith(
expect.anything(),
{
pk: 1,
data: {
text_alert: false
}
}
);
});
it("enables and disables email alerts for check", async () => {
@ -369,22 +375,28 @@ describe("PolicyChecksTab.vue with policy selected and checks", () => {
//Enable Text Alert
await row.trigger("click");
expect(rootActions.editCheckAlertAction).toHaveBeenCalledWith(expect.anything(), {
alertType: "email",
checkid: 1,
category: "diskspace",
action: "enabled"
});
expect(rootActions.editCheckAlert).toHaveBeenCalledWith(
expect.anything(),
{
pk: 1,
data: {
email_alert: true
}
}
);
//Disable Text Alert
await row.trigger("click");
expect(rootActions.editCheckAlertAction).toHaveBeenCalledWith(expect.anything(), {
alertType: "email",
checkid: 1,
category: "diskspace",
action: "disabled"
});
expect(rootActions.editCheckAlert).toHaveBeenCalledWith(
expect.anything(),
{
pk: 1,
data: {
email_alert: false
}
}
);
});
/* TODO: test @close and @hide events */