Skip to content

feat: add Cypress - #1094

Merged
asyncapi-bot merged 29 commits into
asyncapi:masterfrom
aeworxet:feat-add-dockerfile-cypress-code-generation-codemirror
Sep 17, 2024
Merged

asyncapi-bot merged 29 commits into
asyncapi:masterfrom
aeworxet:feat-add-dockerfile-cypress-code-generation-codemirror

Conversation

@aeworxet

@aeworxet aeworxet commented May 5, 2024 •

Copy link
Copy Markdown
Contributor

This PR introduces for ./apps/studio-next:

  • Cypress with testing minimal set of web application's UI elements due to upcoming migration to ./apps/design-system (skeleton of the UI testing that will need to be reviewed after migration)

    • GUI testing is invoked with npm run cy:open
    • Headless end-to-end testing for different browsers is invoked with npm run cy:e2e:* (refer to the cy:e2e:* part of package.json for a list of available browsers (edge is reserved for Windows machines))

    image

  • API route http://localhost:3001/api/v1/generate that only returns requests, just as a proof of concept that the server side is functioning (works only in a local dev environment; the deployed version is subject to CORS restrictions)

Deployment to Vercel is successful and can be viewed at https://asyncapi-studio-studio-next.vercel.app

Related to #661
Related to #1101

@changeset-bot

changeset-bot Bot commented May 5, 2024 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 97fc975

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify

netlify Bot commented May 5, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for modest-rosalind-098b67 ready!

Name Link
🔨 Latest commit 97fc975
🔍 Latest deploy log https://app.netlify.com/sites/modest-rosalind-098b67/deploys/66ea01016254430008573954
😎 Deploy Preview https://deploy-preview-1094--modest-rosalind-098b67.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify

netlify Bot commented May 5, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for asyncapi-studio-design-system ready!

Name Link
🔨 Latest commit 97fc975
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-studio-design-system/deploys/66ea01019a75210007577d87
😎 Deploy Preview https://deploy-preview-1094--asyncapi-studio-design-system.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify

netlify Bot commented May 5, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for studio-next ready!

Name Link
🔨 Latest commit 97fc975
🔍 Latest deploy log https://app.netlify.com/sites/studio-next/deploys/66ea0101be0c9c00080c8465
😎 Deploy Preview https://deploy-preview-1094--studio-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@aeworxet aeworxet mentioned this pull request May 5, 2024
6 of 11 tasks
@aeworxet

aeworxet commented May 5, 2024

Copy link
Copy Markdown
Contributor Author

@Amzani @KhudaDad414
@asyncapi/bounty_team

@asyncapi-bot asyncapi-bot added the bounty AsyncAPI Bounty label May 5, 2024
@aeworxet

aeworxet commented May 5, 2024

Copy link
Copy Markdown
Contributor Author

I started with the addition of Cypress so I could spot regressions during migration to CodeMirror.
Comparison with PR #1062

@Amzani
A couple of questions:

  • Is there a design file (Figma maybe?) where I can take unique names for all HTML elements from, so testing frameworks could find them in the webpage (same as I gave the name data-testid="button-settings" to the Settings button?)
  • What names should I give to HTML elements' data-* attributes: data-testid, data-test, or data-cy?
  • Should there be a separate spec file for components' testing, or, in the case of Studio, only full flow (e2e) makes sense?

@Amzani

Amzani commented May 7, 2024

Copy link
Copy Markdown
Collaborator

@aeworxet

Is there a design file (Figma maybe?) where I can take unique names for all HTML elements from, so testing frameworks could find them in the webpage (same as I gave the name data-testid="button-settings" to the Settings button?)

Not for the existing studio, we only have one for the new improvements that will be integrated once we finish the NextJS migration: https://www.figma.com/proto/bPMB3lkMTOOMuKk0oGLuNm/Studio?type=design&node-id=96-2392&scaling=contain&page-id=0%3A1&starting-point-node-id=2%3A2

What names should I give to HTML elements' data-* attributes: data-testid, data-test, or data-cy?

I vote for data-test for simplicity and in case we want to switch to an other testing tool in the future.

Should there be a separate spec file for components' testing, or, in the case of Studio, only full flow (e2e) makes sense?

The goal is regression test, so I would suggest full flow (e2e), we can encourage components testing for new feature we add to the project.

@KhudaDad414 WDY?

@Amzani

Amzani commented May 9, 2024

Copy link
Copy Markdown
Collaborator

I would remove CodeMirror Integration from the scope of this issue for now, until we merge everything.

@aeworxet

Copy link
Copy Markdown
Contributor Author

I'm working on code generation for Studio, and after POST request to https://api.asyncapi.com/v1/generate I get

Version 3.0.0 is not supported.
Please use latest version of the specification.

Code, responsible for this is
https://github.com/asyncapi/parser-js/blob/master/src/ruleset/functions/isAsyncAPIDocument.ts#L25
https://github.com/asyncapi/parser-js/blob/master/src/constants.ts#L22
and the file which is searched for for 3.0.0 HAS it in master:
https://github.com/asyncapi/spec-json-schemas/blob/master/index.d.ts#L12

It needs to be checked on the server what version of ./node_modules/@asyncapi/specs/index.d.ts it contains.
@smoya

@Amzani

Amzani commented May 20, 2024 •

Copy link
Copy Markdown
Collaborator

@smoya

smoya commented May 20, 2024 •

