More test fixes

This commit is contained in:
Wolfgang Kulhanek
2025-10-17 10:32:12 +02:00
parent 8ef6e2064d
commit 254bd5a149

View File

@@ -566,8 +566,8 @@ function bindSmapiSoapServiceToExpress(
}, },
}), }),
refreshAuthToken: async (_, _2, soapyHeaders: SoapyHeaders, refreshAuthToken: async (_, _2, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers">) => { req: Pick<Request, "headers">) => {
const creds = useHeaderIfPresent(soapyHeaders?.credentials, headers); const creds = useHeaderIfPresent(soapyHeaders?.credentials, req.headers);
// Get the old SMAPI token from credentials before refreshing // Get the old SMAPI token from credentials before refreshing
const oldSmapiToken = creds?.loginToken.token; const oldSmapiToken = creds?.loginToken.token;
const serviceToken = pipe( const serviceToken = pipe(
@@ -602,9 +602,9 @@ function bindSmapiSoapServiceToExpress(
{ id }: { id: string }, { id }: { id: string },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then(({ musicLibrary, credentials, type, typeId }) => { .then(({ musicLibrary, credentials, type, typeId }) => {
switch (type) { switch (type) {
@@ -642,9 +642,9 @@ function bindSmapiSoapServiceToExpress(
{ id }: { id: string }, { id }: { id: string },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then(async ({ musicLibrary, apiKey, type, typeId }) => { .then(async ({ musicLibrary, apiKey, type, typeId }) => {
switch (type) { switch (type) {
@@ -664,9 +664,9 @@ function bindSmapiSoapServiceToExpress(
{ id, term }: { id: string; term: string }, { id, term }: { id: string; term: string },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then(async ({ musicLibrary, apiKey }) => { .then(async ({ musicLibrary, apiKey }) => {
switch (id) { switch (id) {
@@ -710,9 +710,9 @@ function bindSmapiSoapServiceToExpress(
{ id: string; index: number; count: number; recursive: boolean }, { id: string; index: number; count: number; recursive: boolean },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then(async ({ musicLibrary, apiKey, type, typeId }) => { .then(async ({ musicLibrary, apiKey, type, typeId }) => {
const paging = { _index: index, _count: count }; const paging = { _index: index, _count: count };
@@ -782,13 +782,13 @@ function bindSmapiSoapServiceToExpress(
{ id: string; index: number; count: number; recursive: boolean }, { id: string; index: number; count: number; recursive: boolean },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then(({ musicLibrary, apiKey, type, typeId }) => { .then(({ musicLibrary, apiKey, type, typeId }) => {
const paging = { _index: index, _count: count }; const paging = { _index: index, _count: count };
const acceptLanguage = headers["accept-language"]; const acceptLanguage = req.headers["accept-language"];
logger.debug( logger.debug(
`Fetching metadata type=${type}, typeId=${typeId}, acceptLanguage=${acceptLanguage}` `Fetching metadata type=${type}, typeId=${typeId}, acceptLanguage=${acceptLanguage}`
); );
@@ -1108,9 +1108,9 @@ function bindSmapiSoapServiceToExpress(
{ title, seedId }: { title: string; seedId: string | undefined }, { title, seedId }: { title: string; seedId: string | undefined },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(({ musicLibrary }) => .then(({ musicLibrary }) =>
musicLibrary musicLibrary
.createPlaylist(title) .createPlaylist(title)
@@ -1135,18 +1135,18 @@ function bindSmapiSoapServiceToExpress(
{ id }: { id: string }, { id }: { id: string },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(({ musicLibrary }) => musicLibrary.deletePlaylist(id)) .then(({ musicLibrary }) => musicLibrary.deletePlaylist(id))
.then((_) => ({ deleteContainerResult: {} })), .then((_) => ({ deleteContainerResult: {} })),
addToContainer: async ( addToContainer: async (
{ id, parentId }: { id: string; parentId: string }, { id, parentId }: { id: string; parentId: string },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then(({ musicLibrary, typeId }) => .then(({ musicLibrary, typeId }) =>
musicLibrary.addToPlaylist(parentId.split(":")[1]!, typeId) musicLibrary.addToPlaylist(parentId.split(":")[1]!, typeId)
@@ -1156,9 +1156,9 @@ function bindSmapiSoapServiceToExpress(
{ id, indices }: { id: string; indices: string }, { id, indices }: { id: string; indices: string },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then((it) => ({ .then((it) => ({
...it, ...it,
@@ -1180,9 +1180,9 @@ function bindSmapiSoapServiceToExpress(
{ id, rating }: { id: string; rating: number }, { id, rating }: { id: string; rating: number },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then(({ musicLibrary, typeId }) => .then(({ musicLibrary, typeId }) =>
musicLibrary.rate(typeId, ratingFromInt(Math.abs(rating))) musicLibrary.rate(typeId, ratingFromInt(Math.abs(rating)))
@@ -1193,9 +1193,9 @@ function bindSmapiSoapServiceToExpress(
{ id, seconds }: { id: string; seconds: string }, { id, seconds }: { id: string; seconds: string },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then(({ musicLibrary, type, typeId }) => { .then(({ musicLibrary, type, typeId }) => {
switch (type) { switch (type) {
@@ -1223,9 +1223,9 @@ function bindSmapiSoapServiceToExpress(
{ id, seconds }: { id: string; seconds: string }, { id, seconds }: { id: string; seconds: string },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then(({ type, typeId }) => { .then(({ type, typeId }) => {
if (type === "track") { if (type === "track") {
@@ -1243,9 +1243,9 @@ function bindSmapiSoapServiceToExpress(
{ id, status }: { id: string; status: string }, { id, status }: { id: string; status: string },
_, _,
soapyHeaders: SoapyHeaders, soapyHeaders: SoapyHeaders,
{ headers }: Pick<Request, "headers"> req: Pick<Request, "headers">
) => ) =>
login(soapyHeaders?.credentials, headers) login(soapyHeaders?.credentials, req.headers)
.then(splitId(id)) .then(splitId(id))
.then(({ musicLibrary, type, typeId }) => { .then(({ musicLibrary, type, typeId }) => {
if (type === "track") { if (type === "track") {