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

test: Update template credentials setup e2e test for new canvas (no-changelog) #12487

Merged
merged 4 commits into from
Jan 7, 2025
Merged
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
12 changes: 11 additions & 1 deletion cypress/e2e/34-template-credentials-setup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as formStep from '../composables/setup-template-form-step';
import { getSetupWorkflowCredentialsButton } from '../composables/setup-workflow-credentials-button';
import TestTemplate1 from '../fixtures/Test_Template_1.json';
import TestTemplate2 from '../fixtures/Test_Template_2.json';
import { clearNotifications } from '../pages/notifications';
import {
clickUseWorkflowButtonByTitle,
visitTemplateCollectionPage,
Expand Down Expand Up @@ -111,16 +112,19 @@ describe('Template credentials setup', () => {
templateCredentialsSetupPage.fillInDummyCredentialsForAppWithConfirm('X (Formerly Twitter)');
templateCredentialsSetupPage.fillInDummyCredentialsForApp('Telegram');

clearNotifications();

templateCredentialsSetupPage.finishCredentialSetup();

workflowPage.getters.canvasNodes().should('have.length', 3);

cy.grantBrowserPermissions('clipboardReadWrite', 'clipboardSanitizedWrite');

// Focus the canvas so the copy to clipboard works
workflowPage.getters.canvasNodes().eq(0).realClick();
workflowPage.actions.hitSelectAll();
workflowPage.actions.hitCopy();

cy.grantBrowserPermissions('clipboardReadWrite', 'clipboardSanitizedWrite');
// Check workflow JSON by copying it to clipboard
cy.readClipboard().then((workflowJSON) => {
const workflow = JSON.parse(workflowJSON);
Expand Down Expand Up @@ -154,6 +158,8 @@ describe('Template credentials setup', () => {
templateCredentialsSetupPage.fillInDummyCredentialsForApp('Email (IMAP)');
templateCredentialsSetupPage.fillInDummyCredentialsForApp('Nextcloud');

clearNotifications();

templateCredentialsSetupPage.finishCredentialSetup();

workflowPage.getters.canvasNodes().should('have.length', 3);
Expand All @@ -176,6 +182,8 @@ describe('Template credentials setup', () => {
templateCredentialsSetupPage.visitTemplateCredentialSetupPage(testTemplate.id);
templateCredentialsSetupPage.fillInDummyCredentialsForApp('Shopify');

clearNotifications();

templateCredentialsSetupPage.finishCredentialSetup();

getSetupWorkflowCredentialsButton().should('be.visible');
Expand All @@ -192,6 +200,8 @@ describe('Template credentials setup', () => {
templateCredentialsSetupPage.fillInDummyCredentialsForAppWithConfirm('X (Formerly Twitter)');
templateCredentialsSetupPage.fillInDummyCredentialsForApp('Telegram');

clearNotifications();

setupCredsModal.closeModalFromContinueButton();
setupCredsModal.getWorkflowCredentialsModal().should('not.exist');

Expand Down
7 changes: 6 additions & 1 deletion cypress/pages/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ export const infoToast = () => cy.get('.el-notification:has(.el-notification--in
* Actions
*/
export const clearNotifications = () => {
successToast().find('.el-notification__closeBtn').click({ multiple: true });
const buttons = successToast().find('.el-notification__closeBtn');
buttons.then(($buttons) => {
if ($buttons.length) {
buttons.click({ multiple: true });
}
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ exports[`useCanvasOperations > copyNodes > should copy nodes 1`] = `
}
],
"connections": {},
"pinData": {}
"pinData": {},
"meta": {
"instanceId": ""
}
}",
],
]
Expand Down Expand Up @@ -64,7 +67,10 @@ exports[`useCanvasOperations > cutNodes > should copy and delete nodes 1`] = `
}
],
"connections": {},
"pinData": {}
"pinData": {},
"meta": {
"instanceId": ""
}
}",
],
]
Expand Down
6 changes: 6 additions & 0 deletions packages/editor-ui/src/composables/useCanvasOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,12 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
async function copyNodes(ids: string[]) {
const workflowData = deepCopy(getNodesToSave(workflowsStore.getNodesByIds(ids)));

workflowData.meta = {
...workflowData.meta,
...workflowsStore.workflow.meta,
instanceId: rootStore.instanceId,
};

await clipboard.copy(JSON.stringify(workflowData, null, 2));

telemetry.track('User copied nodes', {
Expand Down
14 changes: 14 additions & 0 deletions packages/editor-ui/src/views/NodeView.v2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ const LazyNodeDetailsView = defineAsyncComponent(
async () => await import('@/components/NodeDetailsView.vue'),
);

const LazySetupWorkflowCredentialsButton = defineAsyncComponent(
async () =>
await import('@/components/SetupWorkflowCredentialsButton/SetupWorkflowCredentialsButton.vue'),
);

const $style = useCssModule();
const router = useRouter();
const route = useRoute();
Expand Down Expand Up @@ -1696,6 +1701,9 @@ onBeforeUnmount(() => {
@viewport-change="onViewportChange"
@drag-and-drop="onDragAndDrop"
>
<Suspense>
<LazySetupWorkflowCredentialsButton :class="$style.setupCredentialsButtonWrapper" />
</Suspense>
<div v-if="!isCanvasReadOnly" :class="$style.executionButtons">
<CanvasRunWorkflowButton
v-if="isRunWorkflowButtonVisible"
Expand Down Expand Up @@ -1804,6 +1812,12 @@ onBeforeUnmount(() => {
}
}

.setupCredentialsButtonWrapper {
position: absolute;
left: var(--spacing-s);
top: var(--spacing-s);
}

.readOnlyEnvironmentNotification {
position: absolute;
bottom: 16px;
Expand Down
Loading