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
56 changes: 56 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 { RunCalibrationStatus } = require('../../../lib/domain/enums/RunCalibrationStatus.js');
const { runService } = require('../../../lib/server/services/run/RunService');
const { resetDatabaseContent } = require('../../utilities/resetDatabaseContent.js');
const { tag: { UpdateTagUseCase } } = require('../../../lib/usecases/index.js');
const { dtos: { UpdateTagDto } } = require('../../../lib/domain/index.js');

Check failure on line 36 in test/public/runs/detail.test.js

View workflow job for this annotation

GitHub Actions / linter

'UpdateTagDto' is assigned a value but never used

const { expect } = chai;

Expand Down Expand Up @@ -527,4 +529,58 @@
innerText: 'CmCvjNbg',
});
});

it('should display correct tag styling after updating in tag overview', async () => {
/**
* Retrieve the badge classes and styles
*
* @return {Promise<Array>} resolves with the badge classes and styles
*/
const getRunTagsBadges = async () => {
// Check if the tag is updated
const tagsBadgeClassesSelector = '#Run-tags .badge';
// Wait for badge elements to appear
await page.waitForSelector(tagsBadgeClassesSelector);
// Evaluate and check for inline background color
return await page.$$eval(
tagsBadgeClassesSelector,
(badges) => badges.map((badge) => ({
className: badge.className,
backgroundColor: badge.style.backgroundColor,
})),
);
};

let badges;
const expectedBgColorBefore = 'badge b1 b-gray-light bg-gray-light';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor point here: you expect class as initial state then the colors. It works, but the test would be more robust if you expect a given color at start and check the new color. To do so, could you have a look at updating the seeders accordingly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const expectedBgColorAfter = 'rgb(255, 0, 0)'; //Red

// Fetch the run data before update of tag
await goToRunDetails(page, 106);

badges = await getRunTagsBadges();

expect(badges[0].className).to.eql(expectedBgColorBefore);

const updateTagDto = {
body: {
color: '#FF0000', //Red
},
params: {
tagId: 1,
},
session: {
personid: 1,
id: 1,
name: 'John Doe',
},
};
await new UpdateTagUseCase()
.execute(updateTagDto);

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

expect(badges[0].backgroundColor == expectedBgColorAfter).to.be.true;
});
};
Loading