-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Links in MS Teams notifications were incorrect. Note: the fix only wo…
…rks for new notification destinations. Please recreate existing notification destinations in *Quality-time* to get correct links in MS Teams notifications. Fixes #7614.
- Loading branch information
Showing
12 changed files
with
107 additions
and
93 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
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
89 changes: 43 additions & 46 deletions
89
components/frontend/src/notification/NotificationDestinations.test.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 |
---|---|---|
@@ -1,77 +1,74 @@ | ||
import React from 'react'; | ||
import { act, fireEvent, render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { EDIT_REPORT_PERMISSION, Permissions } from '../context/Permissions'; | ||
import { NotificationDestinations } from './NotificationDestinations'; | ||
import * as fetch_server_api from '../api/fetch_server_api'; | ||
import React from "react"; | ||
import { fireEvent, render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { EDIT_REPORT_PERMISSION, Permissions } from "../context/Permissions"; | ||
import { NotificationDestinations } from "./NotificationDestinations"; | ||
import * as fetch_server_api from "../api/fetch_server_api"; | ||
|
||
jest.mock("../api/fetch_server_api.js") | ||
|
||
const notification_destinations = { | ||
destination_uuid1: { | ||
webhook: "", | ||
name: "new", | ||
url: "" | ||
} | ||
}; | ||
|
||
function renderNotificationDestinations(destinations) { | ||
render( | ||
<Permissions.Provider value={[EDIT_REPORT_PERMISSION]}> | ||
<NotificationDestinations destinations={destinations} report_uuid={"report_uuid"} reload={() => {/* No need to reload during tests */ }} /> | ||
<NotificationDestinations | ||
destinations={destinations} | ||
report_uuid={"report_uuid"} | ||
reload={() => {/* No need to reload during tests */ }} | ||
/> | ||
</Permissions.Provider> | ||
) | ||
} | ||
|
||
it('creates the first notification destination when the add notification destination button is clicked', async () => { | ||
it("creates the first notification destination when the add notification destination button is clicked", async () => { | ||
fetch_server_api.fetch_server_api = jest.fn().mockResolvedValue({ ok: true }); | ||
await act(async () => { | ||
renderNotificationDestinations({}) | ||
}); | ||
await act(async () => { | ||
fireEvent.click(screen.getByText(/Add notification destination/)); | ||
}); | ||
expect(fetch_server_api.fetch_server_api).toHaveBeenCalledWith('post', `report/report_uuid/notification_destination/new`, {}); | ||
renderNotificationDestinations({}); | ||
fireEvent.click(screen.getByText(/Add notification destination/)); | ||
expect(fetch_server_api.fetch_server_api).toHaveBeenCalledWith( | ||
"post", "report/report_uuid/notification_destination/new", { report_url: "http://localhost/" } | ||
); | ||
}); | ||
|
||
it('creates a new notification destination when the add notification destination button is clicked', async () => { | ||
it("creates a new notification destination when the add notification destination button is clicked", async () => { | ||
fetch_server_api.fetch_server_api = jest.fn().mockResolvedValue({ ok: true }); | ||
await act(async () => { | ||
renderNotificationDestinations(notification_destinations) | ||
}); | ||
await act(async () => { | ||
fireEvent.click(screen.getByText(/Add notification destination/)); | ||
}); | ||
expect(fetch_server_api.fetch_server_api).toHaveBeenCalledWith('post', `report/report_uuid/notification_destination/new`, {}); | ||
renderNotificationDestinations(notification_destinations) | ||
fireEvent.click(screen.getByText(/Add notification destination/)); | ||
expect(fetch_server_api.fetch_server_api).toHaveBeenCalledWith( | ||
"post", "report/report_uuid/notification_destination/new", { report_url: "http://localhost/" } | ||
); | ||
}); | ||
|
||
it('edits notification destination name attribute when it is changed in the input field', async () => { | ||
it("edits notification destination name attribute when it is changed in the input field", async () => { | ||
fetch_server_api.fetch_server_api = jest.fn().mockResolvedValue({ ok: true }); | ||
await act(async () => { | ||
renderNotificationDestinations(notification_destinations) | ||
}); | ||
await userEvent.type(screen.getByLabelText(/Name/), ' changed{Enter}'); | ||
|
||
expect(fetch_server_api.fetch_server_api).toHaveBeenCalledWith('post', `report/report_uuid/notification_destination/destination_uuid1/attributes`, { name: "new changed" }); | ||
renderNotificationDestinations(notification_destinations) | ||
await userEvent.type(screen.getByLabelText(/Name/), " changed{Enter}"); | ||
expect(fetch_server_api.fetch_server_api).toHaveBeenCalledWith( | ||
"post", "report/report_uuid/notification_destination/destination_uuid1/attributes", { name: "new changed" } | ||
); | ||
}); | ||
|
||
it('edits multiple notification destination attributes when they are changed in the input fields', async () => { | ||
it("edits multiple notification destination attributes when they are changed in the input fields", async () => { | ||
fetch_server_api.fetch_server_api = jest.fn().mockResolvedValue({ ok: true }); | ||
await act(async () => { | ||
renderNotificationDestinations(notification_destinations) | ||
}); | ||
await userEvent.type(screen.getByPlaceholderText(/https:\/\/example/), 'new.webhook.com{Enter}'); | ||
|
||
expect(fetch_server_api.fetch_server_api).toHaveBeenCalledWith('post', `report/report_uuid/notification_destination/destination_uuid1/attributes`, { webhook: "new.webhook.com", url: "http://localhost/" }); | ||
renderNotificationDestinations(notification_destinations) | ||
await userEvent.type(screen.getByPlaceholderText(/https:\/\/example/), "new.webhook.com{Enter}"); | ||
expect(fetch_server_api.fetch_server_api).toHaveBeenCalledWith( | ||
"post", | ||
"report/report_uuid/notification_destination/destination_uuid1/attributes", | ||
{ webhook: "new.webhook.com", url: "http://localhost/" } | ||
); | ||
}); | ||
|
||
it('removes the notification destination when the delete notification destination button is clicked', async () => { | ||
it("removes the notification destination when the delete notification destination button is clicked", async () => { | ||
fetch_server_api.fetch_server_api = jest.fn().mockResolvedValue({ ok: true }); | ||
await act(async () => { | ||
renderNotificationDestinations(notification_destinations) | ||
}); | ||
await act(async () => { | ||
fireEvent.click(screen.getByText(/Delete notification destination/)); | ||
}); | ||
expect(fetch_server_api.fetch_server_api).toHaveBeenCalledWith('delete', `report/report_uuid/notification_destination/destination_uuid1`, {}); | ||
renderNotificationDestinations(notification_destinations) | ||
fireEvent.click(screen.getByText(/Delete notification destination/)); | ||
expect(fetch_server_api.fetch_server_api).toHaveBeenCalledWith( | ||
"delete", "report/report_uuid/notification_destination/destination_uuid1", {} | ||
); | ||
}); |
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
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