From 3e1828eb129f85d2084c236e81a9d2d538ca9ac2 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Mon, 6 Jan 2020 14:48:32 +0100 Subject: [PATCH] fixed storyshots with react-diff-view --- .../src/__snapshots__/storyshots.test.ts.snap | 16415 ++++++++++++++++ .../ui-components/src/repos/Diff.stories.tsx | 7 +- scm-ui/ui-components/src/storyshots.test.ts | 20 +- 3 files changed, 16438 insertions(+), 4 deletions(-) diff --git a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap index 7fa1b1193f..009fe0cd21 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -334,6 +334,16421 @@ exports[`Storyshots DateFromNow Default 1`] = ` `; +exports[`Storyshots Diff Collapsed 1`] = ` +Array [ +
+
+
+
+ + + src/main/java/com/cloudogu/scm/review/events/EventListener.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
, +
+
+
+
+ + + src/main/js/ChangeNotification.tsx + + + modify + +
+
+
+
+ +
+
+
+
+
+
, +
+
+
+
+ + + src/main/resources/locales/de/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
, +
+
+
+
+ + + src/main/resources/locales/en/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
, +
+
+
+
+ + + src/test/java/com/cloudogu/scm/review/events/ClientTest.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
, +] +`; + +exports[`Storyshots Diff Default 1`] = ` +Array [ +
+
+
+
+ + + src/main/java/com/cloudogu/scm/review/events/EventListener.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + package com.cloudogu.scm.review.events; +
+ + + +
+ + + import com.cloudogu.scm.review.comment.service.BasicComment; +
+ + + import com.cloudogu.scm.review.comment.service.BasicCommentEvent; +
+ + + import com.cloudogu.scm.review.comment.service.CommentEvent; +
+ + + import com.cloudogu.scm.review.comment.service.ReplyEvent; +
+ + + import com.cloudogu.scm.review.pullrequest.service.BasicPullRequestEvent; +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequest; +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequestEvent; +
+ + + import com.github.legman.Subscribe; +
+ + + import lombok.Data; +
+ + + import org.apache.shiro.SecurityUtils; +
+ + + import org.apache.shiro.subject.PrincipalCollection; +
+ + + import org.apache.shiro.subject.Subject; +
+ + + import sonia.scm.EagerSingleton; +
+ + + import sonia.scm.HandlerEventType; +
+ + + import sonia.scm.event.HandlerEvent; +
+ + + import sonia.scm.plugin.Extension; +
+ + + import sonia.scm.repository.Repository; +
+ + + import sonia.scm.security.SessionId; +
+
+
, +
+
+
+
+ + + src/main/js/ChangeNotification.tsx + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import { Link } from "@scm-manager/ui-types"; +
+ + + import { apiClient, Toast, ToastButtons, ToastButton } from "@scm-manager/ui-components"; +
+ + + import { PullRequest } from "./types/PullRequest"; +
+ + + import { useTranslation } from "react-i18next"; +
+ + + +
+ + + type HandlerProps = { +
+ + + url: string; +
+
+
+ + + pullRequest: setEvent +
+ + + }); +
+ + + }, [url]); +
+ + + const { t } = useTranslation("plugins"); +
+ + + if (event) { +
+ + + return ( +
+ + + <Toast type="warning" title="New Changes"> +
+ + + <p>The underlying Pull-Request has changed. Press reload to see the changes.</p> +
+ + + <p>Warning: Non saved modification will be lost.</p> +
+ + + <Toast type="warning" title={t("scm-review-plugin.changeNotification.title")}> +
+ + + <p>{t("scm-review-plugin.changeNotification.description")}</p> +
+ + + <p>{t("scm-review-plugin.changeNotification.modificationWarning")}</p> +
+ + + <ToastButtons> +
+ + + <ToastButton icon="redo" onClick={reload}>Reload</ToastButton> +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}>Ignore</ToastButton> +
+ + + <ToastButton icon="redo" onClick={reload}> +
+ + + {t("scm-review-plugin.changeNotification.buttons.reload")} +
+ + + </ToastButton> +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}> +
+ + + {t("scm-review-plugin.changeNotification.buttons.ignore")} +
+ + + </ToastButton> +
+ + + </ToastButtons> +
+ + + </Toast> +
+ + + ); +
+
+
, +
+
+
+
+ + + src/main/resources/locales/de/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "Der Kommentar bezieht sich auf eine ältere Version des Source- oder Target-Branches. Klicken Sie hier, um den ursprünglichen Kontext zu sehen." +
+ + + } +
+ + + } +
+ + + }, +
+ + + "changeNotification": { +
+ + + "title": "Neue Änderungen", +
+ + + "description": "An diesem Pull Request wurden Änderungen vorgenommen. Laden Sie die Seite neu um diese anzuzeigen.", +
+ + + "modificationWarning": "Warnung: Nicht gespeicherte Eingaben gehen verloren.", +
+ + + "buttons": { +
+ + + "reload": "Neu laden", +
+ + + "ignore": "Ignorieren" +
+ + + } +
+ + + } +
+ + + }, +
+ + + "permissions": { +
+
+
, +
+
+
+
+ + + src/main/resources/locales/en/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "The comment is related to an older of the source or target branch. Click here to see the original context." +
+ + + } +
+ + + } +
+ + + }, +
+ + + "changeNotification": { +
+ + + "title": "New Changes", +
+ + + "description": "The underlying Pull-Request has changed. Press reload to see the changes.", +
+ + + "modificationWarning": "Warning: Non saved modification will be lost.", +
+ + + "buttons": { +
+ + + "reload": "Reload", +
+ + + "ignore": "Ignore" +
+ + + } +
+ + + } +
+ + + }, +
+ + + "permissions": { +
+
+
, +
+
+
+
+ + + src/test/java/com/cloudogu/scm/review/events/ClientTest.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import org.mockito.Mock; +
+ + + import org.mockito.junit.jupiter.MockitoExtension; +
+ + + import sonia.scm.security.SessionId; +
+ + + +
+ + + import javax.ws.rs.sse.OutboundSseEvent; +
+ + + import javax.ws.rs.sse.SseEventSink; +
+ + + +
+ + + import java.time.Clock; +
+ + + import java.time.Instant; +
+ + + import java.time.LocalDateTime; +
+ + + import java.time.ZoneOffset; +
+ + + import java.time.temporal.ChronoField; +
+ + + import java.time.temporal.ChronoUnit; +
+ + + import java.time.temporal.TemporalField; +
+ + + import java.util.concurrent.CompletableFuture; +
+ + + import java.util.concurrent.CompletionStage; +
+ + + import java.util.concurrent.atomic.AtomicLong; +
+ + + import java.util.concurrent.atomic.AtomicReference; +
+ + + +
+ + + import static java.time.temporal.ChronoUnit.MINUTES; +
+
+
+ + + +
+ + + @Test +
+ + + @SuppressWarnings("unchecked") +
+ + + void shouldCloseEventSinkOnFailure() throws InterruptedException { +
+ + + void shouldCloseEventSinkOnFailure() { +
+ + + CompletionStage future = CompletableFuture.supplyAsync(() -> { +
+ + + throw new RuntimeException("failed to send message"); +
+ + + }); +
+
+
+ + + +
+ + + client.send(message); +
+ + + +
+ + + Thread.sleep(50L); +
+ + + +
+ + + verify(eventSink).close(); +
+ + + verify(eventSink, timeout(50L)).close(); +
+ + + } +
+ + + +
+ + + @Test +
+
+
, +] +`; + +exports[`Storyshots Diff File Annotation 1`] = ` +Array [ +
+
+
+
+ + + src/main/java/com/cloudogu/scm/review/events/EventListener.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
+

+ Custom File annotation for + src/main/java/com/cloudogu/scm/review/events/EventListener.java +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + package com.cloudogu.scm.review.events; +
+ + + +
+ + + import com.cloudogu.scm.review.comment.service.BasicComment; +
+ + + import com.cloudogu.scm.review.comment.service.BasicCommentEvent; +
+ + + import com.cloudogu.scm.review.comment.service.CommentEvent; +
+ + + import com.cloudogu.scm.review.comment.service.ReplyEvent; +
+ + + import com.cloudogu.scm.review.pullrequest.service.BasicPullRequestEvent; +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequest; +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequestEvent; +
+ + + import com.github.legman.Subscribe; +
+ + + import lombok.Data; +
+ + + import org.apache.shiro.SecurityUtils; +
+ + + import org.apache.shiro.subject.PrincipalCollection; +
+ + + import org.apache.shiro.subject.Subject; +
+ + + import sonia.scm.EagerSingleton; +
+ + + import sonia.scm.HandlerEventType; +
+ + + import sonia.scm.event.HandlerEvent; +
+ + + import sonia.scm.plugin.Extension; +
+ + + import sonia.scm.repository.Repository; +
+ + + import sonia.scm.security.SessionId; +
+
+
, +
+
+
+
+ + + src/main/js/ChangeNotification.tsx + + + modify + +
+
+
+
+ +
+
+
+
+
+
+

+ Custom File annotation for + src/main/js/ChangeNotification.tsx +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import { Link } from "@scm-manager/ui-types"; +
+ + + import { apiClient, Toast, ToastButtons, ToastButton } from "@scm-manager/ui-components"; +
+ + + import { PullRequest } from "./types/PullRequest"; +
+ + + import { useTranslation } from "react-i18next"; +
+ + + +
+ + + type HandlerProps = { +
+ + + url: string; +
+
+
+ + + pullRequest: setEvent +
+ + + }); +
+ + + }, [url]); +
+ + + const { t } = useTranslation("plugins"); +
+ + + if (event) { +
+ + + return ( +
+ + + <Toast type="warning" title="New Changes"> +
+ + + <p>The underlying Pull-Request has changed. Press reload to see the changes.</p> +
+ + + <p>Warning: Non saved modification will be lost.</p> +
+ + + <Toast type="warning" title={t("scm-review-plugin.changeNotification.title")}> +
+ + + <p>{t("scm-review-plugin.changeNotification.description")}</p> +
+ + + <p>{t("scm-review-plugin.changeNotification.modificationWarning")}</p> +
+ + + <ToastButtons> +
+ + + <ToastButton icon="redo" onClick={reload}>Reload</ToastButton> +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}>Ignore</ToastButton> +
+ + + <ToastButton icon="redo" onClick={reload}> +
+ + + {t("scm-review-plugin.changeNotification.buttons.reload")} +
+ + + </ToastButton> +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}> +
+ + + {t("scm-review-plugin.changeNotification.buttons.ignore")} +
+ + + </ToastButton> +
+ + + </ToastButtons> +
+ + + </Toast> +
+ + + ); +
+
+
, +
+
+
+
+ + + src/main/resources/locales/de/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
+

+ Custom File annotation for + src/main/resources/locales/de/plugins.json +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "Der Kommentar bezieht sich auf eine ältere Version des Source- oder Target-Branches. Klicken Sie hier, um den ursprünglichen Kontext zu sehen." +
+ + + } +
+ + + } +
+ + + }, +
+ + + "changeNotification": { +
+ + + "title": "Neue Änderungen", +
+ + + "description": "An diesem Pull Request wurden Änderungen vorgenommen. Laden Sie die Seite neu um diese anzuzeigen.", +
+ + + "modificationWarning": "Warnung: Nicht gespeicherte Eingaben gehen verloren.", +
+ + + "buttons": { +
+ + + "reload": "Neu laden", +
+ + + "ignore": "Ignorieren" +
+ + + } +
+ + + } +
+ + + }, +
+ + + "permissions": { +
+
+
, +
+
+
+
+ + + src/main/resources/locales/en/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
+

+ Custom File annotation for + src/main/resources/locales/en/plugins.json +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "The comment is related to an older of the source or target branch. Click here to see the original context." +
+ + + } +
+ + + } +
+ + + }, +
+ + + "changeNotification": { +
+ + + "title": "New Changes", +
+ + + "description": "The underlying Pull-Request has changed. Press reload to see the changes.", +
+ + + "modificationWarning": "Warning: Non saved modification will be lost.", +
+ + + "buttons": { +
+ + + "reload": "Reload", +
+ + + "ignore": "Ignore" +
+ + + } +
+ + + } +
+ + + }, +
+ + + "permissions": { +
+
+
, +
+
+
+
+ + + src/test/java/com/cloudogu/scm/review/events/ClientTest.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
+

+ Custom File annotation for + src/test/java/com/cloudogu/scm/review/events/ClientTest.java +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import org.mockito.Mock; +
+ + + import org.mockito.junit.jupiter.MockitoExtension; +
+ + + import sonia.scm.security.SessionId; +
+ + + +
+ + + import javax.ws.rs.sse.OutboundSseEvent; +
+ + + import javax.ws.rs.sse.SseEventSink; +
+ + + +
+ + + import java.time.Clock; +
+ + + import java.time.Instant; +
+ + + import java.time.LocalDateTime; +
+ + + import java.time.ZoneOffset; +
+ + + import java.time.temporal.ChronoField; +
+ + + import java.time.temporal.ChronoUnit; +
+ + + import java.time.temporal.TemporalField; +
+ + + import java.util.concurrent.CompletableFuture; +
+ + + import java.util.concurrent.CompletionStage; +
+ + + import java.util.concurrent.atomic.AtomicLong; +
+ + + import java.util.concurrent.atomic.AtomicReference; +
+ + + +
+ + + import static java.time.temporal.ChronoUnit.MINUTES; +
+
+
+ + + +
+ + + @Test +
+ + + @SuppressWarnings("unchecked") +
+ + + void shouldCloseEventSinkOnFailure() throws InterruptedException { +
+ + + void shouldCloseEventSinkOnFailure() { +
+ + + CompletionStage future = CompletableFuture.supplyAsync(() -> { +
+ + + throw new RuntimeException("failed to send message"); +
+ + + }); +
+
+
+ + + +
+ + + client.send(message); +
+ + + +
+ + + Thread.sleep(50L); +
+ + + +
+ + + verify(eventSink).close(); +
+ + + verify(eventSink, timeout(50L)).close(); +
+ + + } +
+ + + +
+ + + @Test +
+
+
, +] +`; + +exports[`Storyshots Diff File Controls 1`] = ` +Array [ +
+
+
+
+ + + src/main/java/com/cloudogu/scm/review/events/EventListener.java + + + modify + +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + package com.cloudogu.scm.review.events; +
+ + + +
+ + + import com.cloudogu.scm.review.comment.service.BasicComment; +
+ + + import com.cloudogu.scm.review.comment.service.BasicCommentEvent; +
+ + + import com.cloudogu.scm.review.comment.service.CommentEvent; +
+ + + import com.cloudogu.scm.review.comment.service.ReplyEvent; +
+ + + import com.cloudogu.scm.review.pullrequest.service.BasicPullRequestEvent; +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequest; +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequestEvent; +
+ + + import com.github.legman.Subscribe; +
+ + + import lombok.Data; +
+ + + import org.apache.shiro.SecurityUtils; +
+ + + import org.apache.shiro.subject.PrincipalCollection; +
+ + + import org.apache.shiro.subject.Subject; +
+ + + import sonia.scm.EagerSingleton; +
+ + + import sonia.scm.HandlerEventType; +
+ + + import sonia.scm.event.HandlerEvent; +
+ + + import sonia.scm.plugin.Extension; +
+ + + import sonia.scm.repository.Repository; +
+ + + import sonia.scm.security.SessionId; +
+
+
, +
+
+
+
+ + + src/main/js/ChangeNotification.tsx + + + modify + +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import { Link } from "@scm-manager/ui-types"; +
+ + + import { apiClient, Toast, ToastButtons, ToastButton } from "@scm-manager/ui-components"; +
+ + + import { PullRequest } from "./types/PullRequest"; +
+ + + import { useTranslation } from "react-i18next"; +
+ + + +
+ + + type HandlerProps = { +
+ + + url: string; +
+
+
+ + + pullRequest: setEvent +
+ + + }); +
+ + + }, [url]); +
+ + + const { t } = useTranslation("plugins"); +
+ + + if (event) { +
+ + + return ( +
+ + + <Toast type="warning" title="New Changes"> +
+ + + <p>The underlying Pull-Request has changed. Press reload to see the changes.</p> +
+ + + <p>Warning: Non saved modification will be lost.</p> +
+ + + <Toast type="warning" title={t("scm-review-plugin.changeNotification.title")}> +
+ + + <p>{t("scm-review-plugin.changeNotification.description")}</p> +
+ + + <p>{t("scm-review-plugin.changeNotification.modificationWarning")}</p> +
+ + + <ToastButtons> +
+ + + <ToastButton icon="redo" onClick={reload}>Reload</ToastButton> +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}>Ignore</ToastButton> +
+ + + <ToastButton icon="redo" onClick={reload}> +
+ + + {t("scm-review-plugin.changeNotification.buttons.reload")} +
+ + + </ToastButton> +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}> +
+ + + {t("scm-review-plugin.changeNotification.buttons.ignore")} +
+ + + </ToastButton> +
+ + + </ToastButtons> +
+ + + </Toast> +
+ + + ); +
+
+
, +
+
+
+
+ + + src/main/resources/locales/de/plugins.json + + + modify + +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "Der Kommentar bezieht sich auf eine ältere Version des Source- oder Target-Branches. Klicken Sie hier, um den ursprünglichen Kontext zu sehen." +
+ + + } +
+ + + } +
+ + + }, +
+ + + "changeNotification": { +
+ + + "title": "Neue Änderungen", +
+ + + "description": "An diesem Pull Request wurden Änderungen vorgenommen. Laden Sie die Seite neu um diese anzuzeigen.", +
+ + + "modificationWarning": "Warnung: Nicht gespeicherte Eingaben gehen verloren.", +
+ + + "buttons": { +
+ + + "reload": "Neu laden", +
+ + + "ignore": "Ignorieren" +
+ + + } +
+ + + } +
+ + + }, +
+ + + "permissions": { +
+
+
, +
+
+
+
+ + + src/main/resources/locales/en/plugins.json + + + modify + +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "The comment is related to an older of the source or target branch. Click here to see the original context." +
+ + + } +
+ + + } +
+ + + }, +
+ + + "changeNotification": { +
+ + + "title": "New Changes", +
+ + + "description": "The underlying Pull-Request has changed. Press reload to see the changes.", +
+ + + "modificationWarning": "Warning: Non saved modification will be lost.", +
+ + + "buttons": { +
+ + + "reload": "Reload", +
+ + + "ignore": "Ignore" +
+ + + } +
+ + + } +
+ + + }, +
+ + + "permissions": { +
+
+
, +
+
+
+
+ + + src/test/java/com/cloudogu/scm/review/events/ClientTest.java + + + modify + +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import org.mockito.Mock; +
+ + + import org.mockito.junit.jupiter.MockitoExtension; +
+ + + import sonia.scm.security.SessionId; +
+ + + +
+ + + import javax.ws.rs.sse.OutboundSseEvent; +
+ + + import javax.ws.rs.sse.SseEventSink; +
+ + + +
+ + + import java.time.Clock; +
+ + + import java.time.Instant; +
+ + + import java.time.LocalDateTime; +
+ + + import java.time.ZoneOffset; +
+ + + import java.time.temporal.ChronoField; +
+ + + import java.time.temporal.ChronoUnit; +
+ + + import java.time.temporal.TemporalField; +
+ + + import java.util.concurrent.CompletableFuture; +
+ + + import java.util.concurrent.CompletionStage; +
+ + + import java.util.concurrent.atomic.AtomicLong; +
+ + + import java.util.concurrent.atomic.AtomicReference; +
+ + + +
+ + + import static java.time.temporal.ChronoUnit.MINUTES; +
+
+
+ + + +
+ + + @Test +
+ + + @SuppressWarnings("unchecked") +
+ + + void shouldCloseEventSinkOnFailure() throws InterruptedException { +
+ + + void shouldCloseEventSinkOnFailure() { +
+ + + CompletionStage future = CompletableFuture.supplyAsync(() -> { +
+ + + throw new RuntimeException("failed to send message"); +
+ + + }); +
+
+
+ + + +
+ + + client.send(message); +
+ + + +
+ + + Thread.sleep(50L); +
+ + + +
+ + + verify(eventSink).close(); +
+ + + verify(eventSink, timeout(50L)).close(); +
+ + + } +
+ + + +
+ + + @Test +
+
+
, +] +`; + +exports[`Storyshots Diff Line Annotation 1`] = ` +Array [ +
+
+
+
+ + + src/main/java/com/cloudogu/scm/review/events/EventListener.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + package com.cloudogu.scm.review.events; +
+ + + +
+

+ Line Annotation +

+
+ + + import com.cloudogu.scm.review.comment.service.BasicComment; +
+ + + import com.cloudogu.scm.review.comment.service.BasicCommentEvent; +
+ + + import com.cloudogu.scm.review.comment.service.CommentEvent; +
+ + + import com.cloudogu.scm.review.comment.service.ReplyEvent; +
+ + + import com.cloudogu.scm.review.pullrequest.service.BasicPullRequestEvent; +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequest; +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequestEvent; +
+ + + import com.github.legman.Subscribe; +
+ + + import lombok.Data; +
+ + + import org.apache.shiro.SecurityUtils; +
+ + + import org.apache.shiro.subject.PrincipalCollection; +
+ + + import org.apache.shiro.subject.Subject; +
+ + + import sonia.scm.EagerSingleton; +
+ + + import sonia.scm.HandlerEventType; +
+ + + import sonia.scm.event.HandlerEvent; +
+ + + import sonia.scm.plugin.Extension; +
+ + + import sonia.scm.repository.Repository; +
+ + + import sonia.scm.security.SessionId; +
+
+
, +
+
+
+
+ + + src/main/js/ChangeNotification.tsx + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import { Link } from "@scm-manager/ui-types"; +
+

+ Line Annotation +

+
+ + + import { apiClient, Toast, ToastButtons, ToastButton } from "@scm-manager/ui-components"; +
+ + + import { PullRequest } from "./types/PullRequest"; +
+ + + import { useTranslation } from "react-i18next"; +
+ + + +
+ + + type HandlerProps = { +
+ + + url: string; +
+
+
+ + + pullRequest: setEvent +
+ + + }); +
+ + + }, [url]); +
+ + + const { t } = useTranslation("plugins"); +
+ + + if (event) { +
+ + + return ( +
+ + + <Toast type="warning" title="New Changes"> +
+ + + <p>The underlying Pull-Request has changed. Press reload to see the changes.</p> +
+ + + <p>Warning: Non saved modification will be lost.</p> +
+ + + <Toast type="warning" title={t("scm-review-plugin.changeNotification.title")}> +
+ + + <p>{t("scm-review-plugin.changeNotification.description")}</p> +
+ + + <p>{t("scm-review-plugin.changeNotification.modificationWarning")}</p> +
+ + + <ToastButtons> +
+ + + <ToastButton icon="redo" onClick={reload}>Reload</ToastButton> +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}>Ignore</ToastButton> +
+ + + <ToastButton icon="redo" onClick={reload}> +
+ + + {t("scm-review-plugin.changeNotification.buttons.reload")} +
+ + + </ToastButton> +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}> +
+ + + {t("scm-review-plugin.changeNotification.buttons.ignore")} +
+ + + </ToastButton> +
+ + + </ToastButtons> +
+ + + </Toast> +
+ + + ); +
+
+
, +
+
+
+
+ + + src/main/resources/locales/de/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "Der Kommentar bezieht sich auf eine ältere Version des Source- oder Target-Branches. Klicken Sie hier, um den ursprünglichen Kontext zu sehen." +
+ + + } +
+ + + } +
+ + + }, +
+ + + "changeNotification": { +
+ + + "title": "Neue Änderungen", +
+ + + "description": "An diesem Pull Request wurden Änderungen vorgenommen. Laden Sie die Seite neu um diese anzuzeigen.", +
+ + + "modificationWarning": "Warnung: Nicht gespeicherte Eingaben gehen verloren.", +
+ + + "buttons": { +
+ + + "reload": "Neu laden", +
+ + + "ignore": "Ignorieren" +
+ + + } +
+ + + } +
+ + + }, +
+ + + "permissions": { +
+
+
, +
+
+
+
+ + + src/main/resources/locales/en/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "The comment is related to an older of the source or target branch. Click here to see the original context." +
+ + + } +
+ + + } +
+ + + }, +
+ + + "changeNotification": { +
+ + + "title": "New Changes", +
+ + + "description": "The underlying Pull-Request has changed. Press reload to see the changes.", +
+ + + "modificationWarning": "Warning: Non saved modification will be lost.", +
+ + + "buttons": { +
+ + + "reload": "Reload", +
+ + + "ignore": "Ignore" +
+ + + } +
+ + + } +
+ + + }, +
+ + + "permissions": { +
+
+
, +
+
+
+
+ + + src/test/java/com/cloudogu/scm/review/events/ClientTest.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import org.mockito.Mock; +
+ + + import org.mockito.junit.jupiter.MockitoExtension; +
+ + + import sonia.scm.security.SessionId; +
+ + + +
+ + + import javax.ws.rs.sse.OutboundSseEvent; +
+ + + import javax.ws.rs.sse.SseEventSink; +
+ + + +
+ + + import java.time.Clock; +
+ + + import java.time.Instant; +
+ + + import java.time.LocalDateTime; +
+ + + import java.time.ZoneOffset; +
+ + + import java.time.temporal.ChronoField; +
+ + + import java.time.temporal.ChronoUnit; +
+ + + import java.time.temporal.TemporalField; +
+ + + import java.util.concurrent.CompletableFuture; +
+ + + import java.util.concurrent.CompletionStage; +
+ + + import java.util.concurrent.atomic.AtomicLong; +
+ + + import java.util.concurrent.atomic.AtomicReference; +
+ + + +
+ + + import static java.time.temporal.ChronoUnit.MINUTES; +
+
+
+ + + +
+ + + @Test +
+ + + @SuppressWarnings("unchecked") +
+ + + void shouldCloseEventSinkOnFailure() throws InterruptedException { +
+ + + void shouldCloseEventSinkOnFailure() { +
+ + + CompletionStage future = CompletableFuture.supplyAsync(() -> { +
+ + + throw new RuntimeException("failed to send message"); +
+ + + }); +
+
+
+ + + +
+ + + client.send(message); +
+ + + +
+ + + Thread.sleep(50L); +
+ + + +
+ + + verify(eventSink).close(); +
+ + + verify(eventSink, timeout(50L)).close(); +
+ + + } +
+ + + +
+ + + @Test +
+
+
, +] +`; + +exports[`Storyshots Diff OnClick 1`] = ` +Array [ +
+
+
+
+ + + src/main/java/com/cloudogu/scm/review/events/EventListener.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + package com.cloudogu.scm.review.events; +
+ + + +
+ + + import com.cloudogu.scm.review.comment.service.BasicComment; +
+ + + import com.cloudogu.scm.review.comment.service.BasicCommentEvent; +
+ + + import com.cloudogu.scm.review.comment.service.CommentEvent; +
+ + + import com.cloudogu.scm.review.comment.service.ReplyEvent; +
+ + + import com.cloudogu.scm.review.pullrequest.service.BasicPullRequestEvent; +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequest; +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequestEvent; +
+ + + import com.github.legman.Subscribe; +
+ + + import lombok.Data; +
+ + + import org.apache.shiro.SecurityUtils; +
+ + + import org.apache.shiro.subject.PrincipalCollection; +
+ + + import org.apache.shiro.subject.Subject; +
+ + + import sonia.scm.EagerSingleton; +
+ + + import sonia.scm.HandlerEventType; +
+ + + import sonia.scm.event.HandlerEvent; +
+ + + import sonia.scm.plugin.Extension; +
+ + + import sonia.scm.repository.Repository; +
+ + + import sonia.scm.security.SessionId; +
+
+
, +
+
+
+
+ + + src/main/js/ChangeNotification.tsx + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import { Link } from "@scm-manager/ui-types"; +
+ + + import { apiClient, Toast, ToastButtons, ToastButton } from "@scm-manager/ui-components"; +
+ + + import { PullRequest } from "./types/PullRequest"; +
+ + + import { useTranslation } from "react-i18next"; +
+ + + +
+ + + type HandlerProps = { +
+ + + url: string; +
+
+
+ + + pullRequest: setEvent +
+ + + }); +
+ + + }, [url]); +
+ + + const { t } = useTranslation("plugins"); +
+ + + if (event) { +
+ + + return ( +
+ + + <Toast type="warning" title="New Changes"> +
+ + + <p>The underlying Pull-Request has changed. Press reload to see the changes.</p> +
+ + + <p>Warning: Non saved modification will be lost.</p> +
+ + + <Toast type="warning" title={t("scm-review-plugin.changeNotification.title")}> +
+ + + <p>{t("scm-review-plugin.changeNotification.description")}</p> +
+ + + <p>{t("scm-review-plugin.changeNotification.modificationWarning")}</p> +
+ + + <ToastButtons> +
+ + + <ToastButton icon="redo" onClick={reload}>Reload</ToastButton> +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}>Ignore</ToastButton> +
+ + + <ToastButton icon="redo" onClick={reload}> +
+ + + {t("scm-review-plugin.changeNotification.buttons.reload")} +
+ + + </ToastButton> +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}> +
+ + + {t("scm-review-plugin.changeNotification.buttons.ignore")} +
+ + + </ToastButton> +
+ + + </ToastButtons> +
+ + + </Toast> +
+ + + ); +
+
+
, +
+
+
+
+ + + src/main/resources/locales/de/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "Der Kommentar bezieht sich auf eine ältere Version des Source- oder Target-Branches. Klicken Sie hier, um den ursprünglichen Kontext zu sehen." +
+ + + } +
+ + + } +
+ + + }, +
+ + + "changeNotification": { +
+ + + "title": "Neue Änderungen", +
+ + + "description": "An diesem Pull Request wurden Änderungen vorgenommen. Laden Sie die Seite neu um diese anzuzeigen.", +
+ + + "modificationWarning": "Warnung: Nicht gespeicherte Eingaben gehen verloren.", +
+ + + "buttons": { +
+ + + "reload": "Neu laden", +
+ + + "ignore": "Ignorieren" +
+ + + } +
+ + + } +
+ + + }, +
+ + + "permissions": { +
+
+
, +
+
+
+
+ + + src/main/resources/locales/en/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "The comment is related to an older of the source or target branch. Click here to see the original context." +
+ + + } +
+ + + } +
+ + + }, +
+ + + "changeNotification": { +
+ + + "title": "New Changes", +
+ + + "description": "The underlying Pull-Request has changed. Press reload to see the changes.", +
+ + + "modificationWarning": "Warning: Non saved modification will be lost.", +
+ + + "buttons": { +
+ + + "reload": "Reload", +
+ + + "ignore": "Ignore" +
+ + + } +
+ + + } +
+ + + }, +
+ + + "permissions": { +
+
+
, +
+
+
+
+ + + src/test/java/com/cloudogu/scm/review/events/ClientTest.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import org.mockito.Mock; +
+ + + import org.mockito.junit.jupiter.MockitoExtension; +
+ + + import sonia.scm.security.SessionId; +
+ + + +
+ + + import javax.ws.rs.sse.OutboundSseEvent; +
+ + + import javax.ws.rs.sse.SseEventSink; +
+ + + +
+ + + import java.time.Clock; +
+ + + import java.time.Instant; +
+ + + import java.time.LocalDateTime; +
+ + + import java.time.ZoneOffset; +
+ + + import java.time.temporal.ChronoField; +
+ + + import java.time.temporal.ChronoUnit; +
+ + + import java.time.temporal.TemporalField; +
+ + + import java.util.concurrent.CompletableFuture; +
+ + + import java.util.concurrent.CompletionStage; +
+ + + import java.util.concurrent.atomic.AtomicLong; +
+ + + import java.util.concurrent.atomic.AtomicReference; +
+ + + +
+ + + import static java.time.temporal.ChronoUnit.MINUTES; +
+
+
+ + + +
+ + + @Test +
+ + + @SuppressWarnings("unchecked") +
+ + + void shouldCloseEventSinkOnFailure() throws InterruptedException { +
+ + + void shouldCloseEventSinkOnFailure() { +
+ + + CompletionStage future = CompletableFuture.supplyAsync(() -> { +
+ + + throw new RuntimeException("failed to send message"); +
+ + + }); +
+
+
+ + + +
+ + + client.send(message); +
+ + + +
+ + + Thread.sleep(50L); +
+ + + +
+ + + verify(eventSink).close(); +
+ + + verify(eventSink, timeout(50L)).close(); +
+ + + } +
+ + + +
+ + + @Test +
+
+
, +] +`; + +exports[`Storyshots Diff Side-By-Side 1`] = ` +Array [ +
+
+
+
+ + + src/main/java/com/cloudogu/scm/review/events/EventListener.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + package com.cloudogu.scm.review.events; + + + + + package com.cloudogu.scm.review.events; + +
+ + + + + + + + + +
+ + + import com.cloudogu.scm.review.comment.service.BasicComment; + + + +
+ + + import com.cloudogu.scm.review.comment.service.BasicCommentEvent; + + + +
+ + + import com.cloudogu.scm.review.comment.service.CommentEvent; + + + +
+ + + import com.cloudogu.scm.review.comment.service.ReplyEvent; + + + +
+ + + import com.cloudogu.scm.review.pullrequest.service.BasicPullRequestEvent; + + + + + import com.cloudogu.scm.review.pullrequest.service.BasicPullRequestEvent; + +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequest; + + + + + import com.cloudogu.scm.review.pullrequest.service.PullRequest; + +
+ + + import com.cloudogu.scm.review.pullrequest.service.PullRequestEvent; + + + +
+ + + import com.github.legman.Subscribe; + + + + + import com.github.legman.Subscribe; + +
+ + + import lombok.Data; + + + +
+ + + import org.apache.shiro.SecurityUtils; + + + + + import org.apache.shiro.SecurityUtils; + +
+ + + import org.apache.shiro.subject.PrincipalCollection; + + + + + import org.apache.shiro.subject.PrincipalCollection; + +
+ + + import org.apache.shiro.subject.Subject; + + + + + import org.apache.shiro.subject.Subject; + +
+ + + import sonia.scm.EagerSingleton; + + + + + import sonia.scm.EagerSingleton; + +
+ + + import sonia.scm.HandlerEventType; + + + +
+ + + import sonia.scm.event.HandlerEvent; + + + +
+ + + import sonia.scm.plugin.Extension; + + + + + import sonia.scm.plugin.Extension; + +
+ + + import sonia.scm.repository.Repository; + + + + + import sonia.scm.repository.Repository; + +
+ + + import sonia.scm.security.SessionId; + + + + + import sonia.scm.security.SessionId; + +
+
+
, +
+
+
+
+ + + src/main/js/ChangeNotification.tsx + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import { Link } from "@scm-manager/ui-types"; + + + + + import { Link } from "@scm-manager/ui-types"; + +
+ + + import { apiClient, Toast, ToastButtons, ToastButton } from "@scm-manager/ui-components"; + + + + + import { apiClient, Toast, ToastButtons, ToastButton } from "@scm-manager/ui-components"; + +
+ + + import { PullRequest } from "./types/PullRequest"; + + + + + import { PullRequest } from "./types/PullRequest"; + +
+ + + + + import { useTranslation } from "react-i18next"; + +
+ + + + + + + + + +
+ + + type HandlerProps = { + + + + + type HandlerProps = { + +
+ + + url: string; + + + + + url: string; + +
+
+
+ + + pullRequest: setEvent + + + + + pullRequest: setEvent + +
+ + + }); + + + + + }); + +
+ + + }, [url]); + + + + + }, [url]); + +
+ + + + + const { t } = useTranslation("plugins"); + +
+ + + if (event) { + + + + + if (event) { + +
+ + + return ( + + + + + return ( + +
+ + + <Toast type="warning" title="New Changes"> + + + +
+ + + <p>The underlying Pull-Request has changed. Press reload to see the changes.</p> + + + +
+ + + <p>Warning: Non saved modification will be lost.</p> + + + + + <Toast type="warning" title={t("scm-review-plugin.changeNotification.title")}> + +
+ + + + + <p>{t("scm-review-plugin.changeNotification.description")}</p> + +
+ + + + + <p>{t("scm-review-plugin.changeNotification.modificationWarning")}</p> + +
+ + + <ToastButtons> + + + + + <ToastButtons> + +
+ + + <ToastButton icon="redo" onClick={reload}>Reload</ToastButton> + + + +
+ + + <ToastButton icon="times" onClick={() => setEvent(undefined)}>Ignore</ToastButton> + + + + + <ToastButton icon="redo" onClick={reload}> + +
+ + + + + {t("scm-review-plugin.changeNotification.buttons.reload")} + +
+ + + + + </ToastButton> + +
+ + + + + <ToastButton icon="times" onClick={() => setEvent(undefined)}> + +
+ + + + + {t("scm-review-plugin.changeNotification.buttons.ignore")} + +
+ + + + + </ToastButton> + +
+ + + </ToastButtons> + + + + + </ToastButtons> + +
+ + + </Toast> + + + + + </Toast> + +
+ + + ); + + + + + ); + +
+
+
, +
+
+
+
+ + + src/main/resources/locales/de/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "Der Kommentar bezieht sich auf eine ältere Version des Source- oder Target-Branches. Klicken Sie hier, um den ursprünglichen Kontext zu sehen." + + + + + "titleClickable": "Der Kommentar bezieht sich auf eine ältere Version des Source- oder Target-Branches. Klicken Sie hier, um den ursprünglichen Kontext zu sehen." + +
+ + + } + + + + + } + +
+ + + } + + + + + } + +
+ + + + + }, + +
+ + + + + "changeNotification": { + +
+ + + + + "title": "Neue Änderungen", + +
+ + + + + "description": "An diesem Pull Request wurden Änderungen vorgenommen. Laden Sie die Seite neu um diese anzuzeigen.", + +
+ + + + + "modificationWarning": "Warnung: Nicht gespeicherte Eingaben gehen verloren.", + +
+ + + + + "buttons": { + +
+ + + + + "reload": "Neu laden", + +
+ + + + + "ignore": "Ignorieren" + +
+ + + + + } + +
+ + + } + + + + + } + +
+ + + }, + + + + + }, + +
+ + + "permissions": { + + + + + "permissions": { + +
+
+
, +
+
+
+
+ + + src/main/resources/locales/en/plugins.json + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + "titleClickable": "The comment is related to an older of the source or target branch. Click here to see the original context." + + + + + "titleClickable": "The comment is related to an older of the source or target branch. Click here to see the original context." + +
+ + + } + + + + + } + +
+ + + } + + + + + } + +
+ + + + + }, + +
+ + + + + "changeNotification": { + +
+ + + + + "title": "New Changes", + +
+ + + + + "description": "The underlying Pull-Request has changed. Press reload to see the changes.", + +
+ + + + + "modificationWarning": "Warning: Non saved modification will be lost.", + +
+ + + + + "buttons": { + +
+ + + + + "reload": "Reload", + +
+ + + + + "ignore": "Ignore" + +
+ + + + + } + +
+ + + } + + + + + } + +
+ + + }, + + + + + }, + +
+ + + "permissions": { + + + + + "permissions": { + +
+
+
, +
+
+
+
+ + + src/test/java/com/cloudogu/scm/review/events/ClientTest.java + + + modify + +
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + import org.mockito.Mock; + + + + + import org.mockito.Mock; + +
+ + + import org.mockito.junit.jupiter.MockitoExtension; + + + + + import org.mockito.junit.jupiter.MockitoExtension; + +
+ + + import sonia.scm.security.SessionId; + + + + + import sonia.scm.security.SessionId; + +
+ + + + + + +
+ + + import javax.ws.rs.sse.OutboundSseEvent; + + + + + import javax.ws.rs.sse.OutboundSseEvent; + +
+ + + import javax.ws.rs.sse.SseEventSink; + + + + + import javax.ws.rs.sse.SseEventSink; + +
+ + + + + + +
+ + + import java.time.Clock; + + + + + import java.time.Clock; + +
+ + + import java.time.Instant; + + + + + import java.time.Instant; + +
+ + + import java.time.LocalDateTime; + + + + + import java.time.LocalDateTime; + +
+ + + import java.time.ZoneOffset; + + + + + import java.time.ZoneOffset; + +
+ + + import java.time.temporal.ChronoField; + + + + + import java.time.temporal.ChronoField; + +
+ + + import java.time.temporal.ChronoUnit; + + + +
+ + + import java.time.temporal.TemporalField; + + + +
+ + + import java.util.concurrent.CompletableFuture; + + + + + import java.util.concurrent.CompletableFuture; + +
+ + + import java.util.concurrent.CompletionStage; + + + + + import java.util.concurrent.CompletionStage; + +
+ + + import java.util.concurrent.atomic.AtomicLong; + + + +
+ + + import java.util.concurrent.atomic.AtomicReference; + + + + + import java.util.concurrent.atomic.AtomicReference; + +
+ + + + + + + + + +
+ + + import static java.time.temporal.ChronoUnit.MINUTES; + + + + + import static java.time.temporal.ChronoUnit.MINUTES; + +
+
+
+ + + + + + + + + +
+ + + @Test + + + + + @Test + +
+ + + @SuppressWarnings("unchecked") + + + + + @SuppressWarnings("unchecked") + +
+ + + void shouldCloseEventSinkOnFailure() throws InterruptedException { + + + + + void shouldCloseEventSinkOnFailure() { + +
+ + + CompletionStage future = CompletableFuture.supplyAsync(() -> { + + + + + CompletionStage future = CompletableFuture.supplyAsync(() -> { + +
+ + + throw new RuntimeException("failed to send message"); + + + + + throw new RuntimeException("failed to send message"); + +
+ + + }); + + + + + }); + +
+
+
+ + + + + + + + + +
+ + + client.send(message); + + + + + client.send(message); + +
+ + + + + + + + + +
+ + + Thread.sleep(50L); + + + +
+ + + + + + +
+ + + verify(eventSink).close(); + + + + + verify(eventSink, timeout(50L)).close(); + +
+ + + } + + + + + } + +
+ + + + + + + + + +
+ + + @Test + + + + + @Test + +
+
+
, +] +`; + exports[`Storyshots Forms|Checkbox Default 1`] = `
) .add("File Controls", () => } />) .add("File Annotation", () => ( - [

Custom File annotation for {file.newPath}

]} /> + [

Custom File annotation for {file.newPath}

]} + /> )) .add("Line Annotation", () => ( { return { - N2: [

Line Annotation

] + N2:

Line Annotation

}; }} /> diff --git a/scm-ui/ui-components/src/storyshots.test.ts b/scm-ui/ui-components/src/storyshots.test.ts index ee4e34653e..2843046f99 100644 --- a/scm-ui/ui-components/src/storyshots.test.ts +++ b/scm-ui/ui-components/src/storyshots.test.ts @@ -1,6 +1,22 @@ import path from "path"; -import initStoryshots from "@storybook/addon-storyshots"; +import initStoryshots, { snapshotWithOptions } from "@storybook/addon-storyshots"; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const createNodeMock = (element: any) => { + if (element.type === "tr") { + return { + // eslint-disable-next-line @typescript-eslint/no-empty-function + querySelector: (selector: string) => {} + }; + } + return null; +}; initStoryshots({ - configPath: path.resolve(__dirname, "..", ".storybook") + configPath: path.resolve(__dirname, "..", ".storybook"), + // fix snapshot tests with react-diff-view which uses a ref on tr + // @see https://github.com/storybookjs/storybook/pull/1090 + test: snapshotWithOptions({ + createNodeMock + }) });