Skip to content

Commit

Permalink
Merge pull request #11 from cloudblue/fix-scroll
Browse files Browse the repository at this point in the history
Fix scrool and increase coverage
  • Loading branch information
martinconstante authored Nov 21, 2022
2 parents c7ed244 + 09e02b3 commit dbeb7cc
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 160 deletions.
2 changes: 1 addition & 1 deletion cen/extension.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "End Customer Email Notifications",
"description": "With this extension you can send an email every time that a purchase request is approved.",
"version": "1.1.2",
"version": "1.1.3",
"readme_url": "https://github.com/cloudblue/connect-extension-service-delivery-notifications/master/README.md",
"changelog_url": "https://github.com/cloudblue/connect-extension-service-delivery-notifications/master/CHANGELOG.md",
"audience": ["distributor", "reseller"],
Expand Down
4 changes: 0 additions & 4 deletions cen/static/example.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
![logo](https://www.cloudblue.com/assets/images/navlogo-dark.png)

# Sample activation email template

Dear **{{request.asset.tiers.customer.name}}**

Your subscription **{{request.asset.id}}**
for **{{request.asset.product.name}}** has been activated.

This subscription contains the following items:

{% for item in request.asset['items'] %}
{{ item.display_name }} : {{ item.quantity }}
{% endfor %}

Your subscription has been enabled using following parameters that maybe useful in order to use your subscription.

{% for param in request.asset['params'] %}
{{ param.id }} : {{ param.value }}
{% endfor %}
Expand Down
136 changes: 0 additions & 136 deletions cen/static/js/delivery.js

This file was deleted.

4 changes: 2 additions & 2 deletions cen/static/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export async function getSettings() {
return body;
}

async function getRule(id) {
export async function getRule(id) {
const response = await fetch(`/api/rules/${id}`);
const body = await response.json();
return body;
}

async function getRulesProducts() {
export async function getRulesProducts() {
const response = await fetch('/api/products');
const body = await response.json();
return body;
Expand Down
6 changes: 1 addition & 5 deletions cen/static/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ <h5 class="modal-title" id="exampleModalLabel"><label id="header-content"></labe
<label class="col-form-label" for="flexCheckDefault">Select product</label>
<select class="form-select" id="product-id-select"
aria-label="Select the product">
<option value="PRD-022-646-431">PRD-022-646-431 - Product P03 for
martin.constante</option>
<option value="PRD-681-870-239">PRD-681-870-239 - Product P04 for
martin.constante</option>
</select>
</div>
<div id="productIdLabel" style="display: none"></div>
Expand All @@ -117,7 +113,7 @@ <h5 class="modal-title" id="exampleModalLabel"><label id="header-content"></labe
<input class="form-check-input" type="checkbox" value="" id="enabled">
</div>
<label for="message-text" class="col-form-label">Email content</label>
<textarea class="form-control" id="message-text" rows="28"></textarea>
<textarea class="form-control" id="message-text" rows="18"></textarea>
</div>
<div class="col-lg-6 col-preview">
<label class="col-form-label" for="">Preview</label>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "customer-email-notifications"
version = "1.0.0"
version = "1.1.3"
description = "CloudBlue Connect Multi Account Extension that allows to send a personalized email when a new subscription request is created"
authors = ["CloudBlue LLC"]
license = "Apache-2.0"
Expand Down
62 changes: 51 additions & 11 deletions tests/settings.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {getSettings, getRules } from '../cen/static/js/settings.js';
import { getSettings, getRules, getRule, getRulesProducts } from '../cen/static/js/settings.js';

global.fetch.mockReturnValue(Promise.resolve({
json: () => Promise.resolve({email_sender: 'test@example.email', name: 'Test'}),
}));

let settings;

describe('getSettings', () => {
describe('getSettingsTest', () => {
let settings;
beforeEach(async () => {
global.fetch.mockReturnValue(Promise.resolve({
json: () => Promise.resolve({ email_sender: 'test@example.email', name: 'Test' }),
}));
settings = await getSettings();
});
it('should return settings', () => {
Expand All @@ -21,11 +19,53 @@ describe('getSettings', () => {
});
});

describe('getRules', () => {
describe('getRulesTest', () => {
it('should return rules', async () => {
global.fetch.mockReturnValue(Promise.resolve({
json: () => Promise.resolve('OK')}));
json: () => Promise.resolve('OK')
}));
const rules = await getRules();
expect(rules).toBe('OK');
});
});
});

describe('getRuleTest', () => {
it('should return rule', async () => {
global.fetch.mockReturnValue(Promise.resolve({
json: () => Promise.resolve({
product_id: 'PRD-000',
product_name: 'product01',
product_logo: 'img.png',
message: 'message',
enabled: true,

})
}));
const rule = await getRule('RUL-000');
expect(rule.product_id).toBe('PRD-000');
expect(rule.product_name).toBe('product01');
expect(rule.product_logo).toBe('img.png');
expect(rule.message).toBe('message');
expect(rule.enabled).toBe(true);
});
});

describe('getRulesProductsTest', () => {
it('should return rule', async () => {
global.fetch.mockReturnValue(Promise.resolve({
json: () => Promise.resolve([
{
'id': 'PRD-000',
'name': 'product01',
'icon': 'img.png',
'used': true
}
])
}));
const rule = await getRulesProducts();
expect(rule['0'].id).toBe('PRD-000');
expect(rule['0'].name).toBe('product01');
expect(rule['0'].icon).toBe('img.png');
expect(rule['0'].used).toBe(true);
});
});

0 comments on commit dbeb7cc

Please sign in to comment.