From be0cfa90516f7a6d567c1ee53be2a83088fe5035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pol=20Amor=C3=B3s?= Date: Wed, 13 Mar 2024 11:13:47 +0100 Subject: [PATCH] fix(console): add sanity test (#5926) Resolves https://github.com/winglang/wing/issues/5925 *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*. --- .../console/app/test/cloud.api/index.test.ts | 2 +- .../console/app/test/cloud.bucket/index.test.ts | 4 ++-- .../console/app/test/cloud.counter/index.test.ts | 6 +++--- .../console/app/test/cloud.function/index.test.ts | 2 +- .../console/app/test/cloud.queue/index.test.ts | 4 ++-- .../console/app/test/cloud.topic/index.test.ts | 2 +- .../console/app/test/cloud.website/index.test.ts | 2 +- .../console/app/test/ex.dynamodb-table/index.test.ts | 4 ++-- .../console/app/test/ex.redis/index.test.ts | 4 ++-- .../console/app/test/ex.table/index.test.ts | 6 +++--- .../console/app/test/health/health.test.ts | 10 ++++++++++ apps/wing-console/console/app/test/health/main.w | 2 ++ apps/wing-console/console/ui/src/layout/status-bar.tsx | 1 + 13 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 apps/wing-console/console/app/test/health/health.test.ts create mode 100644 apps/wing-console/console/app/test/health/main.w diff --git a/apps/wing-console/console/app/test/cloud.api/index.test.ts b/apps/wing-console/console/app/test/cloud.api/index.test.ts index 20d179cb369..b3dccf278e0 100644 --- a/apps/wing-console/console/app/test/cloud.api/index.test.ts +++ b/apps/wing-console/console/app/test/cloud.api/index.test.ts @@ -10,7 +10,7 @@ const runApiTest = async ( route: string, response: string, ) => { - await getResourceNode(page, "root/Default/cloud.Api").click(); + await getResourceNode(page, "root/Default/Api").click(); await page.getByTestId("cloud.api:method-toggle").click(); await page.getByTestId(`cloud.api:method-entry-${method}`).click(); diff --git a/apps/wing-console/console/app/test/cloud.bucket/index.test.ts b/apps/wing-console/console/app/test/cloud.bucket/index.test.ts index 00319a10dfc..877c90f9650 100644 --- a/apps/wing-console/console/app/test/cloud.bucket/index.test.ts +++ b/apps/wing-console/console/app/test/cloud.bucket/index.test.ts @@ -5,7 +5,7 @@ import { getResourceNode } from "../helpers.js"; describe(`${__dirname}/main.w`, () => { test.skip("opens file preview", async ({ page }) => { - await getResourceNode(page, "root/Default/cloud.Bucket").click(); + await getResourceNode(page, "root/Default/Bucket").click(); await page.getByTestId("cloud.bucket:files-entry-test.txt").click(); @@ -15,7 +15,7 @@ describe(`${__dirname}/main.w`, () => { }); test.skip("deletes a file", async ({ page }) => { - await getResourceNode(page, "root/Default/cloud.Bucket").click(); + await getResourceNode(page, "root/Default/Bucket").click(); const file = page.getByTestId("cloud.bucket:files-entry-test.txt"); diff --git a/apps/wing-console/console/app/test/cloud.counter/index.test.ts b/apps/wing-console/console/app/test/cloud.counter/index.test.ts index 6530273fc6e..4b5794832a9 100644 --- a/apps/wing-console/console/app/test/cloud.counter/index.test.ts +++ b/apps/wing-console/console/app/test/cloud.counter/index.test.ts @@ -5,7 +5,7 @@ import { getResourceNode } from "../helpers.js"; describe(`${__dirname}/main.w`, () => { test.skip("increase counter", async ({ page }) => { - await getResourceNode(page, "root/Default/cloud.Counter").click(); + await getResourceNode(page, "root/Default/Counter").click(); const currentValue = page.getByTestId("cloud.counter:current-value"); @@ -17,7 +17,7 @@ describe(`${__dirname}/main.w`, () => { }); test.skip("decreases counter", async ({ page }) => { - await getResourceNode(page, "root/Default/cloud.Counter").click(); + await getResourceNode(page, "root/Default/Counter").click(); const currentValue = page.getByTestId("cloud.counter:current-value"); @@ -29,7 +29,7 @@ describe(`${__dirname}/main.w`, () => { }); test.skip("resets counter", async ({ page }) => { - await getResourceNode(page, "root/Default/cloud.Counter").click(); + await getResourceNode(page, "root/Default/Counter").click(); const currentValue = page.getByTestId("cloud.counter:current-value"); diff --git a/apps/wing-console/console/app/test/cloud.function/index.test.ts b/apps/wing-console/console/app/test/cloud.function/index.test.ts index d6c64540802..976fba5249d 100644 --- a/apps/wing-console/console/app/test/cloud.function/index.test.ts +++ b/apps/wing-console/console/app/test/cloud.function/index.test.ts @@ -5,7 +5,7 @@ import { getResourceNode } from "../helpers.js"; describe(`${__dirname}/main.w`, () => { test.skip("executes function and shows response", async ({ page }) => { - await getResourceNode(page, "root/Default/cloud.Function").click(); + await getResourceNode(page, "root/Default/Function").click(); await page.getByTestId("cloud.function:invoke").click(); diff --git a/apps/wing-console/console/app/test/cloud.queue/index.test.ts b/apps/wing-console/console/app/test/cloud.queue/index.test.ts index 8b6e61657b8..5038b00eaac 100644 --- a/apps/wing-console/console/app/test/cloud.queue/index.test.ts +++ b/apps/wing-console/console/app/test/cloud.queue/index.test.ts @@ -5,7 +5,7 @@ import { getResourceNode } from "../helpers.js"; describe(`${__dirname}/main.w`, () => { test.skip("pushes message", async ({ page }) => { - await getResourceNode(page, "root/Default/cloud.Queue").click(); + await getResourceNode(page, "root/Default/Queue").click(); await page.getByTestId("cloud.queue:message").fill("Hello world!"); @@ -17,7 +17,7 @@ describe(`${__dirname}/main.w`, () => { }); test.skip("purges message", async ({ page }) => { - await getResourceNode(page, "root/Default/cloud.Queue").click(); + await getResourceNode(page, "root/Default/Queue").click(); await page.getByTestId("cloud.queue:message").fill("Hello world!"); diff --git a/apps/wing-console/console/app/test/cloud.topic/index.test.ts b/apps/wing-console/console/app/test/cloud.topic/index.test.ts index ae2cc972c23..3c14826abb5 100644 --- a/apps/wing-console/console/app/test/cloud.topic/index.test.ts +++ b/apps/wing-console/console/app/test/cloud.topic/index.test.ts @@ -5,7 +5,7 @@ import { getResourceNode } from "../helpers.js"; describe(`${__dirname}/main.w`, () => { test.skip("publishes message", async ({ page }) => { - await getResourceNode(page, "root/Default/cloud.Topic").click(); + await getResourceNode(page, "root/Default/Topic").click(); await page.getByTestId("cloud.topic:message").fill("Hello world!"); diff --git a/apps/wing-console/console/app/test/cloud.website/index.test.ts b/apps/wing-console/console/app/test/cloud.website/index.test.ts index d90947e498e..ac1857f991d 100644 --- a/apps/wing-console/console/app/test/cloud.website/index.test.ts +++ b/apps/wing-console/console/app/test/cloud.website/index.test.ts @@ -5,7 +5,7 @@ import { getResourceNode } from "../helpers.js"; describe(`${__dirname}/main.w`, () => { test.skip("open website", async ({ page }) => { - await getResourceNode(page, "root/Default/cloud.Website").click(); + await getResourceNode(page, "root/Default/Website").click(); // not working when app mode is not "local" // const url = await page.getByTestId("cloud.website:url").inputValue(); diff --git a/apps/wing-console/console/app/test/ex.dynamodb-table/index.test.ts b/apps/wing-console/console/app/test/ex.dynamodb-table/index.test.ts index bae5d2a5691..6d935bc2fb0 100644 --- a/apps/wing-console/console/app/test/ex.dynamodb-table/index.test.ts +++ b/apps/wing-console/console/app/test/ex.dynamodb-table/index.test.ts @@ -16,13 +16,13 @@ const addRow = async (page: Page, data?: Record) => { describe(`${__dirname}/main.w`, () => { test.skip("adds new item", async ({ page }) => { - await getResourceNode(page, "root/Default/ex.DynamodbTable").click(); + await getResourceNode(page, "root/Default/DynamodbTable").click(); await addRow(page, { id: "1", key1: "value1", key2: "value2" }); }); test.skip("removes row", async ({ page }) => { - await getResourceNode(page, "root/Default/ex.DynamodbTable").click(); + await getResourceNode(page, "root/Default/DynamodbTable").click(); await addRow(page, { id: "1", key1: "value1", key2: "value2" }); diff --git a/apps/wing-console/console/app/test/ex.redis/index.test.ts b/apps/wing-console/console/app/test/ex.redis/index.test.ts index 1d1325d353d..c289842664b 100644 --- a/apps/wing-console/console/app/test/ex.redis/index.test.ts +++ b/apps/wing-console/console/app/test/ex.redis/index.test.ts @@ -22,7 +22,7 @@ describe(`${__dirname}/main.w`, () => { }); test.skip("opens redis help", async ({ page }) => { - await getResourceNode(page, "root/Default/ex.Redis").click(); + await getResourceNode(page, "root/Default/Redis").click(); const input = page.getByTestId("ex.redis:input"); @@ -40,7 +40,7 @@ describe(`${__dirname}/main.w`, () => { }); test.skip("navigates history", async ({ page }) => { - await getResourceNode(page, "root/Default/ex.Redis").click(); + await getResourceNode(page, "root/Default/Redis").click(); const input = page.getByTestId("ex.redis:input"); diff --git a/apps/wing-console/console/app/test/ex.table/index.test.ts b/apps/wing-console/console/app/test/ex.table/index.test.ts index 71f7fa440f9..2158c9031ee 100644 --- a/apps/wing-console/console/app/test/ex.table/index.test.ts +++ b/apps/wing-console/console/app/test/ex.table/index.test.ts @@ -30,13 +30,13 @@ const addRow = async ( describe(`${__dirname}/main.w`, () => { test.skip("adds new row", async ({ page }) => { - await getResourceNode(page, "root/Default/ex.Table").click(); + await getResourceNode(page, "root/Default/Table").click(); await addRow(page, "Hello World!"); }); test.skip("edits row", async ({ page }) => { - await getResourceNode(page, "root/Default/ex.Table").click(); + await getResourceNode(page, "root/Default/Table").click(); const rowId = "Hello World!"; @@ -55,7 +55,7 @@ describe(`${__dirname}/main.w`, () => { }); test.skip("removes row", async ({ page }) => { - await getResourceNode(page, "root/Default/ex.Table").click(); + await getResourceNode(page, "root/Default/Table").click(); const rowId = "Hello World!"; diff --git a/apps/wing-console/console/app/test/health/health.test.ts b/apps/wing-console/console/app/test/health/health.test.ts new file mode 100644 index 00000000000..3926dec0934 --- /dev/null +++ b/apps/wing-console/console/app/test/health/health.test.ts @@ -0,0 +1,10 @@ +import { expect, test } from "@playwright/test"; + +import { describe } from "../describe.js"; + +describe(`${__dirname}/main.w`, () => { + test("Health check", async ({ page }) => { + const appState = page.getByTestId("app-state"); + await expect(appState).toContainText("success"); + }); +}); diff --git a/apps/wing-console/console/app/test/health/main.w b/apps/wing-console/console/app/test/health/main.w new file mode 100644 index 00000000000..6758e443e08 --- /dev/null +++ b/apps/wing-console/console/app/test/health/main.w @@ -0,0 +1,2 @@ +bring cloud; + diff --git a/apps/wing-console/console/ui/src/layout/status-bar.tsx b/apps/wing-console/console/ui/src/layout/status-bar.tsx index 37ba4691d49..6624783b36f 100644 --- a/apps/wing-console/console/ui/src/layout/status-bar.tsx +++ b/apps/wing-console/console/ui/src/layout/status-bar.tsx @@ -52,6 +52,7 @@ export const StatusBar = ({ Status: