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

Feature: open plugin components by default #233

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Integrate syntax colorization.
* Modelization feature:
* Allow to use the mouse coordinates when placing new component on drag and drop feature.
* The components list is now open by default.
* Add new environment variable `KEEP_CYPRESS_ATTRIBUTE` to keep all cypress attribute in html.

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ Feature: Test modelizer draw view: add plugin component
Then I expect current url is 'projectName/modelizer/draw\?path=terrator-plugin/modelName'
And I expect '[data-cy="component-definitions-item_terrator-plugin"]' appear 1 time on screen
And I expect '[data-cy="component-definitions-item_terrator-plugin"] [data-cy="title"]' is 'terrator-plugin'

# Select 'terrator-plugin' library
When I click on '[data-cy="component-definitions-item_terrator-plugin"]'
And I wait 1 second
Then I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
And I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
And I expect '[data-cy="component-definition-grid"]' exists
And I expect '[data-cy="component-definition-grid"] [class*="component-definition-card"]' appear 18 times on screen
And I wait 1 second

Scenario Outline: Click on the <element> component should display it on the page
Then I expect '[data-cy="modelizer-draw-view"] [data-cy="draw-container"] [id^="<element>"]' not exists
Expand Down Expand Up @@ -56,7 +53,7 @@ Feature: Test modelizer draw view: add plugin component
| aws_key_pair |

@skip
# TODO: update/fix test
# TODO: update/fix test
Scenario Outline: Dragging the <element> component should display it on the page
Then I expect '[data-cy="modelizer-draw-view"] [data-cy="draw-container"] [id^="<element>_"]' not exists

Expand Down
14 changes: 5 additions & 9 deletions cypress/e2e/ModelizerPage/DrawView/plugin/filter.plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Feature: Test modelizer draw view: plugin filter
| volume |
| subnet |
| route53 |

Scenario Outline: Set text as '<filter>' should not display plugin.
When I set on '[data-cy="definitions-filter-input"]' text '<filter>'
Then I expect '[data-cy="component-definitions-item_terrator-plugin"]' appear 0 time on screen
Expand All @@ -70,8 +70,7 @@ Feature: Test modelizer draw view: plugin filter

Scenario Outline: Select plugin and set text as '<filter>' should display only one element
# Select 'terrator-plugin' library
When I click on '[data-cy="component-definitions-item_terrator-plugin"]'
And I wait 1 second
When I wait 1 second
Then I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
And I expect '[data-cy="component-definition-grid"]' exists
And I expect '[data-cy="component-definition-grid"] [class*="component-definition-card"]' appear 18 times on screen
Expand Down Expand Up @@ -101,8 +100,7 @@ Feature: Test modelizer draw view: plugin filter

Scenario Outline: Select plugin and set text as '<filter>' should display only two elements
# Select 'terrator-plugin' library
When I click on '[data-cy="component-definitions-item_terrator-plugin"]'
And I wait 1 second
When I wait 1 second
Then I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
And I expect '[data-cy="component-definition-grid"]' exists
And I expect '[data-cy="component-definition-grid"] [class*="component-definition-card"]' appear 18 times on screen
Expand All @@ -125,8 +123,7 @@ Feature: Test modelizer draw view: plugin filter

Scenario Outline: Select plugin and set text as '<filter>' should not display any elements.
# Select 'terrator-plugin' library
When I click on '[data-cy="component-definitions-item_terrator-plugin"]'
And I wait 1 second
When I wait 1 second
Then I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
And I expect '[data-cy="component-definition-grid"]' exists
And I expect '[data-cy="component-definition-grid"] [class*="component-definition-card"]' appear 18 times on screen
Expand All @@ -147,8 +144,7 @@ Feature: Test modelizer draw view: plugin filter
And I expect '[data-cy="component-definitions-item_terrator-plugin"] [data-cy="title"]' is 'terrator-plugin (1)'

# Select 'terrator-plugin' library
When I click on '[data-cy="component-definitions-item_terrator-plugin"]'
And I wait 1 second
When I wait 1 second
Then I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
And I expect '[data-cy="component-definitions-item_terrator-plugin"].selected [data-cy="title"]' is 'terrator-plugin (1)'
And I expect '[data-cy="component-definition-grid"]' exists
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/ModelizerPage/DrawView/plugin/init.plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Feature: Test modelizer draw view: plugin initialization
When I set on '[data-cy="create-model-form"] [data-cy="name-input"]' text 'modelName'
And I click on '[data-cy="create-model-form"] [data-cy="submit-button"]'
Then I expect current url is 'projectName/modelizer/draw\?path=terrator-plugin/modelName'
And I wait 1 second

Scenario: Terrator plugin should appear in component definitions list
Then I expect '[data-cy="component-definitions-item_terrator-plugin"]' exists
And I expect '[data-cy="component-definitions-item_terrator-plugin"] [data-cy="title"]' is 'terrator-plugin'

