Merge branch 'feat/dnd-kit-grid' into feat/widget-modernization

This commit is contained in:
Thomas Camlong committed 2026-08-11 11:05:26 +02:00
commit afe17eefc8
2 files changed
+34 -30

No files matched your search

+2 -2
View File
@@ -46,8 +46,8 @@
"scripts:update-bug-report-template": "tsx ./scripts/update-bug-report-template.mts", "scripts:update-bug-report-template": "tsx ./scripts/update-bug-report-template.mts",
"scripts:update-readme-integrations": "tsx ./scripts/update-integration-list.mts", "scripts:update-readme-integrations": "tsx ./scripts/update-integration-list.mts",
"start": "pnpm -F nextjs start", "start": "pnpm -F nextjs start",
"test": "cross-env NODE_ENV=development CI=true vitest run --project \"!e2e\" --coverage.enabled ", "test": "cross-env NODE_ENV=development CI=true vitest run --project \"!e2e\" --retry 2 --coverage.enabled ",
"test:e2e": "cross-env NODE_ENV=development CI=true vitest e2e", "test:e2e": "cross-env NODE_ENV=development CI=true vitest e2e --retry 2 --maxWorkers 2",
"test:workshop": "sh apps/workshop/test.sh", "test:workshop": "sh apps/workshop/test.sh",
"test:workshop-image": "sh apps/workshop/test-image.sh", "test:workshop-image": "sh apps/workshop/test-image.sh",
"test:ui": "cross-env NODE_ENV=development CI=true vitest --project \"!e2e\" --ui --coverage.enabled", "test:ui": "cross-env NODE_ENV=development CI=true vitest --project \"!e2e\" --ui --coverage.enabled",
@@ -41,35 +41,37 @@ describe("Home Assistant integration", () => {
test("Test connection should work", async () => { test("Test connection should work", async () => {
// Arrange // Arrange
const startedContainer = await prepareHomeAssistantContainerAsync(); const startedContainer = await prepareHomeAssistantContainerAsync();
const homeAssistantIntegration = createHomeAssistantIntegration(startedContainer); try {
const homeAssistantIntegration = createHomeAssistantIntegration(startedContainer);
// Act // Act
const result = await homeAssistantIntegration.testConnectionAsync(); const result = await homeAssistantIntegration.testConnectionAsync();
// Assert // Assert
expect(result.success).toBe(true); expect(result.success).toBe(true);
} finally {
// Cleanup await startedContainer.stop();
await startedContainer.stop(); }
}, 30_000); // Timeout of 30 seconds }, 60_000);
test("Test connection should fail with wrong credentials", async () => { test("Test connection should fail with wrong credentials", async () => {
// Arrange // Arrange
const startedContainer = await prepareHomeAssistantContainerAsync(); const startedContainer = await prepareHomeAssistantContainerAsync();
const homeAssistantIntegration = createHomeAssistantIntegration(startedContainer, "wrong-api-key"); try {
const homeAssistantIntegration = createHomeAssistantIntegration(startedContainer, "wrong-api-key");
// Act // Act
const result = await homeAssistantIntegration.testConnectionAsync(); const result = await homeAssistantIntegration.testConnectionAsync();
// Assert // Assert
expect(result.success).toBe(false); expect(result.success).toBe(false);
if (result.success) return; if (result.success) return;
expect(result.error).toBeInstanceOf(TestConnectionError); expect(result.error).toBeInstanceOf(TestConnectionError);
expect(result.error.type).toBe("authorization"); expect(result.error.type).toBe("authorization");
} finally {
// Cleanup await startedContainer.stop();
await startedContainer.stop(); }
}, 30_000); // Timeout of 30 seconds }, 60_000);
}); });
const prepareHomeAssistantContainerAsync = async () => { const prepareHomeAssistantContainerAsync = async () => {
@@ -77,27 +79,29 @@ const prepareHomeAssistantContainerAsync = async () => {
const startedContainer = await homeAssistantContainer.start(); const startedContainer = await homeAssistantContainer.start();
await startedContainer.exec(["unzip", "-o", "/tmp/config.zip", "-d", "/config"]); await startedContainer.exec(["unzip", "-o", "/tmp/config.zip", "-d", "/config"]);
await startedContainer.restart(); await startedContainer.restart();
await waitForHomeAssistantAsync(startedContainer); await waitForHomeAssistantApiAsync(startedContainer);
return startedContainer; return startedContainer;
}; };
const waitForHomeAssistantAsync = async (container: StartedTestContainer) => { const waitForHomeAssistantApiAsync = async (container: StartedTestContainer) => {
const url = `http://${container.getHost()}:${container.getMappedPort(8123)}/api/config`; const url = `http://${container.getHost()}:${container.getMappedPort(8123)}/api/config`;
const deadline = Date.now() + 45_000;
for (let attempt = 0; attempt < 40; attempt++) { while (Date.now() < deadline) {
try { try {
const response = await fetch(url, { const response = await fetch(url, {
headers: { Authorization: `Bearer ${DEFAULT_API_KEY}` }, headers: { Authorization: `Bearer ${DEFAULT_API_KEY}` },
signal: AbortSignal.timeout(1_000),
}); });
if (response.ok) return; if (response.ok) return;
} catch { } catch {
// Home Assistant is still restarting. // Home Assistant closes connections while restarting. Retry until the deadline.
} }
await new Promise((resolve) => setTimeout(resolve, 250));
await new Promise((resolve) => setTimeout(resolve, 500));
} }
throw new Error("Home Assistant did not become ready after restart"); await container.stop();
throw new Error("Home Assistant API did not become ready after restart");
}; };
const createHomeAssistantContainer = () => { const createHomeAssistantContainer = () => {