Skip to content

Commit e34471c

Browse files
authored
fix(heal): wrong priority (#4394)
1 parent e29bc2d commit e34471c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/heal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ module.exports = heal;
154154
function matchRecipes(recipes, contextName) {
155155
return Object.entries(recipes)
156156
.filter(([, recipe]) => !contextName || !recipe.grep || new RegExp(recipe.grep).test(contextName))
157-
.sort(([, a], [, b]) => b.priority - a.priority)
157+
.sort(([, a], [, b]) => a.priority - b.priority)
158158
.map(([name, recipe]) => {
159159
recipe.name = name;
160160
return recipe;

test/unit/heal_test.js

+26
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,32 @@ describe('heal', () => {
2626
expect(heal.hasCorrespondingRecipes({ name: 'click' })).to.be.true;
2727
});
2828

29+
it('should respect the priority of recipes', async () => {
30+
heal.addRecipe('secondPrior', {
31+
priority: 2,
32+
steps: ['click'],
33+
fn: async () => {
34+
return ({ I }) => {
35+
I.refreshPage();
36+
};
37+
},
38+
});
39+
40+
heal.addRecipe('firstPrior', {
41+
priority: 1,
42+
steps: ['refresh'],
43+
fn: async () => {
44+
return ({ I }) => {
45+
I.refreshPage();
46+
I.refreshPage();
47+
};
48+
},
49+
});
50+
51+
expect((await heal.getCodeSuggestions({}))[0].name).to.equal('firstPrior');
52+
expect((await heal.getCodeSuggestions({}))[1].name).to.equal('secondPrior');
53+
});
54+
2955
it('should have corresponding recipes', () => {
3056
heal.recipes = { test: { steps: ['step1', 'step2'], fn: () => {} } };
3157
heal.contextName = 'TestSuite';

0 commit comments

Comments
 (0)