Copy link
Copy Markdown
Member

So the idea is to directly use the generator library.

@Amzani would you mind linking to where that decission has been made? Just to be in sync with asyncapi-archived-repos/server-api#576 where the idea, afaik, was to keep a server but the code living in CLI repo.

@Amzani

Amzani commented May 21, 2024

Copy link
Copy Markdown
Collaborator

@smoya I was assuming that if only Studio uses this API there is no need to maintain it anymore thus deprecating the server-api repo and not migrate it to CLI to reduce complexity.

@aeworxet

Copy link
Copy Markdown
Contributor Author

So the idea is to directly use the generator library.

@Amzani

@KhudaDad414 suggests the opposite, to stick with server-api.
So which one should it be?

Should I invest time into rewriting the logic for SSR, or should I just bugfix the current approach?

(#1094 (comment) is still relevant then)

@KhudaDad414

Copy link
Copy Markdown
Member

@aeworxet IMHO it makes sense to bug fix the current code base. By that I mean sticking to the server-api approach.

As Fran said in the original issue, migration is already hard enough, trying to implement new features at the same time would quadruple the complexity.

@aeworxet

Copy link
Copy Markdown
Contributor Author

@KhudaDad414
'Code Generation' functionality still requires checking of the ./node_modules/@asyncapi/specs/index.d.ts version on api.asyncapi.com as per #1094 (comment) since it is the server that is returning the error.

image

@KhudaDad414

Copy link
Copy Markdown
Member

@aeworxet Since you get the error on the current Studio as well, I would consider resolving it to be out of scope for this Bounty Issue.

We can have another issue and discuss it over there.

@aeworxet

aeworxet commented Jun 3, 2024

Copy link
Copy Markdown
Contributor Author

I'm investigating options for deployment of Studio to a Docker container, and the possibility that the server part might become completely independent, up to being hosted fully in a CLI with invocation through asyncapi server start, led me to a question if deployment of Studio to a Docker container as a full Next.js app (with API Routes, SSR, and others) is needed at all.

The most runtime-dynamic part of Studio currently is the generation of templates, and it can be done through a POST request to an API from a static website (it is made this way currently, in fact.)

I'm not sure OG preview generation is a mandatory functionality for a containerized Studio, it can be left reserved for https://studio.asyncapi.com

I have deployed to https://asyncapi-studio-studio-next.vercel.app a build of Studio with output: 'export' (explanation what 'export' build is, features that are NOT supported.)

The whole 'export' build is nine (9) Mb, it has First Contentful Paint 0.4 s (+ better overall performance score in Lighthouse,) and it doesn't seem to lack any functionality.

Should this version of Studio's build be used for a Docker container?

@Amzani

Amzani commented Jun 3, 2024

Copy link
Copy Markdown
Collaborator

The most runtime-dynamic part of Studio currently is the generation of templates, and it can be done through a POST request to an API from a static website (it is made this way currently, in fact.)

We want to enable long term features like authentication for instance. generation of templates using API to POST should be something we could migrate IMO as we don't want to maintain an entire repository just for 1 single POST /generate method instead of using directly the generator library.

Should this version of Studio's build be used for a Docker container?

How complex is having everything in Docker image?

@aeworxet

aeworxet commented Jun 4, 2024

Copy link
Copy Markdown
Contributor Author

@Amzani

How complex is having everything in Docker image?

It is supposed to be straightforward but I ran into an error on a command that executes fine on desktop, so I'm investigating it.

image

@KhudaDad414

Copy link
Copy Markdown
Member

@aeworxet

aeworxet commented Jul 9, 2024

Copy link
Copy Markdown
Contributor Author

Disabled ESLint's rules on warnings and the error.

@aeworxet

aeworxet commented Jul 9, 2024

Copy link
Copy Markdown
Contributor Author

SonarCloud is frozen.

image

Sergio was dealing with this issue several days ago
asyncapi/parser-js#1008 (comment)

@aeworxet aeworxet changed the title feat: add Dockerfile, Cypress feat: add Cypress Jul 10, 2024
@aeworxet

Copy link
Copy Markdown
Contributor Author

Can this PR be merged, or is there anything else that needs to be done on it?

@asyncapi-bot asyncapi-bot removed the bounty AsyncAPI Bounty label Aug 11, 2024
@Amzani

Amzani commented Sep 11, 2024

Copy link
Copy Markdown
Collaborator

@aeworxet could you fix the conflict ?
Thanks

@aeworxet

Copy link
Copy Markdown
Contributor Author

@Amzani
Fixed.

@aeworxet

Copy link
Copy Markdown
Contributor Author

I had to rename

ConvertVersion -> AsyncAPIConvertVersion

which was renamed recently in @asyncapi/converter v1.5.0.

In the change's PR only the name was changed, so all functionality is supposed to remain the same, but pinging @jonaslagoni just in case.

@Amzani Amzani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aeworxet

Copy link
Copy Markdown
Contributor Author

@KhudaDad414
Can you please dismiss your change request since I have removed all Docker-related code?

@sonarqubecloud

Copy link
Copy Markdown

@KhudaDad414

Copy link
Copy Markdown
Member

/rtm

@asyncapi-bot
asyncapi-bot merged commit 41365d4 into asyncapi:master Sep 17, 2024
@aeworxet
aeworxet deleted the feat-add-dockerfile-cypress-code-generation-codemirror branch September 17, 2024 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants