-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[APM] fix cypress #128411
[APM] fix cypress #128411
Changes from all commits
8034e16
85b7660
98e9641
2e033bb
2e44992
01388e7
f9ee17c
03a428e
00bb3e5
5dbae55
d3e6308
9daa050
aa3a1dc
307927d
642cf4a
29f7744
1351e2a
bf4192a
d690444
d529b21
8da126c
aff3d00
c84828c
8200b5f
8c4fe01
537b205
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 |
---|---|---|
|
@@ -41,12 +41,12 @@ describe('Infrastracture feature flag', () => { | |
|
||
cy.get(infraToggle) | ||
.should('have.attr', 'aria-checked') | ||
.and('equal', 'true'); | ||
.and('equal', 'false'); | ||
}); | ||
|
||
it('shows infrastructure tab in service overview page', () => { | ||
it('hides infrastructure tab in service overview page', () => { | ||
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. Infrastructure tab is now disabled by default |
||
cy.visit(serviceOverviewPath); | ||
cy.contains('a[role="tab"]', 'Infrastructure').click(); | ||
cy.contains('a[role="tab"]', 'Infrastructure').should('not.exist'); | ||
}); | ||
}); | ||
|
||
|
@@ -59,12 +59,12 @@ describe('Infrastracture feature flag', () => { | |
|
||
cy.get(infraToggle) | ||
.should('have.attr', 'aria-checked') | ||
.and('equal', 'false'); | ||
.and('equal', 'true'); | ||
}); | ||
|
||
it('hides infrastructure tab in service overview page', () => { | ||
it('shows infrastructure tab in service overview page', () => { | ||
cy.visit(serviceOverviewPath); | ||
cy.contains('a[role="tab"]', 'Infrastructure').should('not.exist'); | ||
cy.contains('a[role="tab"]', 'Infrastructure').click(); | ||
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. Why is this click() there? I get that you swapped things around, wondering why it was there in the first place. Is it needed? Is it a test masked as an interaction? 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. Good point, I think it's a test. If that's the case we could improve it during the test plan @MiriamAparicio what do you think? 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. @gbamparop can you add this to the flaky tests issue? 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. Added it in |
||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,8 +49,7 @@ describe('Rules', () => { | |
// Create a rule in APM | ||
cy.visit('/app/apm/services'); | ||
cy.contains('Alerts and rules').click(); | ||
cy.contains('Error count').click(); | ||
cy.contains('Create threshold rule').click(); | ||
cy.contains('Create error count rule').click(); | ||
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. The name of the button was changed. |
||
|
||
// Check for the existence of this element to make sure the form | ||
// has loaded. | ||
|
@@ -69,10 +68,6 @@ describe('Rules', () => { | |
before(() => { | ||
cy.loginAsPowerUser(); | ||
deleteAllRules(); | ||
cy.intercept( | ||
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. We were waiting for a third-party API to be called to start the test, and it's not necessary since the button needed to run the test is always there. |
||
'GET', | ||
'/api/alerting/rules/_find?page=1&per_page=10&default_search_operator=AND&sort_field=name&sort_order=asc' | ||
).as('list rules API call'); | ||
}); | ||
|
||
after(() => { | ||
|
@@ -83,11 +78,6 @@ describe('Rules', () => { | |
// Go to stack management | ||
cy.visit('/app/management/insightsAndAlerting/triggersActions/rules'); | ||
|
||
// Wait for this call to finish so the create rule button does not disappear. | ||
// The timeout is set high because at this point we're also waiting for the | ||
// full page load. | ||
cy.wait('@list rules API call', { timeout: 30000 }); | ||
|
||
// Create a rule | ||
cy.contains('button', 'Create rule').click(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ const start = '2021-10-10T00:00:00.000Z'; | |
const end = '2021-10-10T00:15:00.000Z'; | ||
const errorDetailsPageHref = url.format({ | ||
pathname: | ||
'/app/apm/services/opbeans-java/errors/0000000000000000000000000Error%201', | ||
'/app/apm/services/opbeans-java/errors/0000000000000000000000000Error%200', | ||
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. The test was navigating to the wrong error page where it didn't find any errors and broke. And it was trying to link on the discover link but didn't find it. |
||
query: { | ||
rangeFrom: start, | ||
rangeTo: end, | ||
|
@@ -89,7 +89,7 @@ describe('Error details', () => { | |
describe('when clicking on View x occurences in discover', () => { | ||
it('should redirects the user to discover', () => { | ||
cy.visit(errorDetailsPageHref); | ||
cy.contains('span', 'Discover').click(); | ||
cy.contains('View 1 occurrence in Discover.').click(); | ||
cy.url().should('include', 'app/discover'); | ||
}); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ const apisToIntercept = [ | |
}, | ||
]; | ||
|
||
describe('Home page', () => { | ||
// flaky test | ||
describe.skip('Home page', () => { | ||
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. should we skip this? is it not fixed? 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. This test is flaky. I skipped it so we can take a look during FF. |
||
before(async () => { | ||
await synthtrace.index( | ||
opbeans({ | ||
|
@@ -46,12 +47,12 @@ describe('Home page', () => { | |
cy.loginAsReadOnlyUser(); | ||
}); | ||
|
||
it('Redirects to service page with rangeFrom and rangeTo added to the URL', () => { | ||
it('Redirects to service page with environment, rangeFrom and rangeTo added to the URL', () => { | ||
cy.visit('/app/apm'); | ||
|
||
cy.url().should( | ||
'include', | ||
'app/apm/services?rangeFrom=now-15m&rangeTo=now' | ||
'app/apm/services?environment=ENVIRONMENT_ALL&rangeFrom=now-15m&rangeTo=now' | ||
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. There is now a redirect for a default environment and the environment param was not in the test url |
||
); | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,11 +46,6 @@ const apisToIntercept = [ | |
'/internal/apm/services/opbeans-node/service_overview_instances/main_statistics?*', | ||
name: 'instancesMainStatisticsRequest', | ||
}, | ||
{ | ||
cauemarcondes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
endpoint: | ||
'/internal/apm/services/opbeans-node/errors/groups/main_statistics?*', | ||
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. The errors API doesn't accept transaction type anymore. |
||
name: 'errorGroupsMainStatisticsRequest', | ||
}, | ||
{ | ||
endpoint: | ||
'/internal/apm/services/opbeans-node/transaction/charts/breakdown?*', | ||
|
@@ -144,7 +139,7 @@ describe('Service overview - header filters', () => { | |
.find('li') | ||
.first() | ||
.click(); | ||
cy.get('[data-test-subj="suggestionContainer"]').realPress('{enter}'); | ||
cy.get('[data-test-subj="headerFilterKuerybar"]').type('{enter}'); | ||
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. what's the difference between .type and .realPress? 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. Cypress events, like 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. ok, can you add that as a comment to the flaky tests issue? we can try to fix it there if possible but if we can't no biggie. |
||
cy.url().should('include', '&kuery=transaction.name'); | ||
}); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
* 2.0. | ||
*/ | ||
|
||
import moment from 'moment'; | ||
import url from 'url'; | ||
import { synthtrace } from '../../../../synthtrace'; | ||
import { opbeans } from '../../../fixtures/synthtrace/opbeans'; | ||
|
@@ -23,12 +24,12 @@ const apiRequestsToIntercept = [ | |
{ | ||
endpoint: | ||
'/internal/apm/services/opbeans-node/transactions/groups/main_statistics?*', | ||
aliasName: 'transactionsGroupsMainStadisticsRequest', | ||
aliasName: 'transactionsGroupsMainStatisticsRequest', | ||
}, | ||
{ | ||
endpoint: | ||
'/internal/apm/services/opbeans-node/errors/groups/main_statistics?*', | ||
aliasName: 'errorsGroupsMainStadisticsRequest', | ||
aliasName: 'errorsGroupsMainStatisticsRequest', | ||
}, | ||
{ | ||
endpoint: | ||
|
@@ -59,18 +60,18 @@ const apiRequestsToInterceptWithComparison = [ | |
{ | ||
endpoint: | ||
'/internal/apm/services/opbeans-node/transactions/groups/detailed_statistics?*', | ||
aliasName: 'transactionsGroupsDetailedStadisticsRequest', | ||
aliasName: 'transactionsGroupsDetailedStatisticsRequest', | ||
}, | ||
{ | ||
endpoint: | ||
'/internal/apm/services/opbeans-node/service_overview_instances/main_statistics?*', | ||
aliasName: 'instancesMainStadisticsRequest', | ||
aliasName: 'instancesMainStatisticsRequest', | ||
}, | ||
|
||
{ | ||
endpoint: | ||
'/internal/apm/services/opbeans-node/service_overview_instances/detailed_statistics?*', | ||
aliasName: 'instancesDetailedStadisticsRequest', | ||
aliasName: 'instancesDetailedStatisticsRequest', | ||
}, | ||
]; | ||
|
||
|
@@ -84,7 +85,8 @@ const aliasNamesWithComparison = apiRequestsToInterceptWithComparison.map( | |
|
||
const aliasNames = [...aliasNamesNoComparison, ...aliasNamesWithComparison]; | ||
|
||
describe('Service Overview', () => { | ||
// flaky test | ||
describe.skip('Service Overview', () => { | ||
before(async () => { | ||
await synthtrace.index( | ||
opbeans({ | ||
|
@@ -104,37 +106,16 @@ describe('Service Overview', () => { | |
cy.visit(baseUrl); | ||
}); | ||
|
||
it('has no detectable a11y violations on load', () => { | ||
it('renders all components on the page', () => { | ||
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. Cypress was logging off randomly after the test, so I decided to create a single test that checks if all components are visible. 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. that's odd 🤔 IMHO it's fine to have them all in one test anyway though. |
||
cy.contains('opbeans-node'); | ||
// set skipFailures to true to not fail the test when there are accessibility failures | ||
checkA11y({ skipFailures: true }); | ||
}); | ||
|
||
it('transaction latency chart', () => { | ||
cy.get('[data-test-subj="latencyChart"]'); | ||
}); | ||
|
||
it('throughput chart', () => { | ||
cy.get('[data-test-subj="throughput"]'); | ||
}); | ||
|
||
it('transactions group table', () => { | ||
cy.get('[data-test-subj="transactionsGroupTable"]'); | ||
}); | ||
|
||
it('error table', () => { | ||
cy.get('[data-test-subj="serviceOverviewErrorsTable"]'); | ||
}); | ||
|
||
it('dependencies table', () => { | ||
cy.get('[data-test-subj="dependenciesTable"]'); | ||
}); | ||
|
||
it('instances latency distribution chart', () => { | ||
cy.get('[data-test-subj="instancesLatencyDistribution"]'); | ||
}); | ||
|
||
it('instances table', () => { | ||
cy.get('[data-test-subj="serviceOverviewInstancesTable"]'); | ||
}); | ||
}); | ||
|
@@ -241,16 +222,18 @@ describe('Service Overview', () => { | |
it('when selecting a different time range and clicking the update button', () => { | ||
cy.wait(aliasNames, { requestTimeout: 10000 }); | ||
|
||
cy.selectAbsoluteTimeRange( | ||
'Oct 10, 2021 @ 01:00:00.000', | ||
'Oct 10, 2021 @ 01:30:00.000' | ||
); | ||
const timeStart = moment(start).subtract(5, 'm').toISOString(); | ||
const timeEnd = moment(end).subtract(5, 'm').toISOString(); | ||
|
||
cy.selectAbsoluteTimeRange(timeStart, timeEnd); | ||
|
||
cy.contains('Update').click(); | ||
|
||
cy.expectAPIsToHaveBeenCalledWith({ | ||
apisIntercepted: aliasNames, | ||
value: | ||
'start=2021-10-10T00%3A00%3A00.000Z&end=2021-10-10T00%3A30%3A00.000Z', | ||
value: `start=${encodeURIComponent( | ||
new Date(timeStart).toISOString() | ||
)}&end=${encodeURIComponent(new Date(timeEnd).toISOString())}`, | ||
}); | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,8 @@ const apisToIntercept = [ | |
}, | ||
]; | ||
|
||
describe('Service overview: Time Comparison', () => { | ||
// Skipping tests since it's flaky. | ||
describe.skip('Service overview: Time Comparison', () => { | ||
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. Skipping tests since it's flaky. We should re-check this test during FF. 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. Any idea what makes it flaky? can you create an issue for the skipped test(s)? 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. |
||
before(async () => { | ||
await synthtrace.index( | ||
opbeans({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,9 +38,10 @@ describe('Transactions Overview', () => { | |
|
||
it('has no detectable a11y violations on load', () => { | ||
cy.visit(serviceTransactionsHref); | ||
cy.contains('aria-selected="true"', 'Transactions').should( | ||
'have.class', | ||
'euiTab-isSelected' | ||
cy.get('a:contains(Transactions)').should( | ||
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. Test was not using an appropriate selector. |
||
'have.attr', | ||
'aria-selected', | ||
'true' | ||
); | ||
// set skipFailures to true to not fail the test when there are accessibility failures | ||
checkA11y({ skipFailures: true }); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ async function testRunner({ getService }: FtrProviderContext) { | |
const result = await cypressStart(getService, cypress.run); | ||
|
||
if (result && (result.status === 'failed' || result.totalFailed > 0)) { | ||
throw new Error(`APM Cypress tests failed`); | ||
process.exit(1); | ||
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. Is there a way to print useful information to the console? or is it already printed by cypress itself? 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. Cypress already prints the list of tests both the ones that failed and the ones the were successful. |
||
} | ||
} | ||
|
||
|
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.
It wasn't breaking CI, but it was broken after running the test multiple times because the state had to be cleared after the test ran.