From 27b3f63075fe37079dc3063cc4388a6d16264419 Mon Sep 17 00:00:00 2001 From: Jan Vilimek Date: Mon, 26 Sep 2022 12:35:28 +0200 Subject: [PATCH] score-card plugin e2e tests Signed-off-by: Jan Vilimek --- .../integration/plugins/score-card.spec.ts | 83 +++++++++++++++++++ cypress/src/support/commands.ts | 5 ++ cypress/src/types.d.ts | 5 ++ 3 files changed, 93 insertions(+) create mode 100644 cypress/src/integration/plugins/score-card.spec.ts diff --git a/cypress/src/integration/plugins/score-card.spec.ts b/cypress/src/integration/plugins/score-card.spec.ts new file mode 100644 index 0000000000..5871a094e1 --- /dev/null +++ b/cypress/src/integration/plugins/score-card.spec.ts @@ -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. + */ +/// +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

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', + ); + }); + }); +}); diff --git a/cypress/src/support/commands.ts b/cypress/src/support/commands.ts index 02723ffc90..62e21a5bef 100644 --- a/cypress/src/support/commands.ts +++ b/cypress/src/support/commands.ts @@ -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

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'); +}); diff --git a/cypress/src/types.d.ts b/cypress/src/types.d.ts index 181b608a9b..dca22112e9 100644 --- a/cypress/src/types.d.ts +++ b/cypress/src/types.d.ts @@ -77,5 +77,10 @@ declare namespace Cypress { * @example cy.isNotInViewport */ isNotInViewport(element: string): Chainable; + /** + * Check if we have not caused error by our last action + * @example cy.checkForErrors + */ + checkForErrors(): Chainable; } }