Skip to content

Commit

Permalink
add cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
Loggy committed Sep 6, 2021
1 parent 4dcc061 commit 47fe150
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
9 changes: 9 additions & 0 deletions cypress/integration/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ describe('basic test', () => {
cy.location('pathname').should('eq', '/');
});

it('updates flamegraph on app name change', () => {
cy.visit('/')
waitInDevMode(100);

cy.findByTestId('app-name-selector').select('pyroscope.server.cpu');
waitInDevMode(100);
cy.findByTestId('flamegraph-canvas').invoke('attr', 'data-appname').should('eq', 'pyroscope.server.cpu{}');
});

it('view buttons should change view when clicked', () => {
cy.visit('/')
cy.findByTestId('btn-table-view').click();
Expand Down
1 change: 1 addition & 0 deletions webapp/__tests__/__snapshots__/NameSelector.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`NameSelector render correctly NameSelector component 1`] = `
Application: 
<select
className="label-select"
data-testid="app-name-selector"
onChange={[Function]}
value="hotrod.golang.customer"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ class FlameGraph extends React.Component {
<canvas
className="flamegraph-canvas"
height="0"
data-testid="flamegraph-canvas"
data-appname={this.props.label}
ref={this.canvasRef}
onClick={this.clickHandler}
onMouseMove={this.mouseMoveHandler}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
height: 100%;
display: flex;
justify-content: center;
align-items: start;
align-items: flex-start;
position: relative;
padding: 60px 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,7 @@ class FlameGraphRenderer extends React.Component {
format={this.parseFormat(this.state.flamebearer.format)}
view={this.state.view}
ExportData={ExportData}
label={
this.props.labels
? this.props.labels.filter((x) => x.name === "__name__")[0].value
: ""
}
label={this.props.query}
/>
) : null;

Expand Down
1 change: 1 addition & 0 deletions webapp/javascript/components/NameSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function NameSelector(props) {
Application:&nbsp;
<select
className="label-select"
data-testid="app-name-selector"
value={defaultValue}
onChange={selectAppName}
>
Expand Down

0 comments on commit 47fe150

Please sign in to comment.