From d18efe6652a5927d63603eeafb52f0d7293c4d73 Mon Sep 17 00:00:00 2001 From: Mat Pellerin Date: Tue, 2 Jul 2024 12:39:14 +0200 Subject: [PATCH] Adapt e2e tests to the new homepage (#97) --- cypress/e2e/1-basic/resources.cy.js | 48 ++++++++++++++++------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/cypress/e2e/1-basic/resources.cy.js b/cypress/e2e/1-basic/resources.cy.js index b34d099..4670c57 100644 --- a/cypress/e2e/1-basic/resources.cy.js +++ b/cypress/e2e/1-basic/resources.cy.js @@ -4,7 +4,6 @@ import { ACCOUNT, getAuthHeader, goTo, onlyPermanentKb } from '../../support/com describe('Resources', () => { ACCOUNT.availableZones.forEach((zone) => { - describe(`on ${zone.slug}`, () => { before(() => { onlyPermanentKb(); @@ -16,24 +15,27 @@ describe('Resources', () => { cy.request({ method: 'GET', url: `${endpoint}/resources`, - headers: authHeader - }).then(response => { + headers: authHeader, + }).then((response) => { expect(response.status).to.eq(200); - response.body['resources'].forEach(resource => { + response.body['resources'].forEach((resource) => { cy.request({ method: 'PATCH', url: `${endpoint}/resource/${resource.id}`, body: { usermetadata: { - classifications: [{ - labelset: 'dataset', - label: 'permanent', - cancelled_by_user: false - }], relations: [] - } + classifications: [ + { + labelset: 'dataset', + label: 'permanent', + cancelled_by_user: false, + }, + ], + relations: [], + }, }, - headers: authHeader - }).then(patchResponse => expect(patchResponse.status).to.eq(200)); + headers: authHeader, + }).then((patchResponse) => expect(patchResponse.status).to.eq(200)); }); }); @@ -41,26 +43,28 @@ describe('Resources', () => { cy.request({ method: 'GET', url: `${endpoint}/labelsets`, - headers: authHeader - }).then(response => { + headers: authHeader, + }).then((response) => { expect(response.status).to.eq(200); const labelsets = Object.keys(response.body['labelsets']); if (labelsets.length > 1) { cy.task('log', `Delete ${labelsets.length - 1} label sets from previous tests`); - labelsets.filter(labelset => labelset !== 'dataset').forEach(labelset => { - cy.request({ - method: 'DELETE', - url: `${endpoint}/labelset/${labelset}`, - headers: authHeader - }).then(deleteResponse => expect(deleteResponse.status).to.eq(200)); - }); + labelsets + .filter((labelset) => labelset !== 'dataset') + .forEach((labelset) => { + cy.request({ + method: 'DELETE', + url: `${endpoint}/labelset/${labelset}`, + headers: authHeader, + }).then((deleteResponse) => expect(deleteResponse.status).to.eq(200)); + }); } }); }); it('should display status', () => { cy.login(zone); - cy.get('.kb-metrics .title-m:first-of-type').should('contain', '2'); + cy.get('[data-cy="total-resources"]').should('contain', '2'); }); describe('Resources list', () => {