Add weekly weather cards and improve news API fallback

This commit is contained in:
Jacob Dubin
2026-05-11 22:44:56 -05:00
parent 67c738fae3
commit df3b34c8ad
15 changed files with 66158 additions and 37 deletions

View File

@@ -1801,6 +1801,14 @@ public sealed class JiboInteractionServiceTests
Assert.Contains("Tuesday: light rain, high 61, low 52.", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Saturday: light rain, high 61, low 52.", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.Contains("Temperatures are in Fahrenheit.", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.NotNull(decision.SkillPayload);
Assert.True(decision.SkillPayload!.TryGetValue("weather_weekly_cards", out var weeklyCardsValue));
var weeklyCards = Assert.IsAssignableFrom<IReadOnlyList<IDictionary<string, object?>>>(weeklyCardsValue);
Assert.Equal(5, weeklyCards.Count);
var firstCard = weeklyCards[0];
Assert.Equal("Tuesday", firstCard["weather_day"]);
Assert.Equal(61, firstCard["weather_high"]);
Assert.Equal(52, firstCard["weather_low"]);
}
[Fact]
@@ -1829,6 +1837,10 @@ public sealed class JiboInteractionServiceTests
Assert.NotNull(provider.LastRequest);
Assert.Equal("Seattle", provider.LastRequest!.LocationQuery);
Assert.Equal(5, provider.LastRequest.ForecastDayOffset);
Assert.NotNull(decision.SkillPayload);
Assert.True(decision.SkillPayload!.TryGetValue("weather_weekly_cards", out var weeklyCardsValue));
var weeklyCards = Assert.IsAssignableFrom<IReadOnlyList<IDictionary<string, object?>>>(weeklyCardsValue);
Assert.Equal(5, weeklyCards.Count);
}
[Fact]

View File

@@ -2250,6 +2250,53 @@ public sealed class JiboWebSocketServiceTests
Assert.Contains("tempNormal_v01.crn", payloadText, StringComparison.Ordinal);
}
[Fact]
public async Task ClientAsr_WeatherNextWeek_WithProvider_EmitsWeatherHiLoSequenceCards()
{
var customStore = new InMemoryCloudStateStore();
var customService = CreateService(
customStore,
new StubWeatherReportProvider(
new WeatherReportSnapshot("Seattle, US", "light rain", 58, 61, 52, "rain", false)));
await customService.HandleMessageAsync(new WebSocketMessageEnvelope
{
HostName = "neo-hub.jibo.com",
Path = "/listen",
Kind = "neo-hub-listen",
Token = "hub-weather-next-week-token",
Text = """{"type":"LISTEN","transID":"trans-weather-next-week","data":{"hotphrase":true,"rules":["launch","globals/global_commands_launch"]}}"""
});
var replies = await customService.HandleMessageAsync(new WebSocketMessageEnvelope
{
HostName = "neo-hub.jibo.com",
Path = "/listen",
Kind = "neo-hub-listen",
Token = "hub-weather-next-week-token",
Text = """{"type":"CLIENT_ASR","transID":"trans-weather-next-week","data":{"text":"forecast for seattle next week"}}"""
});
Assert.True(replies.Count >= 3);
var skillReply = replies.Last(static reply => string.Equals(ReadReplyType(reply), "SKILL_ACTION", StringComparison.Ordinal));
using var skillPayload = JsonDocument.Parse(skillReply.Text!);
var jcp = skillPayload.RootElement
.GetProperty("data")
.GetProperty("action")
.GetProperty("config")
.GetProperty("jcp");
Assert.Equal("SEQUENCE", jcp.GetProperty("type").GetString());
var children = jcp.GetProperty("children");
Assert.Equal(5, children.GetArrayLength());
var firstChildConfig = children[0].GetProperty("config");
Assert.True(firstChildConfig.TryGetProperty("display", out var firstDisplay));
Assert.Equal(
"weatherTempView",
firstDisplay.GetProperty("view").GetProperty("data").GetProperty("viewConfig").GetProperty("id").GetString());
}
[Fact]
public async Task ClientAsr_OpenTheRadio_EmitsRadioRedirectAndSilentCompletion()
{