Skip to content

Commit

Permalink
Merge branch 'next' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
sagnik3788 authored Oct 2, 2023
2 parents 41c424b + c13c527 commit 29200d1
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 529 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/dev-deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ jobs:
steps:
- run: echo ${{ matrix.projectName }}
- uses: actions/checkout@v3
- uses: ./.github/actions/checkout-submodules
with:
submodule_token: ${{ secrets.SUBMODULES_TOKEN }}
submodule_branch: "next"
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/setup-redis-cluster
- uses: mansagroup/nrwl-nx-action@v3
Expand Down Expand Up @@ -88,11 +84,6 @@ jobs:
name: ['novu/api-ee', 'novu/api']
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/checkout-submodules
with:
enabled: ${{ contains (matrix.name,'ee') }}
submodule_token: ${{ secrets.SUBMODULES_TOKEN }}
submodule_branch: "next"
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/docker/build-api
id: docker_build
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/dev-deploy-worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ jobs:
name: ['novu/worker-ee', 'novu/worker']
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/checkout-submodules
with:
enabled: ${{ contains (matrix.name,'ee') }}
submodule_token: ${{ secrets.SUBMODULES_TOKEN }}
submodule_branch: "next"
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/docker/build-worker
id: docker_build
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/prod-deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ jobs:
steps:
- run: echo ${{ matrix.projectName }}
- uses: actions/checkout@v3
- uses: ./.github/actions/checkout-submodules
with:
submodule_token: ${{ secrets.SUBMODULES_TOKEN }}
submodule_branch: "next"
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/setup-redis-cluster
- uses: mansagroup/nrwl-nx-action@v3
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ jobs:
else
echo "::set-output name=has_token::false"
fi
test_e2e_ee:
name: Test E2E EE
runs-on: ubuntu-latest
Expand All @@ -260,10 +260,6 @@ jobs:
steps:
- run: echo ${{ matrix.projectName }}
- uses: actions/checkout@v3
- uses: ./.github/actions/checkout-submodules
with:
submodule_token: ${{ secrets.SUBMODULES_TOKEN }}
submodule_branch: "next"
- uses: ./.github/actions/setup-project
- uses: ./.github/actions/setup-redis-cluster
- uses: mansagroup/nrwl-nx-action@v3
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can open a new issue with this [issue form](https://github.com/novuhq/novu/i

### Requirements

- Node.js version v14.19.3
- Node.js version v16.15.1
- MongoDB
- Redis. To install Redis on your O.S, please follow the below guides
- [To install Redis on Windows](https://redis.io/docs/getting-started/installation/install-redis-on-windows/)
Expand Down
95 changes: 95 additions & 0 deletions apps/api/src/app/shared/helpers/content.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,99 @@ describe('ContentService', function () {
expect(extractVariables[0].name).to.include('lastName');
});
});

describe('extractStepVariables', () => {
it('should not fail if no filters available', () => {
const contentService = new ContentService();
const messages = [
{
template: {
type: StepTypeEnum.EMAIL,
subject: 'Test {{subscriber.firstName}}',
content: [
{
content: 'Test of {{subscriber.firstName}} {{lastName}}',
type: 'text',
},
],
},
},
] as INotificationTemplateStep[];
const variables = contentService.extractStepVariables(messages);

expect(variables.length).to.equal(0);
});

it('should not fail if filters are set as non array', () => {
const contentService = new ContentService();
const messages = [
{
template: {
type: StepTypeEnum.EMAIL,
subject: 'Test {{subscriber.firstName}}',
content: [
{
content: 'Test of {{subscriber.firstName}} {{lastName}}',
type: 'text',
},
],
},
filters: {},
},
] as INotificationTemplateStep[];
const variables = contentService.extractStepVariables(messages);

expect(variables.length).to.equal(0);
});

it('should not fail if filters are an empty array', () => {
const contentService = new ContentService();
const messages = [
{
template: {
type: StepTypeEnum.EMAIL,
subject: 'Test {{subscriber.firstName}}',
content: [
{
content: 'Test of {{subscriber.firstName}} {{lastName}}',
type: 'text',
},
],
},
filters: [],
},
] as INotificationTemplateStep[];
const variables = contentService.extractStepVariables(messages);

expect(variables.length).to.equal(0);
});

it('should not fail if filters have some wrong settings like missing children in filters', () => {
const contentService = new ContentService();
const messages = [
{
template: {
type: StepTypeEnum.EMAIL,
subject: 'Test {{subscriber.firstName}}',
content: [
{
content: 'Test of {{subscriber.firstName}} {{lastName}}',
type: 'text',
},
],
},
filters: [
{
isNegated: false,
type: 'GROUP',
value: 'AND',
},
],
},
] as INotificationTemplateStep[];
const variables = contentService.extractStepVariables(messages);

expect(variables.length).to.equal(0);
});
});
});
24 changes: 13 additions & 11 deletions apps/api/src/app/shared/helpers/content.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,19 @@ export class ContentService {

for (const message of messages) {
if (message.filters) {
const filterVariables = message.filters.flatMap((filter) =>
filter.children
.filter((item) => item.on === FilterPartTypeEnum.PAYLOAD)
.map((item: IFieldFilterPart) => {
return {
name: item.field,
type: TemplateVariableTypeEnum.STRING,
};
})
);
variables.push(...filterVariables);
const filters = Array.isArray(message.filters) ? message.filters : [];
const filteredVariables = filters.flatMap((filter) => {
const filteredChildren = filter.children?.filter((item) => item.on === FilterPartTypeEnum.PAYLOAD) || [];
const mappedChildren = filteredChildren.map((item: IFieldFilterPart) => {
return {
name: item.field,
type: TemplateVariableTypeEnum.STRING,
};
});

return mappedChildren;
});
variables.push(...filteredVariables);
}

if (message.metadata?.type === DelayTypeEnum.SCHEDULED && message.metadata.delayPath) {
Expand Down
2 changes: 1 addition & 1 deletion apps/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"less-loader": "4.1.0",
"typescript": "4.9.5",
"webpack-dev-server": "4.11.1",
"webpack": "^5.78.0"
"webpack": "5.78.0"
},
"browserslist": {
"production": [
Expand Down
Loading

0 comments on commit 29200d1

Please sign in to comment.