Repository navigation
Fix duplicate missing packages badge - #16555
Merged
Merged
Conversation
|
E2E Tests 🚀 Why these tags?
More on automatic tags from changed files. |
Contributor
|
Thanks for adding a test for this, and for tracing the cause. Since the bug was just the script badge's /// <reference types="vitest/globals" />
import { MenuId } from '../../../../../platform/actions/common/actions.js';
import { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js';
import { PositronActionBarWidgetRegistry } from '../../../../../platform/positronActionBar/browser/positronActionBarWidgetRegistry.js';
import { stubInterface } from '../../../../../test/vitest/stubInterface.js';
import { POSITRON_NOTEBOOK_EDITOR_ID } from '../../../positronNotebook/common/positronNotebookCommon.js';
import { MISSING_PACKAGES_SUPPORTED_KEY } from '../../browser/missingPackagesContextKey.js';
// Registers the badge widgets as a side effect.
import '../../browser/positronMissingPackages.contribution.js';
function badgesFor(activeEditor: string): string[] {
const values: Record<string, unknown> = {
activeEditor,
[MISSING_PACKAGES_SUPPORTED_KEY.key]: true,
};
const contextKeyService = stubInterface<IContextKeyService>({
contextMatchesRules: rules => !rules || rules.evaluate({ getValue: <T>(key: string) => values[key] as T }),
});
return PositronActionBarWidgetRegistry.getWidgets(MenuId.EditorActionsRight, contextKeyService)
.map(w => w.id)
.filter(id => id.startsWith('positronMissingPackages.'));
}
describe('missing packages badge registration', () => {
it('shows only the notebook badge in a Positron notebook', () => {
expect(badgesFor(POSITRON_NOTEBOOK_EDITOR_ID)).toEqual(['positronMissingPackages.notebookBadge']);
});
it('shows only the editor badge in a text editor', () => {
expect(badgesFor('workbench.editors.files.textFileEditor')).toEqual(['positronMissingPackages.editorBadge']);
});
});The second case also covers your validation step 4, that scripts still get their badge. Not a blocker, just a suggestion. Let me know what you think! |
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #16311
Positron notebooks showed the "missing packages" badge twice in the toolbar. There are two badges registered on the same toolbar menu: one for scripts and one for notebooks. The script badge did not exclude notebooks, and the notebook toolbar renders that same menu, so both appeared. The script badge is now hidden when the active editor is a Positron notebook, so notebooks show only their own badge.
This also adds an e2e test that opens a notebook that imports a missing package, switches to another tab and back, and checks that exactly one badge is shown.
Release Notes
New Features
Bug Fixes
Validation Steps
@:packages-pane @:positron-notebooks
import cowsay).