Skip to content

Commit 8683456

Browse files
committed
add e2e test
1 parent 261443e commit 8683456

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

packages/compass-e2e-tests/helpers/selectors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,8 @@ export const DataModelsListItem = (diagramName?: string) => {
14781478
export const DataModelsListItemActions = (diagramName: string) =>
14791479
`${DataModelsListItem(diagramName)} [aria-label="Show actions"]`;
14801480
export const DataModelsListItemDeleteButton = `[data-action="delete"]`;
1481-
export const DataModelAddRelationshipBtn = 'aria/Add relationship';
1481+
export const DataModelAddRelationshipBtn = 'aria/Add Relationship';
1482+
export const DataModelAddCollectionBtn = 'aria/Add Collection';
14821483
export const DataModelNameInputLabel = '//label[text()="Name"]';
14831484
export const DataModelNameInput =
14841485
'input[data-testid="data-model-collection-drawer-name-input"]';

packages/compass-e2e-tests/tests/data-modeling-tab.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,5 +733,41 @@ describe('Data Modeling tab', function () {
733733
expect(nodesPostDelete).to.have.lengthOf(1);
734734
expect(nodesPostDelete[0].id).to.equal('test.testCollection-renamedOne');
735735
});
736+
737+
it('adding a new collection from the toolbar', async function () {
738+
const dataModelName = 'Test Edit Collection';
739+
await setupDiagram(browser, {
740+
diagramName: dataModelName,
741+
connectionName: DEFAULT_CONNECTION_NAME_1,
742+
databaseName: 'test',
743+
});
744+
745+
const dataModelEditor = browser.$(Selectors.DataModelEditor);
746+
await dataModelEditor.waitForDisplayed();
747+
748+
// Click on the add collection button.
749+
await browser.clickVisible(Selectors.DataModelAddCollectionBtn);
750+
751+
// Verify that the drawer is opened.
752+
const drawer = browser.$(Selectors.SideDrawer);
753+
await drawer.waitForDisplayed();
754+
755+
// Name the collection (it submits on unfocus).
756+
const collectionName = 'testCollection-newOne';
757+
await browser.setValueVisible(
758+
browser.$(Selectors.DataModelNameInput),
759+
collectionName
760+
);
761+
await drawer.click(); // Unfocus the input.
762+
763+
// Verify that the new collection is added to the diagram.
764+
const nodes = await getDiagramNodes(browser, 3);
765+
expect(nodes[2].id).to.equal('test.testCollection-newOne');
766+
767+
// Undo once - verify that the collection is removed
768+
// This is to ensure that the initial edit of the collection name wasn't a separate edit
769+
await browser.clickVisible(Selectors.DataModelUndoButton);
770+
await getDiagramNodes(browser, 2);
771+
});
736772
});
737773
});

0 commit comments

Comments
 (0)