Add 'Revert All Selection' feature #68
This commit introduces 'Revert: None - Selected' toggle, enabling users to revert all reversible scripts with a single action, improving user safety and control over script effects. This feature addresses user-reported concerns about the ease of reverting script changes. This feature should enhance the user experience by streamlining the revert process along with providing essential information about script reversibility. Key changes: - Add buttons to revert all selected scripts or setting all selected scripts to non-revert state. - Add tooltips with detailed explanations about consequences of modifying revert states, includinginformation about irreversible script changes. Supporting changes: - Align items on top menu vertically for better visual consistency. - Rename `SelectionType` to `RecommendationStatusType` for more clarity. - Rename `IReverter` to `Reverter` to move away from `I` prefix convention. - The `.script` CSS class was duplicated in `TheScriptsView.vue` and `TheScriptsArea.vue`, leading to style collisions in the development environment. The class has been renamed to component-specific classes to avoid such issues in the future.
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import RatingCircle from '@/presentation/components/Scripts/Menu/Recommendation/Rating/RatingCircle.vue';
|
||||
import CircleRating from '@/presentation/components/Scripts/Menu/Recommendation/Rating/CircleRating.vue';
|
||||
|
||||
const MAX_RATING = 4;
|
||||
|
||||
describe('CircleRating.vue', () => {
|
||||
describe('number of RatingCircle components', () => {
|
||||
it('renders correct number of RatingCircle components based on maxRating', () => {
|
||||
// arrange
|
||||
const expectedMaxRating = MAX_RATING;
|
||||
const currentRating = MAX_RATING - 1;
|
||||
|
||||
// act
|
||||
const wrapper = shallowMount(CircleRating, {
|
||||
propsData: {
|
||||
rating: currentRating,
|
||||
},
|
||||
});
|
||||
|
||||
// assert
|
||||
const ratingCircles = wrapper.findAllComponents(RatingCircle);
|
||||
expect(ratingCircles.length).to.equal(expectedMaxRating);
|
||||
});
|
||||
it('renders the correct number of RatingCircle components for default rating', () => {
|
||||
// arrange
|
||||
const expectedMaxRating = MAX_RATING;
|
||||
|
||||
// act
|
||||
const wrapper = shallowMount(CircleRating);
|
||||
|
||||
// assert
|
||||
const ratingCircles = wrapper.findAllComponents(RatingCircle);
|
||||
expect(ratingCircles.length).to.equal(expectedMaxRating);
|
||||
});
|
||||
});
|
||||
|
||||
describe('rating logic', () => {
|
||||
it('fills the correct number of RatingCircle components based on the provided rating', () => {
|
||||
// arrange
|
||||
const expectedTotalComponents = 3;
|
||||
|
||||
// act
|
||||
const wrapper = shallowMount(CircleRating, {
|
||||
propsData: {
|
||||
rating: expectedTotalComponents,
|
||||
},
|
||||
});
|
||||
|
||||
// assert
|
||||
const filledCircles = wrapper.findAllComponents(RatingCircle).filter((w) => w.props().filled);
|
||||
expect(filledCircles.length).to.equal(expectedTotalComponents);
|
||||
});
|
||||
|
||||
describe('validates rating correctly', () => {
|
||||
const testCases = [
|
||||
{
|
||||
value: -1,
|
||||
expectedValidationResult: false,
|
||||
},
|
||||
{
|
||||
value: 0,
|
||||
expectedValidationResult: true,
|
||||
},
|
||||
{
|
||||
value: MAX_RATING - 1,
|
||||
expectedValidationResult: true,
|
||||
},
|
||||
{
|
||||
value: MAX_RATING,
|
||||
expectedValidationResult: true,
|
||||
},
|
||||
];
|
||||
testCases.forEach((testCase) => {
|
||||
it(`given ${testCase.value} return ${testCase.expectedValidationResult ? 'true' : 'false'}`, () => {
|
||||
// arrange
|
||||
const { validator } = CircleRating.props.rating;
|
||||
|
||||
// act
|
||||
const actualValidationResult = validator(testCase.value);
|
||||
|
||||
// act
|
||||
expect(actualValidationResult).to.equal(testCase.expectedValidationResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user