Improve screenshots

This commit is contained in:
Søren Louv-Jansen 2023-09-07 10:50:01 +02:00
parent 54cf0adc61
commit ad9a53e7cc
7 changed files with 48 additions and 13 deletions

2
.gitignore vendored
View file

@ -94,6 +94,8 @@ npm-debug.log*
## @cypress/snapshot from apm plugin
/snapshots.js
/apm-diagnostics*.json
/x-pack/plugins/apm/ftr_e2e/cypress/e2e/service_map/snapshots/*.actual.png
/x-pack/plugins/apm/ftr_e2e/cypress/e2e/service_map/snapshots/*.diff.png
# transpiled cypress config
x-pack/plugins/fleet/cypress.config.d.ts

View file

@ -55,25 +55,35 @@ describe('service map', () => {
it('shows nodes in service map', () => {
cy.visitKibana(serviceMapHref);
cy.wait('@serviceMap');
cy.wait(500);
cy.getByTestSubj('serviceMap').matchImage({
imagesPath: '{spec_path}/snapshots',
matchAgainstPath: 'cypress/e2e/service_map/snapshots/service_map.png',
maxDiffThreshold: 0.05, // maximum threshold above which the test should fail
});
cy.getByTestSubj('apmServiceGroupsTourDismissButton').click();
prepareCanvasForScreenshot();
cy.withHidden('[data-test-subj="headerGlobalNav"]', () =>
cy.getByTestSubj('serviceMap').matchImage({
imagesPath: '{spec_path}/snapshots',
title: 'global_service_map',
matchAgainstPath: 'cypress/e2e/service_map/snapshots/service_map.png',
maxDiffThreshold: 0.02, // maximum threshold above which the test should fail
})
);
});
it('shows nodes in detailed service map', () => {
cy.visitKibana(detailedServiceMap);
cy.wait('@serviceMap');
cy.contains('h1', 'opbeans-java');
cy.wait(500);
cy.getByTestSubj('serviceMap').matchImage({
imagesPath: '{spec_path}/snapshots',
matchAgainstPath:
'cypress/e2e/service_map/snapshots/detailed_service_map.png',
maxDiffThreshold: 0.05, // maximum threshold above which the test should fail
});
prepareCanvasForScreenshot();
cy.withHidden('[data-test-subj="headerGlobalNav"]', () =>
cy.getByTestSubj('serviceMap').matchImage({
imagesPath: '{spec_path}/snapshots',
matchAgainstPath:
'cypress/e2e/service_map/snapshots/detailed_service_map.png',
maxDiffThreshold: 0.02, // maximum threshold above which the test should fail
})
);
});
describe('when there is no data', () => {
@ -89,3 +99,18 @@ describe('service map', () => {
});
});
});
function prepareCanvasForScreenshot() {
cy.get('html, body').invoke(
'attr',
'style',
'height: auto; scroll-behavior: auto;'
);
cy.wait(300);
cy.getByTestSubj('centerServiceMap').click();
cy.scrollTo('top');
cy.wait(300);
cy.getByTestSubj('centerServiceMap').click();
cy.wait(300);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Before After
Before After

View file

@ -153,6 +153,12 @@ Cypress.Commands.add('dismissServiceGroupsTour', () => {
);
});
Cypress.Commands.add('withHidden', (selector, callback) => {
cy.get(selector).invoke('attr', 'style', 'display: none');
callback();
cy.get(selector).invoke('attr', 'style', '');
});
// A11y configuration
const axeConfig = {

View file

@ -28,5 +28,6 @@ declare namespace Cypress {
updateAdvancedSettings(settings: Record<string, unknown>): void;
getByTestSubj(selector: string): Chainable<JQuery<Element>>;
dismissServiceGroupsTour(): void;
withHidden(selector: string, callback: () => void): void;
}
}

View file

@ -212,6 +212,7 @@ export function Controls() {
<Panel hasShadow={true} paddingSize="none">
<EuiToolTip anchorClassName="eui-displayInline" content={centerLabel}>
<Button
data-test-subj="centerServiceMap"
aria-label={centerLabel}
color="text"
iconType="crosshairs"