-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat: add Cypress #1094
Merged
asyncapi-bot
merged 29 commits into
asyncapi:master
from
aeworxet:feat-add-dockerfile-cypress-code-generation-codemirror
Sep 17, 2024
Merged
feat: add Cypress #1094
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
8287ca2
feat: add Dockerfile, Cypress, code generation
aeworxet 902c44a
feat: add Dockerfile, Cypress, code generation
aeworxet f98436d
feat: add Dockerfile, Cypress, code generation
aeworxet 385f0d6
feat: add Dockerfile, Cypress, code generation
aeworxet 8f1f7b0
feat: add Dockerfile, Cypress
aeworxet e24606e
feat: add Dockerfile
aeworxet ad1d99a
feat: add Dockerfile
aeworxet 3f72d69
feat: add Dockerfile
aeworxet dda3030
feat: add Dockerfile
aeworxet 8c53284
feat: add Dockerfile
aeworxet c3baa62
feat: add Dockerfile
aeworxet 961799a
feat: add Dockerfile
aeworxet 53c6915
feat: add Dockerfile
aeworxet 3553e8d
feat: add Cypress
aeworxet c505fcd
feat: add Cypress
aeworxet 17c7a22
add pnpm-lock.yaml
aeworxet a07f335
modify package.json
aeworxet c0f4083
modify Docker config
aeworxet 2048b44
add .eslintrc
aeworxet 70264db
add ignoring of ESLint's old warnings and error
aeworxet 8583bb0
remove Docker-related code
aeworxet 21e1755
update pnpm-lock.yaml
aeworxet 1db3a5b
update pnpm-lock.yaml
aeworxet e66f922
Update @asyncapi/converter version
aeworxet bc3486b
update pnpm-lock.yaml
aeworxet 5051992
renamed `ConvertVersion` -> `AsyncAPIConvertVersion`
aeworxet 0994c77
Merge branch 'master' into feat-add-dockerfile-cypress-code-generatio…
aeworxet 1fc8590
update pnpm-lock.yaml
aeworxet 97fc975
Merge branch 'master' into feat-add-dockerfile-cypress-code-generatio…
KhudaDad414 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Disable specific file since it would introduce more complexity to reduce it - mainly code complexity and complex template literals | ||
sonar.exclusions=apps/studio/public/js/monaco/**,apps/studio/src/tailwind.css,apps/studio/src/components/SplitPane/** | ||
sonar.exclusions=apps/studio/public/js/monaco/**,apps/studio/src/tailwind.css,apps/studio/src/components/SplitPane/**,apps/studio-next/cypress/**,apps/studio-next/Dockerfile | ||
# Disable duplicate code in tests since it would introduce more complexity to reduce it. | ||
sonar.cpd.exclusions=apps/studio/**,apps/studio-next/src/components/Navigationv3.tsx,apps/studio-next/src/components/Navigation.tsx | ||
sonar.cpd.exclusions=apps/studio/**,apps/studio-next/src/components/Navigationv3.tsx,apps/studio-next/src/components/Navigation.tsx,apps/studio-next/cypress/** |
This file contains 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,9 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"browser": true, | ||
"node": true | ||
}, | ||
"plugins": ["security"], | ||
"extends":["eslint-config-custom", "eslint-config-custom/react"] | ||
} |
This file contains 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,11 @@ | ||
import { defineConfig } from 'cypress'; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
baseUrl: 'http://localhost:3001', | ||
retries: { | ||
runMode: 1, | ||
openMode: 1, | ||
}, | ||
}, | ||
}); |
This file contains 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,136 @@ | ||
// import { isV3 } from "../../src/components/Sidebar"; | ||
const isV3Test = true; | ||
|
||
/* Testing commented hovers is impossible even with `cypress-real-events` so | ||
testing of these hovers is postponed until either Cypress has better support for | ||
`mouseover`/`mouseenter` events or the architecture of `Studio` is changed to | ||
allow testing those. */ | ||
|
||
describe('Studio UI spec', () => { | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
}); | ||
|
||
it('Logo should be visible in the UI', () => { | ||
cy.get('[data-test="logo"]').should('be.visible'); | ||
}); | ||
|
||
// it('Logo should display tooltip "AsyncAPI Logo" on hover', () => { | ||
// cy.get('[data-test="logo"]').trigger('mouseenter'); | ||
// cy.contains('AsyncAPI Logo').should('be.visible'); | ||
// }); | ||
|
||
it('Button "AsyncAPI Website" should be visible in the UI', () => { | ||
cy.get('[data-test="button-website"]').should('be.visible'); | ||
}); | ||
|
||
// it('Button "AsyncAPI Website" should display tooltip "AsyncAPI Website" on hover', () => { | ||
// cy.get('[data-test="button-website"]').trigger('mouseenter'); | ||
// cy.contains('AsyncAPI Website').should('be.visible'); | ||
// }); | ||
|
||
it('Button "AsyncAPI Github Organization" should be visible in the UI', () => { | ||
cy.get('[data-test="button-github"]').should('be.visible'); | ||
}); | ||
|
||
// it('Button "AsyncAPI Github Organization" should display tooltip "AsyncAPI Github Organization" on hover', () => { | ||
// cy.get('[data-test="button-github"]').trigger('mouseenter'); | ||
// cy.contains('AsyncAPI Github Organization').should('be.visible'); | ||
// }); | ||
|
||
it('Button "AsyncAPI Slack Workspace" should be visible in the UI', () => { | ||
cy.get('[data-test="button-slack"]').should('be.visible'); | ||
}); | ||
|
||
// it('Button "AsyncAPI Slack Workspace" should display tooltip "AsyncAPI Slack Workspace" on hover', () => { | ||
// cy.get('[data-test="button-slack"]').trigger('mouseenter'); | ||
// cy.contains('AsyncAPI Slack Workspace').should('be.visible'); | ||
// }); | ||
|
||
it('Button "Navigation" should be visible in the UI', () => { | ||
cy.get('[data-test="button-navigation"]').should('be.visible'); | ||
}); | ||
|
||
it('Button "Navigation" should display tooltip "Navigation" on hover', () => { | ||
cy.get('[data-test="button-navigation"]').trigger('mouseenter'); | ||
cy.contains('Navigation').should('be.visible'); | ||
}); | ||
|
||
it('Button "Editor" should be visible in the UI', () => { | ||
cy.get('[data-test="button-editor"]').should('be.visible'); | ||
}); | ||
|
||
it('Button "Editor" should display tooltip "Editor" on hover', () => { | ||
cy.get('[data-test="button-editor"]').trigger('mouseenter'); | ||
cy.contains('Editor').should('be.visible'); | ||
}); | ||
|
||
it('Button "Template preview" should be visible in the UI', () => { | ||
cy.get('[data-test="button-template-preview"]').should('be.visible'); | ||
}); | ||
|
||
it('Button "Template preview" should display tooltip "Template preview" on hover', () => { | ||
cy.get('[data-test="button-template-preview"]').trigger('mouseenter'); | ||
cy.contains('Template preview').should('be.visible'); | ||
}); | ||
|
||
if (!isV3Test) { // review the need of v2 testing in general | ||
it('Button "Blocks visualiser" should be visible in the UI', () => { | ||
cy.get('[data-test="button-blocks-visualiser"]').should('be.visible'); | ||
}); | ||
|
||
it('Button "Blocks visualiser" should display tooltip "Blocks visualiser" on hover', () => { | ||
cy.get('[data-test="button-blocks-visualiser"]').trigger('mouseenter'); | ||
cy.contains('Blocks visualiser').should('be.visible'); | ||
}); | ||
} | ||
|
||
it('Button "New file" should be visible in the UI', () => { | ||
cy.get('[data-test="button-new-file"]').should('be.visible'); | ||
}); | ||
|
||
it('Button "New file" should display tooltip "New file" on hover', () => { | ||
cy.get('[data-test="button-new-file"]').trigger('mouseenter'); | ||
cy.contains('New file').should('be.visible'); | ||
}); | ||
|
||
it('Button "Settings" should be visible in the UI', () => { | ||
cy.get('[data-test="button-settings"]').should('be.visible'); | ||
}); | ||
|
||
it('Button "Settings" should display tooltip "Studio settings" on hover', () => { | ||
cy.get('[data-test="button-settings"]').trigger('mouseenter'); | ||
cy.contains('Studio settings').should('be.visible'); | ||
}); | ||
|
||
it('Button "Share" should be visible in the UI', () => { | ||
cy.get('[data-test="button-share"]').should('be.visible'); | ||
}); | ||
|
||
it('Button "Share" should display tooltip "Share link" on hover', () => { | ||
cy.get('[data-test="button-share"]').trigger('mouseenter'); | ||
cy.contains('Share link').should('be.visible'); | ||
}); | ||
|
||
it('Button "Dropdown" should be visible in the UI', () => { | ||
cy.get('[data-test="button-dropdown"]').should('be.visible'); | ||
}); | ||
|
||
it('Dropdown menu should contain 8 elements with predefined text', () => { | ||
cy.get('[data-test="button-dropdown"]').click(); | ||
cy.contains('Import from URL'); | ||
cy.contains('Import File'); | ||
cy.contains('Import from Base64'); | ||
cy.contains('Generate code/docs'); | ||
cy.contains('Save as YAML'); | ||
cy.contains('Convert and save as JSON'); | ||
cy.contains('Convert to JSON'); | ||
cy.contains('Convert document'); | ||
}); | ||
|
||
it('Click on Dropdown menu\'s element "Generate code/docs" should open Modal window "Generate code/docs based on your AsyncAPI Document"', () => { | ||
cy.get('[data-test="button-dropdown"]').click(); | ||
cy.contains('Generate code/docs').click(); | ||
cy.contains('Generate code/docs based on your AsyncAPI Document'); | ||
}); | ||
}); |
This file contains 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,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains 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,37 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************** | ||
// This example commands.ts shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
// | ||
// declare global { | ||
// namespace Cypress { | ||
// interface Chainable { | ||
// login(email: string, password: string): Chainable<void> | ||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element> | ||
// } | ||
// } | ||
// } |
This file contains 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,20 @@ | ||
// *********************************************************** | ||
// This example support/e2e.ts is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
This file contains 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 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 |
---|---|---|
|
@@ -6,11 +6,17 @@ | |
"dev": "next dev -p 3001", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "echo 'No linting configured'" | ||
"lint": "next lint", | ||
"cy:e2e:chrome": "cypress run --e2e --browser chrome", | ||
"cy:e2e:chromium": "cypress run --e2e --browser chromium", | ||
"cy:e2e:edge": "cypress run --e2e --browser edge", | ||
"cy:e2e:electron": "cypress run --e2e --browser electron", | ||
"cy:e2e:firefox": "cypress run --e2e --browser firefox", | ||
"cy:open": "cypress open" | ||
}, | ||
"dependencies": { | ||
"@asyncapi/avro-schema-parser": "^3.0.19", | ||
"@asyncapi/converter": "^1.4.16", | ||
"@asyncapi/converter": "^1.6.0", | ||
"@asyncapi/openapi-schema-parser": "^3.0.18", | ||
"@asyncapi/parser": "^3.2.2", | ||
"@asyncapi/protobuf-schema-parser": "^3.2.8", | ||
|
@@ -30,12 +36,10 @@ | |
"react-icons": "^4.6.0", | ||
"reactflow": "^11.2.0", | ||
"@stoplight/yaml": "^4.3.0", | ||
"@codemirror/view": "^6.26.3", | ||
"@types/node": "20.4.6", | ||
"@types/react": "18.2.18", | ||
"@types/react-dom": "18.2.7", | ||
"autoprefixer": "10.4.14", | ||
"codemirror": "^6.0.1", | ||
"eslint-config-next": "13.4.12", | ||
"next": "14.2.3", | ||
"postcss": "8.4.31", | ||
|
@@ -72,6 +76,7 @@ | |
"autoprefixer": "^10.4.13", | ||
"browserify-zlib": "^0.2.0", | ||
"buffer": "^6.0.3", | ||
"cypress": "^13.10.0", | ||
"eslint-config-next": "14.1.4", | ||
"eslint-plugin-security": "^1.5.0", | ||
"eslint-plugin-sonarjs": "^0.16.0", | ||
|
@@ -88,5 +93,6 @@ | |
"util": "^0.12.5", | ||
"web-vitals": "^3.1.0", | ||
"webpack": "^5.75.0" | ||
} | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains 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 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,6 @@ | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function POST(request: Request) { | ||
const response = await request.json(); | ||
return new NextResponse(`route POST -> ${JSON.stringify(response)}`, {status: 201}); | ||
} |
This file contains 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we can use Server Actions instead 🤔 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jerensl
I searched the Internet back and forth and couldn't find answers to several simple questions.
You seem to be very knowledgeable in Next.js Server's matters, so I would like to consult with you on this topic.
Server Actions are meant for performing data fetching and mutations on the Next.js Server.
To my understanding, this implies that Server ALREADY exists as an independent entity, in order for a Server Action to have an environment to be executed in.
In this particular case, right now, full Server consists of one API route.
Thus, if this one and only API route is replaced by a Server Action, the Server will simply vanish, and Server Action will have no place to be executed in.
Besides, this API route is responsible for Server Response, which requires exactly the
next/server
package, and not for data fetching from a third-party resource or a mutation.Taking this into account, does Server Action even make sense in this case, or should the structure with one API route remain (for now, the final architecture of the
Studio
's Server-Side is not defined yet, and this route is added only as a Proof Of Concept and a stub in place where the future Server will be?)Please correct me if I'm getting something wrong in the new for me concept of Server Actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aeworxet
I still new to this Reace Server Components (RSC), so I will answers as much as I know
The thing about Api Route which their rebranding as Route Handler is not supposed to be replaced by Server Actions but different type options in the Architecture which would be considered during the design
https://www.youtube.com/watch?v=PtX5PF17tlQ
Server Actions are supposed to work on top of the React Server Component(RSC) but the majority of the applications inside StudioWrapper do not leverage RSC even for NextJS features like SSR/SSG do not work there
Static Side Generator -> render JSX to HTML during built time
Server Side Rendering -> render JSX to HTML at server when requested by a Client (give what u need only)
This one of the good resources Dan Abramov explains what are the responsibilities of SSR(What NextJS did) and RSC, and how they work together interchangeably
reactwg/server-components#5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jerensl
Thanks.
@KhudaDad414
Would it be safe to assume that Server Actions should not be used currently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aeworxet you are right, we first need to decide how we are going to architecture the component for the
app
directory.