Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[O2B-1139] Refresh tags list when a tag is updated/created #1805

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
14 changes: 6 additions & 8 deletions lib/public/views/Runs/Details/RunDetailsModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,16 @@
async clearAndLoad({ runNumber = null, runId = null, panelKey = null }) {
this.tabbedPanelModel.currentPanelKey = panelKey;
this._updateErrors = [];
this._runDetails = RemoteData.notAsked();
this._eorReasonTypes = RemoteData.notAsked();

Check warning on line 69 in lib/public/views/Runs/Details/RunDetailsModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Details/RunDetailsModel.js#L68-L69

Added lines #L68 - L69 were not covered by tests

if (this._runNumber !== runNumber || this._runId !== runId) {
this.clearAllEditors();
this._runNumber = runNumber;
this._runId = runId;

this._runDetails = RemoteData.notAsked();
this._eorReasonTypes = RemoteData.notAsked();

this._fetchOneRun();
this._fetchReasonTypes();
}
this._runId = runId;
this._runNumber = runNumber;
this._fetchReasonTypes();
this._fetchOneRun();

Check warning on line 77 in lib/public/views/Runs/Details/RunDetailsModel.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/Details/RunDetailsModel.js#L74-L77

Added lines #L74 - L77 were not covered by tests
}

/**
Expand Down
51 changes: 51 additions & 0 deletions test/public/runs/detail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const {
const { RunCalibrationStatus } = require('../../../lib/domain/enums/RunCalibrationStatus.js');
const { runService } = require('../../../lib/server/services/run/RunService');
const { resetDatabaseContent } = require('../../utilities/resetDatabaseContent.js');
const request = require('supertest');
const { server } = require('../../../lib/application');

const { expect } = chai;

Expand Down Expand Up @@ -64,6 +66,30 @@ module.exports = () => {
let url;
let createdRunId;

/**
* Retrieve the badge classes and styles
*
* @return {Promise<void>} A promise that resolves when the badge classes and styles are retrieved
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
*/
const getBadges = async () => {
// Check if the tag is updated
const tagsBadgeClassesSelector = '#Run-tags .badge';
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
// Wait for badge elements to appear
await page.waitForSelector(tagsBadgeClassesSelector);

// Evaluate and check for inline background color
const badgesWithStyles = await page.$$eval(
tagsBadgeClassesSelector,
(badges) => badges.map((badge) => ({
martinboulais marked this conversation as resolved.
Show resolved Hide resolved
index: badges.indexOf(badge),
className: badge.className,
backgroundColor: badge.style.backgroundColor,
})),
);

return badgesWithStyles;
};

before(async () => {
[page, browser, url] = await defaultBefore(page, browser);
await page.setViewport({
Expand Down Expand Up @@ -527,4 +553,29 @@ module.exports = () => {
innerText: 'CmCvjNbg',
});
});

it('should display correct tag styling after updating in tag overview', async () => {
let badges;
// Fetch the run data before update of tag
await goToRunDetails(page, 106);

badges = await getBadges();

expect(badges[0].backgroundColor === 'rgb(255, 0, 0)').to.be.false;
martinboulais marked this conversation as resolved.
Show resolved Hide resolved

const updatedTag = {
color: '#ff0000', // Red color
};

// Update the tag via API request
await request(server)
.put('/api/tags/1?token=admin')
.send(updatedTag)
.expect(201);
martinboulais marked this conversation as resolved.
Show resolved Hide resolved

await goToRunDetails(page, 106);
badges = await getBadges();

expect(badges[0].backgroundColor == 'rgb(255, 0, 0)').to.be.true;
});
};
Loading