2020-03-05 22:42:21 +00:00
|
|
|
describe('node selection', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
cy.visit('/');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('logic after change detection', () => {
|
|
|
|
|
it('should deselect node if it is no longer on the page', () => {
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('.tree-wrapper').get('.tree-node.selected').should('not.exist');
|
2020-03-05 22:42:21 +00:00
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('.tree-wrapper').find('.tree-node:contains("app-todo[TooltipDirective]")').first().click({ force: true });
|
2020-03-05 22:42:21 +00:00
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('.tree-wrapper').find('.tree-node.selected').its('length').should('eq', 1);
|
2020-03-05 22:42:21 +00:00
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.enter('#sample-app').then((getBody) => {
|
|
|
|
|
getBody().find('a:contains("About")').click();
|
2020-03-05 22:42:21 +00:00
|
|
|
});
|
|
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('.tree-wrapper').get('.tree-node.selected').should('not.exist');
|
2020-03-05 22:42:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should reselect the previously selected node if it is still present', () => {
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('.tree-wrapper').get('.tree-node.selected').should('not.exist');
|
2020-03-05 22:42:21 +00:00
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.enter('#sample-app').then((getBody) => {
|
|
|
|
|
getBody().find('input.new-todo').type('Buy cookies{enter}');
|
2020-03-05 22:42:21 +00:00
|
|
|
});
|
|
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('.tree-wrapper').find('.tree-node:contains("app-todo[TooltipDirective]")').last().click({ force: true });
|
2020-03-05 22:42:21 +00:00
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.enter('#sample-app').then((getBody) => {
|
|
|
|
|
getBody().find('app-todo:contains("Buy milk")').find('.destroy').click();
|
2020-03-05 22:42:21 +00:00
|
|
|
});
|
|
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('.tree-wrapper').find('.tree-node.selected').its('length').should('eq', 1);
|
2020-03-05 22:42:21 +00:00
|
|
|
});
|
2020-03-19 20:10:24 +00:00
|
|
|
|
|
|
|
|
it('should select nodes with same name', () => {
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('.tree-wrapper').find('.tree-node:contains("app-todo[TooltipDirective]")').first().click({ force: true });
|
2020-03-19 20:10:24 +00:00
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('.tree-wrapper').find('.tree-node:contains("app-todo[TooltipDirective]")').last().click({ force: true });
|
2020-03-19 20:10:24 +00:00
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('ng-property-view').last().find('mat-tree-node:contains("todo")').click();
|
2020-03-19 20:10:24 +00:00
|
|
|
|
2020-04-08 23:22:14 +00:00
|
|
|
cy.get('ng-property-view').last().find('mat-tree-node:contains("Save the world")').its('length').should('eq', 1);
|
2020-03-19 20:10:24 +00:00
|
|
|
});
|
2020-03-05 22:42:21 +00:00
|
|
|
});
|
|
|
|
|
});
|