Skip to content

Commit

Permalink
Adapt e2e tests to the new homepage (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpellerin42 authored Jul 2, 2024
1 parent f3230b7 commit d18efe6
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions cypress/e2e/1-basic/resources.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ACCOUNT, getAuthHeader, goTo, onlyPermanentKb } from '../../support/com

describe('Resources', () => {
ACCOUNT.availableZones.forEach((zone) => {

describe(`on ${zone.slug}`, () => {
before(() => {
onlyPermanentKb();
Expand All @@ -16,51 +15,56 @@ 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));
});
});

// clean up labelsets
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', () => {
Expand Down

0 comments on commit d18efe6

Please sign in to comment.