Pass version to UI through AppConfig, instead of login payload.master

This makes the version info updated with a browser refresh (no need to logout and login again)
This commit is contained in:
Deluan
2020-04-08 11:00:30 -04:00
parent db246900a6
commit 089a92157f
6 changed files with 35 additions and 14 deletions
+11
View File
@@ -9,6 +9,7 @@ import (
"strconv"
"github.com/deluan/navidrome/conf"
"github.com/deluan/navidrome/consts"
"github.com/deluan/navidrome/model"
"github.com/deluan/navidrome/persistence"
. "github.com/onsi/ginkgo"
@@ -79,6 +80,16 @@ var _ = Describe("ServeIndex", func() {
config := extractAppConfig(w.Body.String())
Expect(config).To(HaveKeyWithValue("loginBackgroundURL", "my_background_url"))
})
It("sets the version", func() {
r := httptest.NewRequest("GET", "/index.html", nil)
w := httptest.NewRecorder()
ServeIndex(ds, fs)(w, r)
config := extractAppConfig(w.Body.String())
Expect(config).To(HaveKeyWithValue("version", consts.Version()))
})
})
var appConfigRegex = regexp.MustCompile(`(?m)window.__APP_CONFIG__="([^"]*)`)