Skip to content

Commit

Permalink
chore(root): Release 2024-11-19 08:06 (#7058)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Nov 19, 2024
2 parents 4db93d5 + f9b2199 commit 5e1dc24
Show file tree
Hide file tree
Showing 58 changed files with 805 additions and 329 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: blacksmith-2vcpu-ubuntu-2204
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/community-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
jobs:
check:
name: Verify
runs-on: blacksmith-2vcpu-ubuntu-2204
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conventional-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ permissions:
jobs:
main:
name: Validate PR titles
runs-on: blacksmith-2vcpu-ubuntu-2204
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/milestone-assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
permissions:
issues: write
pull-requests: write
runs-on: blacksmith-2vcpu-ubuntu-2204
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-pr-change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- edited
jobs:
check-branches:
runs-on: blacksmith-2vcpu-ubuntu-2204
runs-on: ubuntu-latest
steps:
- name: Check branches
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
contents: read
pull-requests: write
statuses: write
runs-on: blacksmith-2vcpu-ubuntu-2204
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-manager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
permissions:
contents: read
pull-requests: write
runs-on: blacksmith-2vcpu-ubuntu-2204
runs-on: ubuntu-latest
steps:
- name: Process stale PRs
uses: actions/stale@v9
Expand Down
2 changes: 1 addition & 1 deletion .source
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,26 @@ const InAppRenderOutputSchema = z.object({
avatar: z.string().optional(),
primaryAction: z
.object({
label: z.string(),
label: z.string().optional(),
redirect: z.object({
url: z.string(),
url: z.string().optional(),
target: RedirectTargetEnumSchema.optional(), // Optional target
}),
})
.optional(),
secondaryAction: z
.object({
label: z.string(),
label: z.string().optional(),
redirect: z.object({
url: z.string(),
url: z.string().optional(),
target: RedirectTargetEnumSchema.optional(), // Optional target
}),
})
.optional(), // Optional secondary action
data: z.record(z.unknown()).optional(), // Optional data
redirect: z
.object({
url: z.string(),
url: z.string().optional(),
target: RedirectTargetEnumSchema.optional(), // Optional target
})
.optional(),
Expand Down
55 changes: 29 additions & 26 deletions apps/api/src/app/events/e2e/bridge-trigger.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from 'axios';
import { expect } from 'chai';
import { v4 as uuidv4 } from 'uuid';
import sinon from 'sinon';

import { SubscribersService, UserSession } from '@novu/testing';
Expand Down Expand Up @@ -60,7 +59,7 @@ contexts.forEach((context: Context) => {
});

it(`should trigger the bridge workflow with sync [${context.name}]`, async () => {
const workflowId = `hello-world-${`${context.name}-${uuidv4()}`}`;
const workflowId = `hello-world-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step, payload }) => {
Expand Down Expand Up @@ -160,7 +159,7 @@ contexts.forEach((context: Context) => {
});

it(`should skip by static value [${context.name}]`, async () => {
const workflowIdSkipByStatic = `skip-by-static-value-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowIdSkipByStatic = `skip-by-static-value-workflow-${`${context.name}`}`;
const newWorkflow = workflow(
workflowIdSkipByStatic,
async ({ step, payload }) => {
Expand Down Expand Up @@ -223,7 +222,7 @@ contexts.forEach((context: Context) => {
});

it(`should skip by variable default value [${context.name}]`, async () => {
const workflowIdSkipByVariable = `skip-by-variable-default-value-${`${context.name}-${uuidv4()}`}`;
const workflowIdSkipByVariable = `skip-by-variable-default-value-${`${context.name}`}`;
const newWorkflow = workflow(
workflowIdSkipByVariable,
async ({ step, payload }) => {
Expand Down Expand Up @@ -287,7 +286,7 @@ contexts.forEach((context: Context) => {
});

it(`should have execution detail errors for invalid trigger payload [${context.name}]`, async () => {
const workflowId = `missing-payload-name-${`${context.name}-${uuidv4()}`}`;
const workflowId = `missing-payload-name-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step, payload }) => {
Expand Down Expand Up @@ -353,7 +352,7 @@ contexts.forEach((context: Context) => {
});

it(`should use custom step [${context.name}]`, async () => {
const workflowId = `with-custom-step-${`${context.name}-${uuidv4()}`}`;
const workflowId = `with-custom-step-${`${context.name}`}`;
const newWorkflow = workflow(workflowId, async ({ step }) => {
const resInApp = await step.inApp('send-in-app', async () => {
return {
Expand Down Expand Up @@ -419,7 +418,7 @@ contexts.forEach((context: Context) => {
});

it(`should trigger the bridge workflow with digest [${context.name}]`, async () => {
const workflowId = `digest-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowId = `digest-workflow-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -491,7 +490,7 @@ contexts.forEach((context: Context) => {
});

it(`should trigger the bridge workflow with delay [${context.name}]`, async () => {
const workflowId = `delay-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowId = `delay-workflow-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -572,7 +571,7 @@ contexts.forEach((context: Context) => {
});

it(`should trigger the bridge workflow with control default and payload data [${context.name}]`, async () => {
const workflowId = `default-payload-params-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowId = `default-payload-params-workflow-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step, payload }) => {
Expand Down Expand Up @@ -624,12 +623,16 @@ contexts.forEach((context: Context) => {
});

expect(sentMessage.length).to.be.eq(2);
expect(sentMessage[1].subject).to.include('prefix Hello default_name');
expect(sentMessage[0].subject).to.include('prefix Hello payload_name');
const expectedSubjects = ['prefix Hello default_name', 'prefix Hello payload_name'];

expectedSubjects.forEach((expectedSubject) => {
const found = sentMessage.some((message) => message.subject.includes(expectedSubject));
expect(found).to.be.true;
});
});

it(`should trigger the bridge workflow with control variables [${context.name}]`, async () => {
const workflowId = `control-variables-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowId = `control-variables-workflow-${`${context.name}`}`;
const stepId = 'send-email';
const newWorkflow = workflow(
workflowId,
Expand Down Expand Up @@ -687,7 +690,7 @@ contexts.forEach((context: Context) => {
});

it(`should store 2 in-app messages for a single notification event [${context.name}]`, async () => {
const workflowId = `double-in-app-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowId = `double-in-app-workflow-${`${context.name}`}`;
const newWorkflow = workflow(workflowId, async ({ step }) => {
await step.inApp('send-in-app1', () => ({ body: 'Hello there 1' }));
await step.inApp('send-in-app2', () => ({ body: 'Hello there 2' }));
Expand Down Expand Up @@ -716,7 +719,7 @@ contexts.forEach((context: Context) => {
});

it(`should deliver message if the Workflow Definition doesn't contain preferences [${context.name}]`, async () => {
const workflowId = `without-preferences-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowId = `without-preferences-workflow-${`${context.name}`}`;
const newWorkflow = workflow(workflowId, async ({ step }) => {
await step.inApp('send-in-app', () => ({ body: 'Hello there 1' }));
});
Expand Down Expand Up @@ -749,7 +752,7 @@ contexts.forEach((context: Context) => {
});

it(`should deliver message if inApp is enabled via workflow preferences [${context.name}]`, async () => {
const workflowId = `enabled-inapp-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowId = `enabled-inapp-workflow-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -786,7 +789,7 @@ contexts.forEach((context: Context) => {
});

it(`should NOT deliver message if inApp is disabled via workflow preferences [${context.name}]`, async () => {
const workflowId = `disabled-inapp-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowId = `disabled-inapp-workflow-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -834,7 +837,7 @@ contexts.forEach((context: Context) => {
});

it(`should deliver inApp message if workflow is disabled via workflow preferences and inApp is enabled [${context.name}]`, async () => {
const workflowId = `disabled-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowId = `disabled-workflow-inapp-enabled-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -874,7 +877,7 @@ contexts.forEach((context: Context) => {
});

it(`should NOT deliver inApp message if workflow is disabled via workflow preferences [${context.name}]`, async () => {
const workflowId = `disabled-workflow-${`${context.name}-${uuidv4()}`}`;
const workflowId = `disabled-workflow-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -921,7 +924,7 @@ contexts.forEach((context: Context) => {

// eslint-disable-next-line max-len
it(`should deliver inApp message if subscriber disabled inApp channel for readOnly workflow with inApp enabled [${context.name}]`, async () => {
const workflowId = `enabled-readonly-workflow-level-${`${context.name}-${uuidv4()}`}`;
const workflowId = `enabled-readonly-workflow-level-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -974,7 +977,7 @@ contexts.forEach((context: Context) => {

// eslint-disable-next-line max-len
it(`should NOT deliver inApp message if subscriber enables inApp channel for readOnly workflow with inApp disabled [${context.name}]`, async () => {
const workflowId = `disabled-readonly-workflow-level-${`${context.name}-${uuidv4()}`}`;
const workflowId = `disabled-readonly-workflow-level-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -1038,7 +1041,7 @@ contexts.forEach((context: Context) => {

// eslint-disable-next-line max-len
it(`should deliver inApp message if subscriber disabled inApp channel globally for readOnly workflow with inApp enabled [${context.name}]`, async () => {
const workflowId = `enabled-readonly-global-level-${`${context.name}-${uuidv4()}`}`;
const workflowId = `enabled-readonly-global-level-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -1089,7 +1092,7 @@ contexts.forEach((context: Context) => {

// eslint-disable-next-line max-len
it(`should NOT deliver inApp message if subscriber enabled inApp channel globally for readOnly workflow with inApp disabled [${context.name}]`, async () => {
const workflowId = `disabled-readonly-global-level-${`${context.name}-${uuidv4()}`}`;
const workflowId = `disabled-readonly-global-level-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -1158,7 +1161,7 @@ contexts.forEach((context: Context) => {
*/
expect(true).to.equal(true);
} else {
const workflowId = `disabled-editable-global-level-${`${context.name}-${uuidv4()}`}`;
const workflowId = `disabled-editable-global-level-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -1213,7 +1216,7 @@ contexts.forEach((context: Context) => {
*/
expect(true).to.equal(true);
} else {
const workflowId = `enabled-editable-global-level-${`${context.name}-${uuidv4()}`}`;
const workflowId = `enabled-editable-global-level-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -1279,7 +1282,7 @@ contexts.forEach((context: Context) => {
*/
expect(true).to.equal(true);
} else {
const workflowId = `disabled-editable-global-workflow-level-${`${context.name}-${uuidv4()}`}`;
const workflowId = `disabled-editable-global-workflow-level-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down Expand Up @@ -1343,7 +1346,7 @@ contexts.forEach((context: Context) => {
*/
expect(true).to.equal(true);
} else {
const workflowId = `enabled-editable-global-workflow-level-${`${context.name}-${uuidv4()}`}`;
const workflowId = `enabled-editable-global-workflow-level-${`${context.name}`}`;
const newWorkflow = workflow(
workflowId,
async ({ step }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expect } from 'chai';
import { NotificationTemplateService, UserSession } from '@novu/testing';
import { INotificationTemplate, INotificationTemplateStep } from '@novu/shared';
import { ChannelCTATypeEnum, INotificationTemplate, INotificationTemplateStep, StepTypeEnum } from '@novu/shared';
import { PreferencesRepository } from '@novu/dal';
import { CreateWorkflowRequestDto } from '../dto';

describe('Get workflow by id - /workflows/:workflowId (GET)', async () => {
let session: UserSession;
Expand Down Expand Up @@ -30,4 +32,51 @@ describe('Get workflow by id - /workflows/:workflowId (GET)', async () => {
expect(step._templateId).to.be.ok;
expect(foundTemplate.triggers.length).to.equal(template.triggers.length);
});

it('should return the workflow preference settings when the V2 Preferences do not exist', async () => {
const testTemplate = {
name: 'test template',
description: 'This is a test description',
notificationGroupId: session.notificationGroups[0]._id,
steps: [
{
template: {
name: 'Message Name',
content: 'Test Template',
type: StepTypeEnum.IN_APP,
cta: {
type: ChannelCTATypeEnum.REDIRECT,
data: {
url: 'https://example.org/profile',
},
},
},
},
],
preferenceSettings: {
in_app: true,
sms: true,
push: true,
chat: true,
email: false,
},
tags: [],
} satisfies CreateWorkflowRequestDto;
const { body: postWorkflowResponse } = await session.testAgent.post(`/v1/workflows`).send(testTemplate);

const preferenceRepository = new PreferencesRepository();

await preferenceRepository.delete({
_environmentId: session.environment._id,
_templateId: postWorkflowResponse.data._id,
});

const { body: getWorkflowResponse } = await session.testAgent.get(`/v1/workflows/${postWorkflowResponse.data._id}`);

expect(getWorkflowResponse.data).to.be.ok;

const template: INotificationTemplate = getWorkflowResponse.data;

expect(template.preferenceSettings).to.deep.equal(testTemplate.preferenceSettings);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ describe('Update workflow by id - /workflows/:workflowId (PUT)', async () => {
const template: INotificationTemplate = body.data;

const updateData: UpdateWorkflowRequestDto = {
name: '',
tags: [''],
description: '',
name: 'test email template',
tags: ['test-tag'],
description: 'This is a test description',
steps: [
{
template: {
Expand Down
Loading

0 comments on commit 5e1dc24

Please sign in to comment.