Skip to content

Commit

Permalink
Merge pull request #13 from snyk-tech-services/test/custom-template
Browse files Browse the repository at this point in the history
test: custom Handlebars.js template provided as input
  • Loading branch information
lili2311 authored Oct 2, 2020
2 parents acf8a0f + 5b4c3c7 commit 858bf5d
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 3 deletions.
158 changes: 158 additions & 0 deletions test/system/fixtures/custom-view.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-us">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Snyk Licenses Report</title>
<link rel="icon" type="image/png" href="https://res.cloudinary.com/snyk/image/upload/v1468845142/favicon/favicon.png"
sizes="194x194">
<link rel="shortcut icon" href="https://res.cloudinary.com/snyk/image/upload/v1468845142/favicon/favicon.ico">
<style type="text/css">
body {
margin: 0;
padding: 0;
font-weight: 400;
}
a {
color: #4b45a1;
}
h1,
h2 {
color: #393842;
}
.banner-logo {
padding-right: 2%;
margin-top: .85em;
}
.banner-container {
padding: 0 1.25rem;
}
.banner {
height: 4.0625rem;
padding: .75rem 0;
}
.banner {
background-color: #4b45a9;
padding: .625rem 0;
position: relative;
z-index: 1000;
}
.border-bottom {
border-bottom: 1px solid #ccc;
}
.border-top {
border-top: 1px solid #ccc;
}
.border-left {
border-left: 1px solid #ccc;
}
.border-right {
border-right: 1px solid #ccc;
}
.license_title {
border-left: .5rem solid #ccc;
padding: 4px;
}
.license_title--medium {
border-left-color: #df8620;
}
.license_title--high {
border-left-color: #b31a6b;
}
.display-flex {
display: flex;
max-width: 100%;
}
.column {
flex: 1 0 150px;
max-width: 100%;
}
.column-large {
flex: 1 0 300px;
max-width: 100%;
}
.dependency {
flex: 0 0 30%;
max-width: 100%;
word-break: break-all;
}
.u-padding-top--sm {
padding-top: .5rem;
}
.u-margin-top--sm {
margin-top: .5rem;
}
.u-padding--sm {
padding: .5rem;
}
.u-padding--xl {
padding: 2rem;
}
.overflow-auto {
overflow: auto;
}
</style>
</head>

<body>
{{!-- {{> header }} --}}
<header id="banner" class="banner">
<div class="banner-container">
<div class="banner-logo">
<a class="brand" href="https://www.snyk.io" title="Snyk">
<svg width="68px" height="35px" viewBox="0 0 68 35" version="1.1" xmlns="http://www.w3.org/2000/svg"
role="img">
<title>Snyk - Open Source Security</title>
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g fill="#fff">
<path
d="M5.732,27.278 C3.445,27.278 1.589,26.885 0,26.124 L0.483,22.472 C2.163,23.296 4.056,23.689 5.643,23.689 C6.801,23.689 7.563,23.295 7.563,22.599 C7.563,20.594 0.333,21.076 0.333,15.839 C0.333,12.491 3.407,10.729 7.259,10.729 C9.179,10.729 11.161,11.249 12.444,11.704 L11.924,15.294 C10.577,14.774 8.747,14.291 7.222,14.291 C6.282,14.291 5.518,14.621 5.518,15.231 C5.518,17.208 12.903,16.815 12.903,21.925 C12.903,25.325 9.877,27.277 5.733,27.277 L5.732,27.278 Z M25.726,26.936 L25.726,17.894 C25.726,15.827 24.811,14.85 23.069,14.85 C22.219,14.85 21.329,15.09 20.719,15.46 L20.719,26.936 L15.352,26.936 L15.352,11.262 L20.602,10.83 L20.474,13.392 L20.652,13.392 C21.784,11.87 23.702,10.716 25.992,10.716 C28.736,10.716 31.112,12.416 31.112,16.436 L31.112,26.936 L25.724,26.936 L25.726,26.936 Z M61.175,26.936 L56.879,19.479 L56.446,19.479 L56.446,26.935 L51.082,26.935 L51.082,8.37 L56.447,0 L56.447,17.323 C57.515,16.017 61.112,11.059 61.112,11.059 L67.732,11.059 L61.454,17.689 L67.949,26.95 L61.175,26.95 L61.175,26.938 L61.175,26.936 Z M44.13,11.11 L41.93,18.262 C41.5,19.606 41.08,22.079 41.08,22.079 C41.08,22.079 40.75,19.516 40.292,18.172 L37.94,11.108 L31.928,11.108 L38.462,26.935 C37.572,29.04 36.199,30.815 34.369,30.815 C34.039,30.815 33.709,30.802 33.389,30.765 L31.255,34.061 C31.928,34.441 33.212,34.835 34.737,34.835 C38.703,34.835 41.359,31.627 43.215,26.885 L49.443,11.108 L44.132,11.108 L44.13,11.11 Z">
</path>
</g>
</g>
</svg>
</a>
</div>
</div>
</header>

<main class="u-padding--xl">
<h1>Custom Template Licenses Attribution Report</h1>
<h2>Org: <a href="{{orgData.url}}">{{orgData.name}}</a></h2>
{{#each licenses}}
<div class="u-padding-top--sm">
<h1 class="license_title license_title--{{severity}}">
<a href="{{licenseUrl}}">{{id}}</a>
</h1>
<strong>Severity</strong>: {{severity}}
</div>
{{/each}}
</main>
</body>

</html>
15 changes: 12 additions & 3 deletions test/system/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,18 @@ describe('`snyk-licenses-report generate <...>`', () => {
},
);
}, 50000);
it.todo('generated the report successfully with custom template');
it.todo('generated the report successfully with custom template');

it('generated the report successfully with custom template', (done) => {
exec(
`node ${main} generate --orgPublicId=${ORG_ID} --template=${__dirname + '/fixtures/custom-view.hbs'}`,
{ env: { SNYK_TOKEN: process.env.SNYK_TEST_TOKEN } },
(err, stdout) => {
console.log({err, stdout})
expect(err).toBeNull();
expect(stdout).toMatch('HTML license report saved at');
done();
},
);
}, 50000);
it.todo('API is down');
it.todo('Requested org has no licenses policy');
});

0 comments on commit 858bf5d

Please sign in to comment.