forked from eclipse-sirius/sirius-web
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1588] Add support to stop revealing the selection in the explorer
Bug: eclipse-sirius#1588 Signed-off-by: Michaël Charfadi <michael.charfadi@obeosoft.com>
- Loading branch information
1 parent
f5417c8
commit 8337e69
Showing
18 changed files
with
496 additions
and
140 deletions.
There are no files selected for viewing
This file contains 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
119 changes: 119 additions & 0 deletions
119
integration-tests/cypress/integration/project/edit/explorer-toolbar_spec.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the erms 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 | ||
*******************************************************************************/ | ||
describe('/projects/:projectId/edit - Tree toolbar', () => { | ||
beforeEach(() => { | ||
cy.deleteAllProjects(); | ||
cy.createProject('Cypress Project').then((res) => { | ||
const projectId = res.body.data.createProject.project.id; | ||
const robot_flow_id = 'c26b6086-b444-3ee6-b8cd-9a4fde5956a7'; | ||
cy.createDocument(projectId, robot_flow_id, 'flow').then(() => { | ||
cy.visit(`/projects/${projectId}/edit`); | ||
}); | ||
}); | ||
|
||
cy.getByTestId('flow').dblclick(); | ||
cy.getByTestId('Robot').dblclick(); | ||
cy.getByTestId('Robot-more').click(); | ||
cy.getByTestId('treeitem-contextmenu').findByTestId('new-representation').click(); | ||
|
||
cy.getByTestId('name').clear(); | ||
cy.getByTestId('name').type('Topography'); | ||
cy.getByTestId('representationDescription').click(); | ||
cy.getByTestId('Topography with auto layout').click(); | ||
cy.getByTestId('create-representation').click(); | ||
cy.getByTestId('Topography').click(); | ||
}); | ||
|
||
it('Deactivate the synchronisation mode does not reveal the semantic element selected on a diagram but activating it will', () => { | ||
// 1. Deactivate the synchronisation mode | ||
cy.getByTestId('tree-synchronise').click(); | ||
|
||
// 2. On the diagram, click on the 'CaptureSubSystem' | ||
cy.getByTestId('CaptureSubSystem').should('exist'); | ||
cy.getByTestId('Label - CaptureSubSystem').click(); | ||
|
||
// 3. CHECK that the 'CaptureSubSystem' node is visible and selected in the explorer | ||
cy.getByTestId('selected').contains('CaptureSubSystem'); | ||
|
||
// 4. On the diagram, click on the 'DSP' | ||
cy.getByTestId('DSP').should('not.exist'); | ||
cy.getByTestId('Label - DSP').click(); | ||
|
||
// 5. CHECK that the 'DSP' node is not visible and not selected in the explorer | ||
cy.getByTestId('DSP').should('not.exist'); | ||
cy.getByTestId('selected').should('not.exist'); | ||
|
||
// 6. Activate the synchronisation mode | ||
cy.getByTestId('tree-synchronise').click(); | ||
|
||
// 5. CHECK that the 'GPU' node is visible and selected | ||
cy.getByTestId('DSP').should('exist'); | ||
cy.getByTestId('selected').findByTestId('DSP').should('exist'); | ||
}); | ||
|
||
it('can open the new model modal', () => { | ||
cy.getByTestId('new-model').click(); | ||
|
||
cy.get('.MuiDialog-container').should('be.visible'); | ||
cy.getByTestId('navbar-contextmenu').should('not.exist'); | ||
|
||
cy.getByTestId('name').type('{esc}'); | ||
cy.get('.MuiDialog-container').should('not.exist'); | ||
}); | ||
|
||
it('requires a name to create a new model', () => { | ||
cy.getByTestId('new-model').click(); | ||
cy.getByTestId('create-document').should('be.disabled'); | ||
}); | ||
|
||
it('can create a new document by clicking on the create button', () => { | ||
cy.getByTestId('new-model').click(); | ||
|
||
cy.getByTestId('name-input').should('be.enabled'); | ||
cy.getByTestId('name').type('nobel'); | ||
|
||
cy.getByTestId('create-document').should('be.enabled'); | ||
cy.getByTestId('create-document').click(); | ||
|
||
cy.get('.MuiDialog-container').should('not.exist'); | ||
cy.getByTestId('explorer').contains('nobel'); | ||
}); | ||
|
||
it('can open the upload document modal', () => { | ||
cy.getByTestId('upload-document').click(); | ||
|
||
cy.get('.MuiDialog-container').should('be.visible'); | ||
|
||
cy.get('.MuiDialog-container').type('{esc}'); | ||
cy.get('.MuiDialog-container').should('not.exist'); | ||
}); | ||
}); | ||
|
||
//The upload function doesn't exist anymore. | ||
it.skip('can upload an existing document', () => { | ||
cy.getByTestId('upload-document').click(); | ||
|
||
cy.fixture('Robot.xmi').then((fileContent) => { | ||
cy.getByTestId('file').upload({ | ||
fileContent, | ||
fileName: 'robot', | ||
mimeType: 'text/xml', | ||
encoding: 'utf8', | ||
}); | ||
|
||
cy.getByTestId('upload-document').click(); | ||
|
||
cy.get('.MuiDialog-container').should('not.exist'); | ||
cy.getByTestId('explorer').contains('robot'); | ||
}); | ||
}); |
This file contains 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
This file contains 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
This file contains 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
54 changes: 54 additions & 0 deletions
54
packages/trees/frontend/sirius-components-trees/src/common/sendFile.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019, 2023 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 const sendFile = async (httpOrigin: string, query: string, variables: any, file: File) => { | ||
const operations = { | ||
query, | ||
variables, | ||
}; | ||
|
||
const formData = new FormData(); | ||
formData.append('operations', JSON.stringify(operations)); | ||
formData.append('map', JSON.stringify({ '0': 'variables.file' })); | ||
formData.append('0', file); | ||
|
||
const csrfToken = getCookie('XSRF-TOKEN'); | ||
|
||
const response = await fetch(`${httpOrigin}/api/graphql/upload`, { | ||
method: 'POST', | ||
body: formData, | ||
credentials: 'include', | ||
mode: 'cors', | ||
headers: { | ||
'X-XSRF-TOKEN': csrfToken, | ||
}, | ||
}); | ||
|
||
return await response.json(); | ||
}; | ||
|
||
const getCookie = (name: string): string => { | ||
let cookieValue: string = null; | ||
if (document.cookie && document.cookie !== '') { | ||
const cookies = document.cookie.split(';'); | ||
for (let i = 0; i < cookies.length; i++) { | ||
const cookie = cookies[i].trim(); | ||
// Does this cookie string begin with the name we want? | ||
if (cookie.substring(0, name.length + 1) === name + '=') { | ||
cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); | ||
break; | ||
} | ||
} | ||
} | ||
return cookieValue; | ||
}; |
Oops, something went wrong.