-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
test: add e2e tests for pages under tools dropdown #4533
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
base: master
Are you sure you want to change the base?
Changes from all commits
0c6bcdd
cfacd6e
504f7f3
a41b39e
88e545d
a9c6212
2118a1a
ada737a
9df361d
b1a9aff
4fb2c32
09f8016
626a99a
acbdb6b
d81fa0a
a3fb69a
38cb603
844ff45
b689fe3
a36ba19
88335e4
5134008
4044946
0083202
bd8f6e1
ac3e698
1e3e949
c0baccf
d8fc389
c52db52
d6a5e32
d106460
7447d5d
6f0a445
bdfbcf6
95aedb9
1c4b835
e181b2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "generator": { | ||
| "path": "/tools/generator", | ||
| "heading": "Docs, Code, Anything!", | ||
| "image": "generator diagram", | ||
| "github": "https://www.github.com/asyncapi/generator", | ||
| "docs": "/docs/tools/generator" | ||
| }, | ||
| "cli": { | ||
| "path": "/tools/cli", | ||
| "heading": "Interact with AsyncAPI from the comfort of your CLI", | ||
| "install": "npm install -g @asyncapi/cli", | ||
| "github": "https://www.github.com/asyncapi/cli", | ||
| "docs": "/docs/tools/cli" | ||
| }, | ||
| "parsers": { | ||
| "path": "/tools/parsers", | ||
| "heading": "Build your own tools", | ||
| "install": "npm install @asyncapi/parser", | ||
| "github": "https://www.github.com/asyncapi/parser-js" | ||
| }, | ||
| "githubActions": { | ||
| "path": "/tools/github-actions", | ||
| "heading": "Automate using GitHub Actions", | ||
| "github": "https://www.github.com/asyncapi/github-action-for-generator" | ||
| }, | ||
| "modelina": { | ||
| "path": "/tools/modelina", | ||
| "heading": "Modelina", | ||
| "install": "npm install @asyncapi/modelina", | ||
| "tryIt": { | ||
| "text": "Try it now", | ||
| "href": "https://modelina.org/playground" | ||
| }, | ||
| "github": "https://www.github.com/asyncapi/modelina" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,55 @@ | ||||
| class BasePage { | ||||
| visit(url = '/') { | ||||
| cy.visit(url); | ||||
| } | ||||
|
|
||||
| getElement(selector) { | ||||
| return cy.get(selector); | ||||
| } | ||||
|
|
||||
| hoverElement(selector) { | ||||
| return this.getElement(selector) | ||||
| .trigger('mouseover') | ||||
| .trigger('mouseenter'); | ||||
| } | ||||
|
|
||||
| verifyElementIsVisible(selector) { | ||||
| return this.getElement(selector).should('be.visible'); | ||||
| } | ||||
|
|
||||
| verifyElementHasAttribute(selector, attribute, value) { | ||||
| return this.getElement(selector).should('have.attr', attribute, value); | ||||
| } | ||||
|
|
||||
| verifyHeadingExists(headingText) { | ||||
| return cy.contains('h1, h2, h3, h4, h5, h6', headingText).should('be.visible'); | ||||
| } | ||||
|
|
||||
| verifyLink(href, text, { findByText = false } = {}) { | ||||
| if (findByText && text) { | ||||
| const chain = cy.contains('a', text).should('be.visible'); | ||||
| return href ? chain.and('have.attr', 'href', href) : chain; | ||||
| } | ||||
| const chain = cy.get(`a[href="${href}"]`).should('be.visible').and('have.attr', 'href', href); | ||||
| return text ? chain.and('contain', text) : chain; | ||||
| } | ||||
|
|
||||
| verifyButtonLink(href, buttonText) { | ||||
| return this.verifyLink(href, buttonText, { findByText: true }); | ||||
| } | ||||
|
|
||||
| verifyElementContainsText(selector, text) { | ||||
| return cy.contains(selector, text).should('exist'); | ||||
| } | ||||
|
|
||||
| verifyImageVisible(altText) { | ||||
| return cy.get(`img[alt="${altText}"]`) | ||||
| .should('be.visible') | ||||
| .and('have.attr', 'src') | ||||
| .should('not.be.empty'); | ||||
| } | ||||
|
|
||||
|
|
||||
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| class BlogPage { | ||
| import BasePage from './BasePage'; | ||
|
|
||
| class BlogPage extends BasePage { | ||
| verifyPageLoaded() { | ||
| cy.contains('h1', 'Welcome to our blog!').should('be.visible'); | ||
| this.verifyHeadingExists('Welcome to our blog!'); | ||
| } | ||
| } | ||
|
|
||
anushkaaaaaaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export default BlogPage; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| class CaseStudiesPage { | ||
| import BasePage from './BasePage'; | ||
|
|
||
| class CaseStudiesPage extends BasePage { | ||
| verifyPageLoaded() { | ||
| cy.contains('h1', 'Case Studies').should('be.visible'); | ||
| this.verifyHeadingExists('Case Studies'); | ||
| } | ||
| } | ||
|
|
||
anushkaaaaaaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export default CaseStudiesPage; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| class CommunityPage { | ||
| import BasePage from './BasePage'; | ||
|
|
||
| class CommunityPage extends BasePage { | ||
| verifyPageLoaded() { | ||
| cy.contains('h1','Home of #CommunityOps') | ||
| .should('be.visible'); | ||
| this.verifyHeadingExists('Home of #CommunityOps'); | ||
| } | ||
| } | ||
anushkaaaaaaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export default CommunityPage; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| class RoadmapPage { | ||
| import BasePage from './BasePage'; | ||
|
|
||
| class RoadmapPage extends BasePage { | ||
| verifyPageLoaded() { | ||
| cy.contains('h1', 'AsyncAPI becomes the #1 API specification for defining and developing APIs.').should('be.visible'); | ||
| this.verifyHeadingExists('AsyncAPI becomes the #1 API specification for defining and developing APIs.'); | ||
| } | ||
| } | ||
|
|
||
anushkaaaaaaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export default RoadmapPage; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import BasePage from './BasePageTools'; | ||
| import BasePage from './BasePage'; | ||
anushkaaaaaaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| class ToolsPage extends BasePage { | ||
anushkaaaaaaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| visitToolsPage() { | ||
| super.visit('/tools'); | ||
| } | ||
|
|
||
| verifyPageLoaded() { | ||
| cy.contains('h1', 'Tools').should('be.visible'); | ||
| this.verifyHeadingExists('Tools'); | ||
| } | ||
|
|
||
| verifyHeader() { | ||
|
|
@@ -24,21 +24,8 @@ class ToolsPage extends BasePage { | |
| .parents('.rounded-lg.border.shadow-md') | ||
| .first() | ||
| .within(() => { | ||
| cy.get('h2').should('contain', heading); | ||
| this.verifyHeadingExists(heading); | ||
| }); | ||
| } | ||
|
|
||
| verifyWebsiteLinks(href, heading) { | ||
| this.verifyToolLink(href, heading, 'website'); | ||
| } | ||
|
|
||
| verifyGithubLinks(href, heading) { | ||
| this.verifyToolLink(href, heading, 'github'); | ||
| } | ||
|
|
||
| verifyDocsLinks(href, heading) { | ||
| this.verifyToolLink(href, heading, 'docs'); | ||
| } | ||
| } | ||
|
|
||
anushkaaaaaaaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export default ToolsPage; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import BasePage from './BasePage'; | ||
| import CaseStudiesPage from './CaseStudiesPage'; | ||
| import DocsPage from './DocsPage'; | ||
| import RoadmapPage from './RoadmapPage'; | ||
|
|
@@ -34,30 +35,9 @@ const homepageLinks = features.flatMap((feature) => | |
| })), | ||
| ); | ||
|
|
||
| class HomePage { | ||
| class HomePage extends BasePage { | ||
| visit() { | ||
| cy.visit('/'); | ||
| } | ||
|
|
||
| verifyElementIsVisible(selector) { | ||
| cy.get(selector).should('be.visible'); | ||
| } | ||
|
|
||
| verifyElementHasAttribute(selector, attribute, value) { | ||
| cy.get(selector).should('have.attr', attribute, value); | ||
| } | ||
|
|
||
| verifyHeadingExists(headingText) { | ||
| cy.contains('h1, h2, h3, h4, h5, h6', headingText).should('be.visible'); | ||
| } | ||
|
|
||
| verifyLinkExists(linkName, linkUrl) { | ||
| cy.get('a') | ||
| .contains(linkName, { matchCase: false }) | ||
| .should('exist') | ||
| .then(($el) => { | ||
| cy.wrap($el).invoke('attr', 'href').should('include', linkUrl); | ||
| }); | ||
| return super.visit('/'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In line 43, can you remove the This is part of your existing code that you have already merged. Since we have enhanced our |
||
| } | ||
|
|
||
| verifyCardTitles(customTitles, testId = null) { | ||
|
|
@@ -71,21 +51,20 @@ class HomePage { | |
| } | ||
|
|
||
| verifyNavbarLogo() { | ||
| this.verifyElementIsVisible('[data-testid="Navbar-logo"]'); | ||
| return this.verifyElementIsVisible('[data-testid="Navbar-logo"]'); | ||
| } | ||
|
|
||
| verifyHeader(text = headerText) { | ||
| this.verifyHeadingExists(text); | ||
| return this.verifyHeadingExists(text); | ||
| } | ||
|
|
||
| verifyGithubStarButton(link = githubStarLink) { | ||
| const selector = '[data-testid="Navbar-main"] [data-testid="Button-link"]'; | ||
| this.verifyElementIsVisible(selector); | ||
| this.verifyElementHasAttribute(selector, 'href', link); | ||
| return this.verifyElementIsVisible(selector).and('have.attr', 'href', link); | ||
| } | ||
|
|
||
| verifyReadTheDocsButton(link = readDocsLink) { | ||
| cy.get(`[data-testid="Button-link"][href="${link}"]`).should('be.visible'); | ||
| return cy.get(`[data-testid="Button-link"][href="${link}"]`).should('be.visible'); | ||
| } | ||
|
|
||
| verifyHomepageCards( | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||
| import BasePage from './BasePage'; | ||||
| import toolsData from '../fixtures/toolsPages.json'; | ||||
|
|
||||
| class ToolsGenerator extends BasePage { | ||||
|
|
||||
|
||||
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.
This is a commented-out assertion that should either be removed or uncommented. Leaving commented code reduces code clarity. The change appears intentional to remove the visibility check, but the commented line should be deleted rather than left in the codebase.