Skip to content

Commit

Permalink
chore(springwolf-ui): re-add smoke-test for complete app
Browse files Browse the repository at this point in the history
Co-authored-by: Timon Back <timonback@users.noreply.github.com>
  • Loading branch information
sam0r040 and timonback committed Dec 13, 2024
1 parent af366bb commit 3b896c7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 10 deletions.
2 changes: 1 addition & 1 deletion springwolf-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build_pages": "ng build",
"watch": "ng build --watch",
"test": "jest --no-cache",
"update": "ng update | awk -v re='@[[:alnum:]]' '$0 ~ re {printf $1 \" \"}' | xargs ng update --force=true"
"update": "ng update | awk -v re='@[[:alnum:]]' '$0 ~ re {printf $1 \" \"}' | xargs ng update --force=true && npm update"
},
"private": true,
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion springwolf-ui/src/app/app.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ main {
padding: 0;
}

section {
article {
margin: 2em 1em;
}
16 changes: 8 additions & 8 deletions springwolf-ui/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<app-header></app-header>
<main class="mat-typography">
<app-sidenav>
<section appNavigationTarget id="info">
<article appNavigationTarget id="info">
<app-info></app-info>
</section>
</article>

<section appNavigationTarget id="servers">
<article appNavigationTarget id="servers">
<app-servers></app-servers>
</section>
</article>

<section appNavigationTarget id="channels">
<article appNavigationTarget id="channels">
<app-channels> </app-channels>
</section>
</article>

<section appNavigationTarget id="schemas">
<article appNavigationTarget id="schemas">
<app-schemas></app-schemas>
</section>
</article>
</app-sidenav>
</main>
47 changes: 47 additions & 0 deletions springwolf-ui/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* SPDX-License-Identifier: Apache-2.0 */
import { AppComponent } from "./app.component";
import { render, screen, waitFor, within } from "@testing-library/angular";
import { appConfig } from "./app.config";
import { MatIconTestingModule } from "@angular/material/icon/testing";

describe("AppComponent", () => {
test("should render", async () => {
await render(AppComponent, {
providers: appConfig.providers,
imports: [MatIconTestingModule],
});

await waitFor(() => {
expect(
screen.getAllByText("Springwolf example project", { exact: false })
.length
).toBeGreaterThan(0);
});

// get menu items
const articles = screen.getAllByRole("article");

// server menu
const servers = articles.find(
(article) => within(article).queryByText("Servers") !== null
);
expect(servers).not.toBeNull();
expect(within(servers!!).getAllByRole("article").length).toBeGreaterThan(0);

// channel menu
const channels = articles.find(
(article) => within(article).queryByText("Channels") !== null
);
expect(channels).not.toBeNull();
expect(within(channels!!).getAllByRole("article").length).toBeGreaterThan(
0
);

// schema menu
const schemas = articles.find(
(article) => within(article).queryByText("Schemas") !== null
);
expect(schemas).not.toBeNull();
expect(within(schemas!!).getAllByRole("article").length).toBeGreaterThan(0);
});
});

0 comments on commit 3b896c7

Please sign in to comment.