fix(ui): mediaserver error modal improvements
This commit is contained in:
parent
e14cfdee85
commit
e778c3c443
@ -6,6 +6,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -476,6 +477,59 @@ func TestIntegrationStartupCheck(t *testing.T) {
|
|||||||
<-done
|
<-done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIntegrationMediaServerError(t *testing.T) {
|
||||||
|
ctx, cancel := context.WithTimeout(t.Context(), 10*time.Minute)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
lis, err := net.Listen("tcp", ":1935")
|
||||||
|
require.NoError(t, err)
|
||||||
|
t.Cleanup(func() { lis.Close() })
|
||||||
|
|
||||||
|
logger := testhelpers.NewTestLogger(t).With("component", "integration")
|
||||||
|
dockerClient, err := dockerclient.NewClientWithOpts(dockerclient.FromEnv, dockerclient.WithAPIVersionNegotiation())
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
configService := setupConfigService(t, config.Config{Sources: config.Sources{RTMP: config.RTMPSource{Enabled: true}}})
|
||||||
|
screen, screenCaptureC, getContents := setupSimulationScreen(t)
|
||||||
|
|
||||||
|
done := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
err := app.Run(ctx, app.RunParams{
|
||||||
|
ConfigService: configService,
|
||||||
|
DockerClient: dockerClient,
|
||||||
|
Screen: &terminal.Screen{
|
||||||
|
Screen: screen,
|
||||||
|
Width: 200,
|
||||||
|
Height: 25,
|
||||||
|
CaptureC: screenCaptureC,
|
||||||
|
},
|
||||||
|
ClipboardAvailable: false,
|
||||||
|
BuildInfo: domain.BuildInfo{Version: "0.0.1", GoVersion: "go1.16.3"},
|
||||||
|
Logger: logger,
|
||||||
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
done <- struct{}{}
|
||||||
|
}()
|
||||||
|
|
||||||
|
require.EventuallyWithT(
|
||||||
|
t,
|
||||||
|
func(t *assert.CollectT) {
|
||||||
|
assert.True(t, contentsIncludes(getContents(), "Mediaserver error: Server process exited unexpectedly."), "expected to see title")
|
||||||
|
assert.True(t, contentsIncludes(getContents(), "address already in use"), "expected to see message")
|
||||||
|
},
|
||||||
|
time.Minute,
|
||||||
|
time.Second,
|
||||||
|
"expected to see media server error modal",
|
||||||
|
)
|
||||||
|
printScreen(getContents, "Ater displaying the media server error modal")
|
||||||
|
|
||||||
|
// Quit the app, this should cause the done channel to receive.
|
||||||
|
sendKey(screen, tcell.KeyEnter, ' ')
|
||||||
|
|
||||||
|
<-done
|
||||||
|
}
|
||||||
|
|
||||||
func setupSimulationScreen(t *testing.T) (tcell.SimulationScreen, chan<- terminal.ScreenCapture, func() []string) {
|
func setupSimulationScreen(t *testing.T) (tcell.SimulationScreen, chan<- terminal.ScreenCapture, func() []string) {
|
||||||
// Fetching the screen contents is tricky at this level of the test pyramid,
|
// Fetching the screen contents is tricky at this level of the test pyramid,
|
||||||
// because we need to:
|
// because we need to:
|
||||||
|
@ -480,16 +480,17 @@ func (ui *UI) updateProgressModal(container domain.Container) {
|
|||||||
// on top of other modals.
|
// on top of other modals.
|
||||||
const (
|
const (
|
||||||
pageNameMain = "main"
|
pageNameMain = "main"
|
||||||
pageNameNoDestinations = "no-destinations"
|
|
||||||
pageNameAddDestination = "add-destination"
|
pageNameAddDestination = "add-destination"
|
||||||
pageNameModalDestinationError = "modal-destination-error"
|
|
||||||
pageNameModalAbout = "modal-about"
|
|
||||||
pageNameModalQuit = "modal-quit"
|
|
||||||
pageNameModalStartupCheck = "modal-startup-check"
|
|
||||||
pageNameModalClipboard = "modal-clipboard"
|
|
||||||
pageNameModalPullProgress = "modal-pull-progress"
|
|
||||||
pageNameModalRemoveDestination = "modal-remove-destination"
|
|
||||||
pageNameConfigUpdateFailed = "modal-config-update-failed"
|
pageNameConfigUpdateFailed = "modal-config-update-failed"
|
||||||
|
pageNameNoDestinations = "no-destinations"
|
||||||
|
pageNameModalAbout = "modal-about"
|
||||||
|
pageNameModalClipboard = "modal-clipboard"
|
||||||
|
pageNameModalDestinationError = "modal-destination-error"
|
||||||
|
pageNameModalPullProgress = "modal-pull-progress"
|
||||||
|
pageNameModalQuit = "modal-quit"
|
||||||
|
pageNameModalRemoveDestination = "modal-remove-destination"
|
||||||
|
pageNameModalSourceError = "modal-source-error"
|
||||||
|
pageNameModalStartupCheck = "modal-startup-check"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ui *UI) resetFocus() {
|
func (ui *UI) resetFocus() {
|
||||||
@ -540,26 +541,23 @@ func (ui *UI) hideModal(pageName string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ui *UI) handleMediaServerClosed(exitReason string) {
|
func (ui *UI) handleMediaServerClosed(exitReason string) {
|
||||||
done := make(chan struct{})
|
|
||||||
|
|
||||||
ui.app.QueueUpdateDraw(func() {
|
ui.app.QueueUpdateDraw(func() {
|
||||||
|
if ui.pages.HasPage(pageNameModalSourceError) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
modal := tview.NewModal()
|
modal := tview.NewModal()
|
||||||
modal.SetText("Mediaserver error: " + exitReason).
|
modal.SetText("Mediaserver error: " + exitReason).
|
||||||
AddButtons([]string{"Quit"}).
|
AddButtons([]string{"Quit"}).
|
||||||
SetBackgroundColor(tcell.ColorBlack).
|
SetBackgroundColor(tcell.ColorBlack).
|
||||||
SetTextColor(tcell.ColorWhite).
|
SetTextColor(tcell.ColorWhite).
|
||||||
SetDoneFunc(func(int, string) {
|
SetDoneFunc(func(int, string) {
|
||||||
// TODO: improve app cleanup
|
ui.commandCh <- CommandQuit{}
|
||||||
done <- struct{}{}
|
|
||||||
|
|
||||||
ui.app.Stop()
|
|
||||||
})
|
})
|
||||||
modal.SetBorderStyle(tcell.StyleDefault.Background(tcell.ColorBlack).Foreground(tcell.ColorWhite))
|
modal.SetBorderStyle(tcell.StyleDefault.Background(tcell.ColorBlack).Foreground(tcell.ColorWhite))
|
||||||
|
|
||||||
ui.pages.AddPage("modal", modal, true, true)
|
ui.pages.AddPage(pageNameModalSourceError, modal, true, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
<-done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const dash = "—"
|
const dash = "—"
|
||||||
@ -904,7 +902,6 @@ func (ui *UI) confirmQuit() {
|
|||||||
func(buttonIndex int, _ string) {
|
func(buttonIndex int, _ string) {
|
||||||
if buttonIndex == 0 {
|
if buttonIndex == 0 {
|
||||||
ui.commandCh <- CommandQuit{}
|
ui.commandCh <- CommandQuit{}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user