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

Create the channel preview sidebar and route #5128

6 changes: 3 additions & 3 deletions apps/web/cypress/tests/changes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dragAndDrop } from './notification-editor';
import { dragAndDrop, editChannel } from './notification-editor';
import { goBack } from './notification-editor';

describe('Changes Screen', function () {
Expand Down Expand Up @@ -122,7 +122,7 @@ function createNotification() {
cy.visit('/workflows/create');
cy.waitForNetworkIdle(500);

cy.getByTestId('title').clear().type('Test Notification Title');
cy.getByTestId('name-input').clear().type('Test Notification Title');

cy.getByTestId('settings-page').click();
cy.waitForNetworkIdle(500);
Expand All @@ -135,7 +135,7 @@ function createNotification() {
dragAndDrop('email');
cy.waitForNetworkIdle(500);

cy.clickWorkflowNode(`node-emailSelector`);
editChannel('email');
cy.waitForNetworkIdle(500);

cy.getByTestId('emailSubject').type('this is email subject');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ describe('Creation functionality', function () {
cy.clickWorkflowNode('node-emailSelector');
cy.waitForNetworkIdle(500);

cy.getByTestId('edit-action').click();
cy.waitForNetworkIdle(500);

cy.getByTestId('emailSubject').type('this is email subject');
cy.getByTestId('email-editor').getByTestId('editor-row').click();
cy.getByTestId('editable-text-content').clear().type('This text is written from a test {{firstName}}', {
Expand All @@ -223,6 +226,7 @@ describe('Creation functionality', function () {
cy.waitForNetworkIdle(500);

cy.clickWorkflowNode('node-smsSelector');
cy.getByTestId('edit-action').click();
cy.waitForNetworkIdle(500);

cy.getByTestId('smsNotificationContent').type('This text is written from a test {{var}}', {
Expand All @@ -240,11 +244,12 @@ describe('Creation functionality', function () {
cy.waitLoadTemplatePage(() => {
cy.visit('/workflows/create');
});
cy.waitForNetworkIdle(500);

dragAndDrop('email');
cy.waitForNetworkIdle(500);

cy.clickWorkflowNode('node-emailSelector');
editChannel('email');
cy.waitForNetworkIdle(500);

cy.getByTestId('emailSubject').type('this is email subject');
Expand Down
3 changes: 3 additions & 0 deletions apps/web/cypress/tests/notification-editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export function dragAndDrop(channel: Channel, dropTestId = 'addNodeButton') {

export function editChannel(channel: Channel, last = false) {
cy.clickWorkflowNode(`node-${channel}Selector`, last);
if (['inApp', 'email', 'sms', 'chat', 'push'].includes(channel)) {
cy.getByTestId('edit-action').click();
}
}

export function goBack() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('Workflow Editor - Main Functionality', function () {

cy.getByTestId('settings-page').click();
cy.waitForNetworkIdle(500);
cy.getByTestId('title').first().should('have.value', template.name);
cy.getByTestId('name-input').first().should('have.value', template.name);

editChannel('inApp');
cy.waitForNetworkIdle(500);
Expand All @@ -95,7 +95,7 @@ describe('Workflow Editor - Main Functionality', function () {
goBack();
cy.waitForNetworkIdle(500);

cy.getByTestId('title').clear().type('This is the new notification title');
cy.getByTestId('name-input').clear().type('This is the new notification title');

editChannel('inApp', true);
cy.waitForNetworkIdle(500);
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('Workflow Editor - Main Functionality', function () {
dragAndDrop('email');
cy.waitForNetworkIdle(500);

cy.clickWorkflowNode(`node-emailSelector`);
editChannel(`email`);

cy.getByTestId(`step-active-switch`).should('have.value', 'on');
cy.getByTestId(`step-active-switch`).click({ force: true });
Expand All @@ -221,8 +221,8 @@ describe('Workflow Editor - Main Functionality', function () {
goBack();

dragAndDrop('inApp');
editChannel('inApp');

cy.clickWorkflowNode(`node-inAppSelector`);
cy.getByTestId(`step-active-switch`).should('have.value', 'on');
});

Expand Down
49 changes: 27 additions & 22 deletions apps/web/cypress/tests/notification-editor/steps-actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Workflow Editor - Steps Actions', function () {
cy.get('.react-flow__node').should('have.length', 4);
cy.clickWorkflowNode(`node-inAppSelector`);
cy.waitForNetworkIdle(500);
cy.getByTestId('editor-sidebar-delete').click();
cy.getByTestId('step-actions-menu').click().getByTestId('delete-step-action').click();
cy.get('.mantine-Modal-modal button').contains('Delete step').click();
cy.getByTestId(`node-inAppSelector`).should('not.exist');
cy.get('.react-flow__node').should('have.length', 3);
Expand Down Expand Up @@ -112,12 +112,13 @@ describe('Workflow Editor - Steps Actions', function () {

cy.waitForNetworkIdle(500);

cy.clickWorkflowNode(`node-inAppSelector`);
editChannel(`inApp`);
cy.getByTestId(`step-active-switch`).get('label').contains('Active');
cy.getByTestId(`step-active-switch`).click({ force: true });
goBack();

cy.clickWorkflowNode(`node-inAppSelector`);
editChannel(`inApp`);

cy.getByTestId(`step-active-switch`).get('label').contains('Inactive');
});

Expand All @@ -128,12 +129,12 @@ describe('Workflow Editor - Steps Actions', function () {

cy.waitForNetworkIdle(500);

cy.clickWorkflowNode(`node-inAppSelector`);
editChannel(`inApp`);
cy.getByTestId(`step-should-stop-on-fail-switch`).get('label').contains('Stop if step fails');
cy.getByTestId(`step-should-stop-on-fail-switch`).click({ force: true });
goBack();

cy.clickWorkflowNode(`node-inAppSelector`);
editChannel(`inApp`);
cy.getByTestId(`step-should-stop-on-fail-switch`).should('be.checked');
});

Expand Down Expand Up @@ -214,7 +215,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.clickWorkflowNode(`node-inAppSelector`);

cy.getByTestId('editor-sidebar-add-conditions').click();
cy.getByTestId('add-conditions-action').click();
cy.getByTestId('add-new-condition').click();

cy.getByTestId('conditions-form-on').click();
Expand All @@ -227,7 +228,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.getByTestId('apply-conditions-btn').click();

cy.getByTestId('editor-sidebar-edit-conditions').contains('1');
cy.getByTestId('add-conditions-action').contains('1');
});

it('should be able to add read/seen filters to a particular step', function () {
Expand All @@ -239,7 +240,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.clickWorkflowNode(`node-emailSelector`);

cy.getByTestId('editor-sidebar-add-conditions').click();
cy.getByTestId('add-conditions-action').click();
cy.getByTestId('add-new-condition').click();

cy.getByTestId('conditions-form-on').click();
Expand All @@ -252,7 +253,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.getByTestId('apply-conditions-btn').click();

cy.getByTestId('editor-sidebar-edit-conditions').contains('1');
cy.getByTestId('add-conditions-action').contains('1');
});

it('should be able to not add read/seen filters to first step', function () {
Expand All @@ -264,7 +265,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.clickWorkflowNode(`node-inAppSelector`);

cy.getByTestId('editor-sidebar-add-conditions').click();
cy.getByTestId('add-conditions-action').click();

cy.getByTestId('add-new-condition').click();
cy.getByTestId('conditions-form-on').click();
Expand All @@ -280,7 +281,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.clickWorkflowNode(`node-inAppSelector`);

cy.getByTestId('editor-sidebar-add-conditions').click();
cy.getByTestId('add-conditions-action').click();

cy.getByTestId('add-new-condition').click();

Expand All @@ -291,15 +292,15 @@ describe('Workflow Editor - Steps Actions', function () {

cy.getByTestId('apply-conditions-btn').click();

cy.getByTestId('editor-sidebar-edit-conditions').contains('1');
cy.getByTestId('add-conditions-action').contains('1');

cy.getByTestId('editor-sidebar-edit-conditions').click();
cy.getByTestId('add-conditions-action').click();
cy.getByTestId('conditions-row-btn').click();
cy.getByTestId('conditions-row-delete').click();

cy.getByTestId('apply-conditions-btn').click();

cy.getByTestId('editor-sidebar-add-conditions').should('not.contain', '1');
cy.getByTestId('add-conditions-action').should('not.contain', '1');
});

it('should be able to add webhook filter for a particular step', function () {
Expand All @@ -311,7 +312,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.clickWorkflowNode(`node-inAppSelector`);

cy.getByTestId('editor-sidebar-add-conditions').click();
cy.getByTestId('add-conditions-action').click();

cy.getByTestId('add-new-condition').click();

Expand All @@ -326,7 +327,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.getByTestId('apply-conditions-btn').click();

cy.getByTestId('editor-sidebar-edit-conditions').contains('1');
cy.getByTestId('add-conditions-action').contains('1');
});

it('should be able to add online right now filter for a particular step', function () {
Expand All @@ -338,7 +339,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.clickWorkflowNode(`node-inAppSelector`);

cy.getByTestId('editor-sidebar-add-conditions').click();
cy.getByTestId('add-conditions-action').click();

cy.getByTestId('add-new-condition').click();

Expand All @@ -349,7 +350,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.getByTestId('apply-conditions-btn').click();

cy.getByTestId('editor-sidebar-edit-conditions').contains('1');
cy.getByTestId('add-conditions-action').contains('1');
});

it('should be able to add online in the last X time period filter for a particular step', function () {
Expand All @@ -361,7 +362,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.clickWorkflowNode(`node-inAppSelector`);

cy.getByTestId('editor-sidebar-add-conditions').click();
cy.getByTestId('add-conditions-action').click();

cy.getByTestId('add-new-condition').click();

Expand All @@ -373,7 +374,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.getByTestId('apply-conditions-btn').click();

cy.getByTestId('editor-sidebar-edit-conditions').contains('1');
cy.getByTestId('add-conditions-action').contains('1');
});

it('should be able to add multiple filters to a particular step', function () {
Expand All @@ -385,7 +386,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.clickWorkflowNode(`node-inAppSelector`);

cy.getByTestId('editor-sidebar-add-conditions').click();
cy.getByTestId('add-conditions-action').click();

cy.getByTestId('add-new-condition').click();
cy.getByTestId('conditions-form-on').click();
Expand All @@ -404,7 +405,7 @@ describe('Workflow Editor - Steps Actions', function () {

cy.getByTestId('apply-conditions-btn').click();

cy.getByTestId('editor-sidebar-edit-conditions').contains('2');
cy.getByTestId('add-conditions-action').contains('2');
});

it('should re-render content on between step click', function () {
Expand All @@ -425,15 +426,19 @@ describe('Workflow Editor - Steps Actions', function () {
const lastContent = 'last content for sms';

cy.clickWorkflowNode(`node-smsSelector`);
cy.getByTestId('edit-action').click();
cy.getByTestId('smsNotificationContent').type(firstContent);

cy.clickWorkflowNode(`node-smsSelector`, true);
cy.getByTestId('edit-action').click();
cy.getByTestId('smsNotificationContent').type(lastContent);

cy.clickWorkflowNode(`node-smsSelector`);
cy.getByTestId('edit-action').click();
cy.getByTestId('smsNotificationContent').should('have.text', firstContent);

cy.clickWorkflowNode(`node-smsSelector`, true);
cy.getByTestId('edit-action').click();
cy.getByTestId('smsNotificationContent').should('have.text', lastContent);
});
});
8 changes: 4 additions & 4 deletions apps/web/cypress/tests/notification-editor/variants.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Workflow Editor - Variants', function () {
cy.visit('/workflows/create');
});
cy.wait('@getWorkflow');
cy.getByTestId('title').first().clear().type(title).blur();
cy.getByTestId('name-input').first().clear().type(title).blur();
};

const fillInAppEditorContentWith = (text: string) => {
Expand Down Expand Up @@ -322,7 +322,7 @@ describe('Workflow Editor - Variants', function () {
cy.wait('@getWorkflow');

cy.getByTestId(`node-${channel}Selector`).getByTestId('variants-count').contains('2 variants');
editChannel(channel);
cy.clickWorkflowNode(`node-${channel}Selector`);

checkVariantListCard({ selector: 'variant-item-card-1', message: VARIANT_EDITOR_TEXT });
checkVariantConditions({ selector: 'variant-item-card-1', contains: '1' });
Expand Down Expand Up @@ -647,7 +647,7 @@ describe('Workflow Editor - Variants', function () {

navigateAndOpenFirstWorkflow();

editChannel(channel);
cy.clickWorkflowNode(`node-${channel}Selector`);

cy.getByTestId('variant-item-card-0').getByTestId('conditions-action').should('be.visible').contains('1');
cy.getByTestId('variant-item-card-0').trigger('mouseover');
Expand Down Expand Up @@ -678,7 +678,7 @@ describe('Workflow Editor - Variants', function () {

navigateAndOpenFirstWorkflow();

editChannel(channel);
cy.clickWorkflowNode(`node-${channel}Selector`);

cy.getByTestId('variant-root-card').getByTestId('conditions-action').should('be.visible').contains('No');
cy.getByTestId('variant-root-card').trigger('mouseover');
Expand Down
2 changes: 2 additions & 0 deletions apps/web/cypress/tests/tenants-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ describe('Tenants Page', function () {
cy.getByTestId('update-tenant-sidebar-submit').click();
});

cy.waitForNetworkIdle(500);

cy.getByTestId('tenants-list-table').find('td:nth-child(1)').contains('New Name');
cy.getByTestId('tenants-list-table').find('td:nth-child(2)').contains('test-tenant');

Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import { SSO, UserAccess, Cloud } from '@novu/design-system';
import { BrandingForm, LayoutsListPage } from './pages/brand/tabs';
import { TranslationRoutes } from './pages/TranslationPages';
import { VariantsPage } from './pages/templates/components/VariantsPage';
import { ChannelPreview } from './pages/templates/components/ChannelPreview';

library.add(far, fas);

Expand Down Expand Up @@ -159,6 +160,7 @@ function App() {
<Route path="snippet" element={<SnippetPage />} />
<Route path="providers" element={<ProvidersPage />} />
<Route path=":channel/:stepUuid" element={<ChannelStepEditor />} />
<Route path=":channel/:stepUuid/preview" element={<ChannelPreview />} />
<Route path=":channel/:stepUuid/variants" element={<VariantsPage />} />
<Route path=":channel/:stepUuid/variants/:variantUuid" element={<ChannelStepEditor />} />
<Route path=":channel/:stepUuid/variants/create" element={<VariantsPage />} />
Expand Down
Loading
Loading