score-card plugin e2e tests

Signed-off-by: Jan Vilimek <jvilimek@users.noreply.github.com>
This commit is contained in:
Jan Vilimek
2022-09-26 12:35:28 +02:00
parent 1d3d575132
commit 27b3f63075
3 changed files with 93 additions and 0 deletions
@@ -0,0 +1,83 @@
/*
* Copyright 2021 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types="cypress" />
import 'os';
describe('score-card', () => {
describe('Score board', () => {
it('displays the score board based on sample data', () => {
cy.loginAsGuest();
cy.visit('/score-board');
cy.screenshot({ capture: 'viewport' });
cy.contains('System scores overview').should('be.visible');
cy.checkForErrors();
cy.get('span:contains("1-2 of 2")').should('be.visible'); // beware, there is also a hidden <P/> element
cy.contains('audio-playback').should('be.visible');
cy.contains('team-c').should('be.visible');
cy.contains('non-valid-system').should('be.visible');
cy.contains('Name').should('be.visible');
cy.contains('Date').should('be.visible');
cy.contains('Code').should('be.visible');
cy.contains('Documentation').should('be.visible');
cy.contains('Operations').should('be.visible');
cy.contains('Quality').should('be.visible');
cy.contains('Security').should('be.visible');
cy.contains('Total').should('be.visible');
cy.contains('50 %').should('be.visible');
cy.contains('75 %').should('be.visible');
cy.log('navigating to score card detail for audio-playback');
cy.get('a[data-id="audio-playback"]').should('be.visible').click();
cy.screenshot({ capture: 'viewport' });
cy.url().should(
'include',
'/catalog/default/System/audio-playback/score',
);
cy.contains('Scoring').should('be.visible');
cy.contains('Total score: 57 %').should('be.visible');
cy.contains('Code').should('be.visible');
cy.contains('90 %').should('be.visible');
cy.contains('Documentation').should('be.visible');
cy.contains('75 %').should('be.visible');
cy.contains('Operations').should('be.visible');
cy.contains('50 %').should('be.visible');
cy.contains('Quality').should('be.visible');
cy.contains('25 %').should('be.visible');
cy.contains('Security');
cy.contains('10 %').should('be.visible');
cy.checkForErrors();
cy.log(
'Clicking on button [>] that is first child of the element (td) with value=Code',
);
cy.get('[value="Code"] > button:first-child').click();
cy.checkForErrors();
cy.screenshot({ capture: 'viewport' });
cy.log('Clicking on link for Code');
cy.contains('hints: Gitflow: 100%').should('be.visible');
cy.get('a[data-id="2157"]')
.should('be.visible')
.should(
'have.attr',
'href',
'https://TBD/XXX/_wiki/wikis/XXX.wiki/2157',
);
});
});
});
+5
View File
@@ -118,3 +118,8 @@ Cypress.Commands.add('waitSectionTwoPage', () => {
Cypress.Commands.add('waitHomePage', () => {
cy.wait(['@entityMetadata', '@syncEntity', '@techdocsMetadata', '@homeHTML']);
});
Cypress.Commands.add('checkForErrors', () => {
// when an error occurs there is a <div> with an "alert" role attribute. This can change ofc => we shall add also some positive ("when error occurs") test
cy.get('div[role="alert"]').should('not.exist');
});
+5
View File
@@ -77,5 +77,10 @@ declare namespace Cypress {
* @example cy.isNotInViewport
*/
isNotInViewport(element: string): Chainable<Element>;
/**
* Check if we have not caused error by our last action
* @example cy.checkForErrors
*/
checkForErrors(): Chainable<Element>;
}
}