Scenario: Should have only one plugin installed with all these definitions
When I click on '[data-cy="component-definitions-item_terrator-plugin"]'
Scenario Outline: Should have only one plugin installed with all these definitions
Then I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
And I expect '[data-cy="component-definitions-item_terrator-plugin"].selected [data-cy="title"]' is 'terrator-plugin (18)'
And I expect '[data-cy="component-definition-grid"] [class*="component-definition-card"]' appear 18 times on screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ Feature: Test modelizer draw view: add template component
When I set on '[data-cy="create-model-form"] [data-cy="name-input"]' text 'modelName'
And I click on '[data-cy="create-model-form"] [data-cy="submit-button"]'
Then I expect current url is 'projectName/modelizer/draw\?path=terrator-plugin/modelName'
And I expect '[data-cy="component-definitions-item_Templates"]' appear 1 time on screen
And I expect '[data-cy="component-definitions-item_Templates"] [data-cy="title"]' is 'Templates'

# Select 'Templates' library
When I click on '[data-cy="component-definitions-item_terrator-plugin"]'
And I wait 1 second
Then I expect '[data-cy="component-definitions-item_Templates"]' appear 1 time on screen
And I expect '[data-cy="component-definitions-item_Templates"] [data-cy="title"]' is 'Templates'

When I click on '[data-cy="component-definitions-item_Templates"]'
And I wait 1 second
Then I expect '[data-cy="component-definitions-item_Templates"].selected' exists
And I expect '[data-cy="component-definition-grid"]' exists
And I expect '[data-cy="component-definition-grid"] [class*="component-definition-card"]' appear 2 times on screen

Scenario Outline: Click on the Test application component should display it on the page
Scenario: Click on the Test application component should display it on the page
Then I expect '[data-cy="modelizer-draw-view"] [data-cy="draw-container"] [id^="SecurityGroup_"]' not exists
And I expect '[data-cy="modelizer-draw-view"] [data-cy="draw-container"] [id^="InternetGateway_"]' not exists
And I expect '[data-cy="modelizer-draw-view"] [data-cy="draw-container"] [id^="VPC_"]' not exists
Expand All @@ -40,9 +43,9 @@ Feature: Test modelizer draw view: add template component
And I expect '[data-cy="modelizer-draw-view"] [data-cy="draw-container"] [id^="VPC_"]' exists
And I expect '[data-cy="modelizer-draw-view"] [data-cy="draw-container"] [id^="VPC_"]' exists
And I expect '[class="link"]' exists

@skip
# TODO: update/fix test
# TODO: update/fix test
Scenario Outline: Dragging the <element> component should display it on the page
Then I expect '[data-cy="modelizer-draw-view"] [data-cy="draw-container"] [id^="<element>_"]' not exists

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ Feature: Test modelizer draw view: template filter
When I set on '[data-cy="create-model-form"] [data-cy="name-input"]' text 'modelName'
And I click on '[data-cy="create-model-form"] [data-cy="submit-button"]'
Then I expect current url is 'projectName/modelizer/draw\?path=terrator-plugin/modelName'
And I expect '[data-cy="component-definitions-item_Templates"]' exists

When I wait 1 second
And I click on '[data-cy="component-definitions-item_terrator-plugin"]'
And I wait 1 second
Then I expect '[data-cy="component-definitions-item_Templates"]' exists

Scenario Outline: Set text as '<filter>' should display only one element inside template title
When I set on '[data-cy="definitions-filter-input"]' text '<filter>'
Expand All @@ -28,7 +32,7 @@ Feature: Test modelizer draw view: template filter
| filter |
| Aws provider |
| Test application |

Scenario Outline: Set text as '<filter>' should not display template
When I set on '[data-cy="definitions-filter-input"]' text '<filter>'
Then I expect '[data-cy="component-definitions-item_Templates"]' appear 0 time on screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ Feature: Test modelizer draw view: template initialization
And I click on '[data-cy="create-model-form"] [data-cy="submit-button"]'
Then I expect current url is 'projectName/modelizer/draw\?path=terrator-plugin/modelName'

When I wait 1 second
And I click on '[data-cy="component-definitions-item_terrator-plugin"]'
And I wait 1 second

Scenario: Template should appear in component definitions list
Then I expect '[data-cy="component-definitions-item_Templates"]' exists
And I expect '[data-cy="component-definitions-item_Templates"] [data-cy="title"]' is 'Templates'

Scenario: Should have only one plugin installed with all these definitions
Scenario Outline: Should have only one plugin installed with all these definitions
When I click on '[data-cy="component-definitions-item_Templates"]'
Then I expect '[data-cy="component-definitions-item_Templates"].selected' exists
And I expect '[data-cy="component-definitions-item_Templates"].selected [data-cy="title"]' is 'Templates (2)'
Expand Down
12 changes: 5 additions & 7 deletions cypress/e2e/ModelizerPage/SwitchView/add.component.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ Feature: Test switch model to text view: add component/link
Then I expect current url is 'projectName/modelizer/draw\?path=terrator-plugin/modelName'
And I expect '[data-cy="component-definitions-item_terrator-plugin"]' appear 1 time on screen
And I expect '[data-cy="component-definitions-item_terrator-plugin"] [data-cy="title"]' is 'terrator-plugin'

