Skip to content

Conversation

@ihexxa
Copy link
Contributor

@ihexxa ihexxa commented Sep 27, 2024

Background

We plan to move forward without settings persistence temporarily and will bring back it later.

Changes

  • Temporarily disable the settings persistence
  • Fixed the running request order
  • Fixed incorrect test status font color
  • Fixed workflow redirection with setNextRequest
  • RequestRow should not be an array

Ref: INS-4452

@ihexxa ihexxa self-assigned this Sep 27, 2024
@ihexxa ihexxa changed the title fix(runner): disable settings persistence temporarily and run request with correct order fix(runner): disable settings persistence temporarily and some fixes Sep 27, 2024
const matchName = targetRequest.name.trim() === nextRequestIdOrName.trim();
// find the last request with matched name in case multiple requests with same name in collection runner
const matchLastIndex = j === requests.slice().reverse().findIndex(req => req.name.trim() === nextRequestIdOrName.trim());
const matchLastIndex = j === _.findLastIndex(requests, req => req.name.trim() === nextRequestIdOrName.trim());
Copy link
Contributor

Choose a reason for hiding this comment

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

We aim to avoid the use of lodash for these operations. Was the previous function not working as intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the previous function changes the pre previous behavior, the card contains more info, and linter complains of findlastindex. May i know why do we avoid lodash?

Copy link
Contributor

Choose a reason for hiding this comment

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

Some reasons to avoid lodash:

  • Most of it is not helpful and replaced by latest JS features
  • Increases bundle size and makes us dependent on it. (In our case we include it for the pre/post scripts but shouldn't use it in the project)
  • More things we need to learn in order to figure out how something works.

I'd suggest using the platform Array.findLastIndex and use a @ts-expect-error for it.

Suggested change
const matchLastIndex = j === _.findLastIndex(requests, req => req.name.trim() === nextRequestIdOrName.trim());
// @ts-expect-error - Needs upgrade to latest typescript
const matchLastIndex = j === requests.findLastIndex(req => req.name.trim() === nextRequestIdOrName.trim());

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@ihexxa ihexxa Sep 29, 2024

Choose a reason for hiding this comment

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

I have to say that my thought is a bit different: 🫤 :

  • lodash is a dependency of many modules, so it seems infeasible to totally exclude it from the bundle as it could be indirect dependency.
  • It also take time to learn the builtin approach, but I agree that a small part of lodash functions are not intuitive
  • And this repo (18.7 stars) and lodash with 59.7 stars.

But im fine to go with the builtin approach as you mentioned more js features come into play.

const [runnerAdvancedSettings, setAdvancedRunnerSettings] = useState<RunnerAdvancedSettings>(tempRunnerSettings.advanced);
const [isRunning, setIsRunning] = useState(false);

invariant(iterationCount, 'iterationCount should not be null');
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is inside the render function what happens in the error case? If the iteration count can't be null maybe we should describe it better in the type instead of an invariant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently the component checks this and rejects invalid values, include null. Agreed with that the invariant should be removed also.

@jackkav jackkav force-pushed the fix/disable-runner-cfg-persist branch from 53f4c85 to eaaa8ee Compare September 27, 2024 13:00
jackkav
jackkav previously approved these changes Sep 27, 2024
@jackkav jackkav merged commit 6188f07 into develop Sep 27, 2024
@jackkav jackkav deleted the fix/disable-runner-cfg-persist branch September 27, 2024 13:21
const matchName = targetRequest.name.trim() === nextRequestIdOrName.trim();
// find the last request with matched name in case multiple requests with same name in collection runner
const matchLastIndex = j === _.findLastIndex(requests, req => req.name.trim() === nextRequestIdOrName.trim());
const matchLastIndex = j === requests.slice().reverse().findIndex(req => req.name.trim() === nextRequestIdOrName.trim());
Copy link
Contributor Author

@ihexxa ihexxa Sep 29, 2024

Choose a reason for hiding this comment

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

@jackkav This is a bug fix (not style improvement) we should not revert it.
That's why I propose leaving a comment instead editing it in place, as the last setting persistence change has significantly introduced some issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants