Skip to content

Commit

Permalink
[3982] Add support for command palette
Browse files Browse the repository at this point in the history
Bug: #3982
Signed-off-by: Stéphane Bégaudeau <[email protected]>
Signed-off-by: Guillaume Coutable <[email protected]>
  • Loading branch information
gcoutable committed Oct 8, 2024
1 parent b456b93 commit a7cad24
Show file tree
Hide file tree
Showing 66 changed files with 3,139 additions and 595 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ jobs:
npx yalc add @eclipse-sirius/sirius-components-formdescriptioneditors
npx yalc add @eclipse-sirius/sirius-components-forms
npx yalc add @eclipse-sirius/sirius-components-gantt
npx yalc add @eclipse-sirius/sirius-components-omnibox
npx yalc add @eclipse-sirius/sirius-components-portals
npx yalc add @eclipse-sirius/sirius-components-widget-reference
npx yalc add @eclipse-sirius/sirius-components-selection
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ The new endpoints are:
description (optional).
** deleteProject (`POST /api/rest/projects/{projectId}`): Delete the project with the given id (projectId).
** updateProject (`PUT /projects/{projectId}`): Update the project with the given id (projectId).
- https://github.com/eclipse-sirius/sirius-web/issues/3982[#3982] [core] Add support for the command palette.
+ The edit project view needs to declare the `OmniboxProvider` to benefit from the command palette.
[source,typescript]
----
const initialContextEntries: OmniboxContextEntry[] = [
{ id: context.project.currentEditingContext.id, label: context.project.name, kind: 'EditingContext' },
];
<OmniboxProvider initialContextEntries={initialContextEntries}>
...
<Workbench
editingContextId={...}
initialRepresentationSelected={...}
onRepresentationSelected={...}
readOnly={...}
/>
</OmniboxProvider>
----

=== Improvements

Expand Down
41 changes: 41 additions & 0 deletions integration-tests/cypress/e2e/project/omnibox.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/

import { Project } from '../../pages/Project';
import { Flow } from '../../usecases/Flow';
import { Explorer } from '../../workbench/Explorer';
import { Omnibox } from '../../workbench/Omnibox';

const projectName = 'Cypress - Omnibox';
describe('Project - Omnibox', () => {
context('Given a Robot flow project', () => {
let projectId: string = '';
beforeEach(() => {
new Flow().createRobotProject(projectName).then((createdProjectData) => {
projectId = createdProjectData.projectId;
new Project().visit(projectId);
});
});

afterEach(() => cy.deleteProject(projectId));

it('Then the omnibox can be display and used to select an element in the workbench', () => {
const explorer = new Explorer();
const omnibox = new Omnibox(projectName);
omnibox.display();
omnibox.sendQuery('').findByTestId('DSP').click();
omnibox.shouldBeClosed();
explorer.getSelectedTreeItems().contains('DSP').should('exist');
});
});
});
50 changes: 50 additions & 0 deletions integration-tests/cypress/workbench/Omnibox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/

export class Omnibox {
constructor(readonly projectName: string) {}

private getOmnibox(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.getByTestId('omnibox');
}

public display(): Cypress.Chainable<JQuery<HTMLElement>> {
cy.getByTestId(`navbar-${this.projectName}`).should('exist');
cy.get('body').type('{ctrl+k}');
cy.getByTestId('omnibox').should('exist');
return this.getOmnibox();
}

public sendQuery(query: string, hasResult: boolean = true): Cypress.Chainable<JQuery<HTMLElement>> {
if (query !== '') {
this.getOmnibox().find('.MuiInputBase-input').type(`${query}`);
}
this.getOmnibox().findByTestId('submit-query-button').should('not.be.disabled');
this.getOmnibox().find('.MuiInputBase-input').type('{enter}');

this.getOmnibox().find('.MuiList-root').findByTestId('fetch-omnibox-result').should('not.exist');
if (hasResult) {
this.getOmnibox().find('.MuiList-root').findByTestId('omnibox-no-result').should('not.exist');
} else {
this.getOmnibox().find('.MuiList-root').findByTestId('omnibox-no-result').should('exist');
}

this.getOmnibox().findByTestId('submit-query-button').should('be.disabled');

return this.getOmnibox().find('.MuiList-root');
}

public shouldBeClosed(): void {
cy.getByTestId('omnibox').should('not.exist');
}
}
Loading

0 comments on commit a7cad24

Please sign in to comment.