# Select 'terrator-plugin' library
When I click on '[data-cy="component-definitions-item_terrator-plugin"]'
And I wait 1 second
Then I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
And I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
And I expect '[data-cy="component-definition-grid"]' exists
And I expect '[data-cy="component-definition-grid"] [class*="component-definition-card"]' appear 18 times on screen

Expand Down Expand Up @@ -99,7 +95,8 @@ Feature: Test switch model to text view: add component/link
But I expect '[id^="aws"]' not exists

Scenario: Link two components (Draw view) should update plugin file content with new attributes properties (Text view)
When I click on '[data-cy="component-definition_aws_subnet"]'
When I wait 1 second
And I click on '[data-cy="component-definition_aws_subnet"]'
And I wait 1 second
And I click on '[data-cy="component-definition_aws_internet_gateway"]'
And I wait 1 second
Expand Down Expand Up @@ -133,7 +130,8 @@ Feature: Test switch model to text view: add component/link
And I expect active file content to contain 'resource.*"aws_internet_gateway".*"aws_internet_gateway_1".*{}'

Scenario: Add link attributes inside plugin file content (Text view) should display link between two components (Draw view)
When I click on '[data-cy="component-definition_aws_subnet"]'
When I wait 1 second
And I click on '[data-cy="component-definition_aws_subnet"]'
And I wait 1 second
And I click on '[data-cy="component-definition_aws_internet_gateway"]'

Expand Down
8 changes: 3 additions & 5 deletions cypress/e2e/ModelizerPage/SwitchView/delete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ Feature: Test switch model to text view: delete component/link
Then I expect current url is 'projectName/modelizer/draw\?path=terrator-plugin/modelName'
And I expect '[data-cy="component-definitions-item_terrator-plugin"]' appear 1 time on screen
And I expect '[data-cy="component-definitions-item_terrator-plugin"] [data-cy="title"]' is 'terrator-plugin'

# Select 'terrator-plugin' library
When I click on '[data-cy="component-definitions-item_terrator-plugin"]'
And I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
And I expect '[data-cy="component-definition-grid"] [class*="component-definition-card"]' appear 18 times on screen
And I wait 1 second
Then I expect '[data-cy="component-definitions-item_terrator-plugin"].selected' exists
Then I expect '[data-cy="component-definition-grid"] [class*="component-definition-card"]' appear 18 times on screen

Scenario: Delete a component (Draw view) should remove plugin file (Text view)
When I click on '[data-cy="component-definition_aws"]'
Expand Down Expand Up @@ -137,6 +134,7 @@ Feature: Test switch model to text view: delete component/link

When I set active file content to '[]'
And I click on '[data-cy="navigation-bar"] [data-cy="modelizer-switch-button"] [aria-pressed="false"]'
And I wait 1 second
Then I expect '[data-cy="navigation-bar"] [data-cy="modelizer-switch-button"] [aria-pressed="true"] [class="block"]' is 'Draw'
And I expect '[data-cy="modelizer-draw-view"] [data-cy="draw-container"]' exists
But I expect '[id^="aws"]' not exists
Expand Down
5 changes: 2 additions & 3 deletions src/components/list/LibraryList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ const props = defineProps({
default: () => [],
},
});

const definitionFilter = ref('');
const selectedItemId = ref(null);
const isSelected = ref(false);
const selectedItemId = ref(props.plugin.data.name);
const isSelected = ref(true);
// TODO : remove this const
// when @quasar/[email protected] is officially released
const inputLabel = computed(() => t('page.modelizer.drawer.components.filterLabel'));
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/components/list/LibraryList.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,21 @@ describe('Test component: LibraryList', () => {

describe('Test function: onItemClick', () => {
it('should invert isSelected value and set selectedItemId equals to the given parameter', () => {
expect(wrapper.vm.isSelected).toBeFalsy();
expect(wrapper.vm.isSelected).toBeTruthy();

wrapper.vm.onItemClick('pluginName');
wrapper.vm.onItemClick();

expect(wrapper.vm.isSelected).toBeTruthy();
expect(wrapper.vm.selectedItemId).toEqual('pluginName');
expect(wrapper.vm.isSelected).toBeFalsy();
expect(wrapper.vm.selectedItemId).toBeNull();
});

it('should invert isSelected value and set selectedItemId to null', () => {
wrapper.vm.isSelected = true;
wrapper.vm.isSelected = false;

wrapper.vm.onItemClick();
wrapper.vm.onItemClick('pluginName');

expect(wrapper.vm.isSelected).toBeFalsy();
expect(wrapper.vm.selectedItemId).toEqual(null);
expect(wrapper.vm.isSelected).toBeTruthy();
expect(wrapper.vm.selectedItemId).toEqual('pluginName');
});
});
});