generated from finos-labs/project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 92
Introduce E2E Tests for Calm Hub UI #1854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2b93620
feat(calm-hub-ui): add e2e testing framework and test specs
YoofiTT96 fbebc55
feat(calm-hub-ui): add e2e test for adrs, flows, patterns, visualizer
YoofiTT96 c900d36
feat(calm-hub-ui): update documentation for e2e tests
YoofiTT96 a9a141c
Merge branch 'refs/heads/main' into e2e-tests
YoofiTT96 8c203ff
feat(calm-hub-ui): update documentation for e2e tests
YoofiTT96 bcd6831
feat(calm-hub-ui): use envs for config
YoofiTT96 7784d08
Merge branch 'refs/heads/main' into e2e-tests
YoofiTT96 6758796
Update calm-hub-ui/src/hub/components/json-renderer/JsonRenderer.tsx
YoofiTT96 78d0275
Update calm-hub-ui/cypress/e2e/adrs.cy.ts
YoofiTT96 4c66b6b
Update calm-hub-ui/cypress/e2e/flows.cy.ts
YoofiTT96 9f2c75a
Update calm-hub-ui/README.md
YoofiTT96 2983746
Update calm-hub-ui/README.md
YoofiTT96 c2a2381
Update calm-hub-ui/cypress/e2e/flows.cy.ts
YoofiTT96 3a0a44b
feat(calm-hub-ui): update package.json
YoofiTT96 d52e943
Merge branch 'e2e-tests' of https://github.com/YoofiTT96/architecture…
YoofiTT96 197e3df
Update calm-hub-ui/cypress/e2e/architectures.cy.ts
YoofiTT96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| VITE_BASE_URL=http://localhost:5173 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { defineConfig } from "cypress"; | ||
| import 'dotenv/config'; | ||
|
|
||
| export default defineConfig({ | ||
| e2e: { | ||
| baseUrl: process.env.VITE_BASE_URL, | ||
| }, | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| const expectedNamespace = "finos" | ||
| const expectedAdrId = 1; | ||
| const expectedAdrRevision = 2; | ||
|
|
||
| describe('ADR Tests', () => { | ||
| beforeEach(() => { | ||
| cy.intercept("/calm/namespaces", {"values": [expectedNamespace]}); | ||
| cy.intercept("/calm/namespaces/finos/adrs", {"values": [expectedAdrId]}); | ||
| cy.intercept("/calm/namespaces/finos/adrs/1/revisions", {"values": [expectedAdrRevision]}); | ||
| cy.intercept(`/calm/namespaces/finos/adrs/1/revisions/${expectedAdrRevision}`, { | ||
| fixture: "example-adr" | ||
| }); | ||
| }) | ||
|
|
||
| it("Displays ADR JSON successfully", () => { | ||
| cy.visit("/"); | ||
| cy.findByText(expectedNamespace).click(); | ||
| cy.findByText(/adrs/i).click(); | ||
| cy.findByText(/1/i).click(); | ||
| cy.findByText(expectedAdrRevision).click(); | ||
|
|
||
| cy.fixture('example-adr').then(data => { | ||
| cy.contains(/id/i).should("exist"); | ||
| cy.contains(data.id).should("exist"); | ||
|
|
||
| cy.contains(/namespace/i).should("exist"); | ||
| cy.contains(data.namespace).should("exist"); | ||
|
|
||
| cy.contains(data.revision).should("exist"); | ||
|
|
||
| cy.contains(data.adr.title).should("exist"); | ||
| cy.contains(data.adr.status, { | ||
| matchCase: false | ||
| }).should("exist"); | ||
| cy.contains(/context and problem/i).should("exist") | ||
| cy.contains(data.adr.contextAndProblemStatement).should("exist"); | ||
|
|
||
| cy.contains(/decision drivers/i).should("exist") | ||
| cy.contains(/considered options/i).should("exist") | ||
| cy.contains(/decision outcome/i).should("exist") | ||
|
|
||
| }); | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| const expectedNamespace = "finos" | ||
| const expectedArchitectureId = 1; | ||
| const expectedArchitectureVersion = "1.0.0"; | ||
|
|
||
| describe('Architecture Tests', () => { | ||
| beforeEach(() => { | ||
| cy.intercept("/calm/namespaces", {"values": [expectedNamespace]}); | ||
| cy.intercept("/calm/namespaces/finos/architectures", {"values": [expectedArchitectureId]}); | ||
| cy.intercept("/calm/namespaces/finos/architectures/1/versions", {"values": [expectedArchitectureVersion]}); | ||
| cy.intercept("/calm/namespaces/finos/architectures/1/versions/1.0.0", { | ||
| fixture: "three-tier-calm.json" | ||
| }); | ||
| }) | ||
|
|
||
| it("Displays architecture JSON successfully", () => { | ||
| cy.visit("/"); | ||
| cy.findByText(expectedNamespace).click(); | ||
| cy.findByText(/architectures/i).click(); | ||
| cy.findByText(/1/i).click(); | ||
| cy.findByText(/1.0.0/i).click(); | ||
|
|
||
| cy.findByText(/relationship descriptions/i).should("exist"); | ||
| cy.findByText(/node descriptions/i).should("exist"); | ||
|
|
||
| cy.findByRole("tab", { name: /json/i}).click(); | ||
|
|
||
| cy.fixture('three-tier-calm').then(data => { | ||
| cy.contains(/\$schema/i).should("exist"); | ||
| cy.contains(data.$schema).should("exist"); | ||
| cy.contains(/id/i).should("exist"); | ||
|
|
||
| cy.contains(/nodes/i).should("exist"); | ||
|
|
||
| Object.entries(data.nodes[0]).forEach(([key, value]) => { | ||
| cy.contains(key).should("exist"); | ||
| cy.contains(value as string).should("exist"); | ||
| }); | ||
|
|
||
| cy.contains(/unique-id/i).should("exist"); | ||
| cy.contains(data.nodes[0]["unique-id"]).should("exist"); | ||
|
|
||
| cy.contains(/name/i).should("exist"); | ||
| cy.contains(data.nodes[0]["name"]).should("exist"); | ||
|
|
||
| cy.contains(/description/i).should("exist"); | ||
| cy.contains(data.nodes[0]["description"]).should("exist"); | ||
|
|
||
| cy.contains(/node-type/i).should("exist"); | ||
| cy.contains(data.nodes[0]["node-type"]).should("exist"); | ||
| }); | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| const expectedNamespace = "finos" | ||
| const expectedFlowId = 1; | ||
| const expectedFlowVersion = "1.0.0"; | ||
|
|
||
| describe('Flow Tests', () => { | ||
| beforeEach(() => { | ||
| cy.intercept("/calm/namespaces", {"values": [expectedNamespace]}); | ||
| cy.intercept("/calm/namespaces/finos/flows", {"values": [expectedFlowId]}); | ||
| cy.intercept("/calm/namespaces/finos/flows/1/versions", {"values": [expectedFlowVersion]}); | ||
| cy.intercept("/calm/namespaces/finos/flows/1/versions/1.0.0", { | ||
| fixture: "update-account-flow" | ||
| }); | ||
| }) | ||
|
|
||
| it("Displays flow JSON successfully", () => { | ||
| cy.visit("/"); | ||
| cy.findByText(expectedNamespace).click(); | ||
| cy.findByText(/flows/i).click(); | ||
| cy.findByText(/1/i).click(); | ||
| cy.findByText(/1.0.0/i).click(); | ||
|
|
||
| cy.fixture('update-account-flow').then(data => { | ||
| cy.contains(/\$schema/i).should("exist"); | ||
| cy.contains(data.$schema).should("exist"); | ||
|
|
||
| cy.contains(/\$id/i).should("exist"); | ||
| cy.contains(data.$id).should("exist"); | ||
|
|
||
| cy.contains(/unique-id/i).should("exist"); | ||
| cy.contains(data["unique-id"]).should("exist"); | ||
|
|
||
| cy.contains(/name/i).should("exist"); | ||
| cy.contains(data.name).should("exist"); | ||
|
|
||
| cy.contains(/description/i).should("exist"); | ||
| cy.contains(data.description).should("exist"); | ||
|
|
||
| cy.contains(/transitions/i).should("exist"); | ||
|
|
||
| Object.entries(data.transitions[0]).forEach(([key, value]) => { | ||
| cy.contains(key).should("exist"); | ||
| cy.contains(value as string).should("exist"); | ||
| }); | ||
|
|
||
| }); | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import {namespaces, resourceTypes} from "../fixtures/constants.js"; | ||
|
|
||
| describe('Home page tests', () => { | ||
| beforeEach(() => { | ||
| cy.intercept("/calm/namespaces", {"values": namespaces}) | ||
| }) | ||
|
|
||
| it('Loads initial screen successfully', () => { | ||
| cy.visit('/'); | ||
| cy.findByText("Explore").should("exist"); | ||
| cy.findByText("Namespaces").should("exist"); | ||
| namespaces.forEach(namespace => cy.findByText(namespace).should("exist")); | ||
| cy.findByText(namespaces[0]).click(); | ||
| resourceTypes.forEach(resourceType => { cy.findByText(resourceType).should("exist"); }); | ||
| }) | ||
|
|
||
| context("Wide screen tests", () => { | ||
| it("Finds navigation items", () => { | ||
| cy.viewport('macbook-16') | ||
| cy.visit('/'); | ||
| cy.findByRole("link", { name: "Hub" }) | ||
| cy.findByRole("link", { name: "Visualizer" }) | ||
| }) | ||
|
|
||
| }) | ||
|
|
||
| context("Collapsed screen tests", () => { | ||
| it("Finds navigation items", () => { | ||
| cy.viewport(1000, 600) | ||
| cy.visit('/'); | ||
| cy.findByRole("button", { name: "Open Menu" }).click(); | ||
| cy.findByRole("link", { name: "Hub" }) | ||
| cy.findByRole("link", { name: "Visualizer" }) | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| const expectedNamespace = "finos" | ||
| const expectedPatternId = 1; | ||
| const expectedPatternVersion = "1.0.0"; | ||
|
|
||
| describe('Pattern Tests', () => { | ||
| beforeEach(() => { | ||
| cy.intercept("/calm/namespaces", {"values": [expectedNamespace]}); | ||
| cy.intercept("/calm/namespaces/finos/patterns", {"values": [expectedPatternId]}); | ||
| cy.intercept("/calm/namespaces/finos/patterns/1/versions", {"values": [expectedPatternVersion]}); | ||
| cy.intercept("/calm/namespaces/finos/patterns/1/versions/1.0.0", { | ||
| fixture: "conference-signup-pattern" | ||
| }); | ||
| }) | ||
|
|
||
| it("Displays pattern JSON successfully", () => { | ||
| cy.visit("/"); | ||
| cy.findByText(expectedNamespace).click(); | ||
| cy.findByText(/patterns/i).click(); | ||
| cy.findByText(/1/i).click(); | ||
| cy.findByText(/1.0.0/i).click(); | ||
|
|
||
| cy.fixture('conference-signup-pattern').then(data => { | ||
| cy.contains(/\$schema/i).should("exist"); | ||
| cy.contains(data.$schema).should("exist"); | ||
|
|
||
| cy.contains(/\$id/i).should("exist"); | ||
| cy.contains(data.$id).should("exist"); | ||
|
|
||
| cy.contains(/title/i).should("exist"); | ||
| cy.contains(data.title).should("exist"); | ||
|
|
||
| cy.contains(/description/i).should("exist"); | ||
| cy.contains(data.description).should("exist"); | ||
|
|
||
| cy.contains(/minItems/i).should("exist"); | ||
| cy.contains(data.properties.nodes.minItems).should("exist"); | ||
|
|
||
| cy.contains(data.properties.nodes.minItems).should("exist"); | ||
|
|
||
| cy.contains(/prefixItems/i).should("exist"); | ||
| }); | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| describe("Visualizer page tests", () => { | ||
| it("Displays visualizer on navigation", () => { | ||
| cy.viewport('macbook-16') | ||
| cy.visit("/"); | ||
|
|
||
| cy.findByRole("link", { name: "Visualizer" }).click(); | ||
|
|
||
| cy.get('canvas').should("not.exist"); | ||
| cy.findByText(/drag and drop your file here/i).should("exist"); | ||
|
|
||
| cy.fixture("three-tier-calm", null).as('architecture'); | ||
| cy.get('input[type=file]').selectFile("@architecture", {force: true}) | ||
|
|
||
| cy.get('canvas').should("exist"); | ||
| cy.findByText(/relationship descriptions/i).should("exist"); | ||
| cy.findByText(/node descriptions/i).should("exist"); | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.