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

Add test for code snippet cloning #2451

Merged
merged 1 commit into from
Feb 8, 2022
Merged
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
33 changes: 33 additions & 0 deletions tests/integration/codesnippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,31 @@ describe('Code Snippet tests', () => {
deleteSnippet(snippetName);
});

// Duplicate snippet
it('should duplicate existing Code Snippet', () => {
createValidCodeSnippet(snippetName);
cy.wait(500);
let snippetRef = getSnippetByName(snippetName);
expect(snippetRef).to.not.be.null;

// create a duplicate of this snippet
duplicateSnippet(snippetName);
cy.wait(100);
snippetRef = getSnippetByName(`${snippetName}-Copy1`);
expect(snippetRef).to.not.be.null;

// create another duplicate of this snippet
duplicateSnippet(snippetName);
cy.wait(100);
snippetRef = getSnippetByName(`${snippetName}-Copy2`);
expect(snippetRef).to.not.be.null;

// cleanup
deleteSnippet(snippetName);
deleteSnippet(`${snippetName}-Copy1`);
deleteSnippet(`${snippetName}-Copy2`);
});

it('should have visible action buttons for existing code snippet', () => {
createValidCodeSnippet(snippetName);

Expand Down Expand Up @@ -367,6 +392,14 @@ const deleteSnippet = (snippetName: string): void => {
cy.get('button.jp-mod-accept').click();
};

const duplicateSnippet = (snippetName: string): void => {
// Find element by name
const item = getSnippetByName(snippetName);

// Click duplicate button
item.find('button[title="Duplicate"]').click();
};

const getActionButtonsElement = (snippetName: string): any => {
const actionButtonsElement = getSnippetByName(snippetName).find(
'.elyra-expandableContainer-action-buttons'
Expand Down