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

fix(editor): Enable pinning main output with error and always allow unpinning #11452

Merged

Conversation

CharlieKolb
Copy link
Contributor

@CharlieKolb CharlieKolb commented Oct 29, 2024

Summary

Allow pinning the main output even if we have an error branch from the OnError setting.

Also always allow unpinning existing pinned data.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/ADO-2343/community-issue-cant-unpin-output-in-http-module
#10066
#10240

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@n8n-assistant n8n-assistant bot added n8n team Authored by the n8n team ui Enhancement in /editor-ui or /design-system labels Oct 29, 2024
@CharlieKolb CharlieKolb changed the title bug(editor): Enable pinning main output with error and always allow unpinning fix(editor): Enable pinning main output with error and always allow unpinning Oct 29, 2024
@CharlieKolb CharlieKolb marked this pull request as ready for review October 31, 2024 10:47
@@ -288,6 +288,11 @@ export default defineComponent({
return false;
}

if (this.outputIndex !== 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be more safe here to check the type instead of the output index? Because, for example, if the UX changes and suddenly error output is on top, this would be wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed this assumption is a bit wacky. It's rooted in the explicit effort elsewhere in the code to add the error path after node specific outputs, but it might not hold long-term.

So it turns out we actually don't need this check here, as this line

if (!this.rawInputData.length && !this.pinnedData.hasData.value) {
has !this.rawInputData.length, which causes us to return early for errors.
I don't fully understand this, does this happen to align, or can we rely on this semantically?

I can still add the check, though I'd move it to canPinNode by adding an index parameter if that works for you.

packages/editor-ui/src/composables/usePinnedData.ts Outdated Show resolved Hide resolved
@@ -133,4 +141,71 @@ describe('usePinnedData', () => {
expect(spy).toHaveBeenCalled();
});
});

describe('canPinData()', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding Unit tests. Would it also be useful to add some e2e tests as well for this bug?

Copy link
Contributor Author

@CharlieKolb CharlieKolb Nov 5, 2024

Choose a reason for hiding this comment

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

Especially if we now drop the condition in the vue file or move it to the composable this unit test should now have us fully covered.

I'm a bit unclear still on when to add e2e tests, I understand we're looking to move away from them "by default" and that there is a real cost associated?

Copy link
Contributor

@mutdmour mutdmour Nov 5, 2024

Choose a reason for hiding this comment

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

there's no rule. My general rule is if the bug depends on the interaction of multiple modules, then better to have an e2e test for it.

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

const output = outputs[outputIndex];

if (outputs[outputIndex] === undefined)
throw new Error(`Out of bounds index ${outputIndex} provided to canPinNode`);
Copy link
Contributor

Choose a reason for hiding this comment

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

This could brick the UI. So might be better to have a sensible default rather than break UI.

For example adding a node with no outputs.
Screenshot 2024-11-05 at 16 25 16

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh nice catch, I had assumed we always have an output.

Copy link
Contributor

github-actions bot commented Nov 6, 2024

✅ All Cypress E2E specs passed

Copy link

cypress bot commented Nov 6, 2024

n8n    Run #7738

Run Properties:  status check passed Passed #7738  •  git commit 4db633a2ec: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 CharlieKolb 🗃️ e2e/*
Project n8n
Branch Review ADO-2343/community-issue-cant-unpin-output-in-http-module
Run status status check passed Passed #7738
Run duration 04m 28s
Commit git commit 4db633a2ec: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 CharlieKolb 🗃️ e2e/*
Committer Charlie Kolb
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 461
View all changes introduced in this branch ↗︎

@CharlieKolb CharlieKolb merged commit 40c8882 into master Nov 7, 2024
33 checks passed
@CharlieKolb CharlieKolb deleted the ADO-2343/community-issue-cant-unpin-output-in-http-module branch November 7, 2024 07:32
OlegIvaniv pushed a commit that referenced this pull request Nov 12, 2024
@github-actions github-actions bot mentioned this pull request Nov 13, 2024
@janober
Copy link
Member

janober commented Nov 13, 2024

Got released with [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team Released ui Enhancement in /editor-ui or /design-system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants