Skip to content
This repository has been archived by the owner on Jan 14, 2019. It is now read-only.

Commit

Permalink
fix bug and icon for archives (fixes #927, via #928)
Browse files Browse the repository at this point in the history
  • Loading branch information
sseliverstov authored and baev committed Feb 15, 2017
1 parent daf051a commit 091f64c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Expected: "{\n\"name\": \"test\",\n\"value\": \"ok value\"\n}"
<attachment title="CSV Attachment" source="b81da3c0-1b9d-4219-9e35-87e139ec446c-attachment.csv" type="text/csv"/>
<attachment title="WEBM Attachment" source="aae99fa5-af39-461f-b218-b1e4f2a88e56-attachment.webm" type="video/webm"/>
<attachment title="URI Attachment" source="00a0bc5a-6372-4e66-8088-1571966a056b-attachment.uri" type="text/uri-list"/>
<attachment title="TAR.GZIP Attachment" source="00a0bc5a-6372-4e66-8088-1571966a156b-attachment.tar.gz" type="application/x-gtar"/>
</attachments>
<labels>
<label name="severity" value="critical"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void shouldGenerateWithoutFailures() throws Exception {
assertThat(dataDirectory, contains(PluginManager.WIDGETS_JSON));
assertThat(dataDirectory, contains(ReportWriter.REPORT_JSON));

assertThat(dataDirectory, hasFilesCount(14, "*-attachment*"));
assertThat(dataDirectory, hasFilesCount(15, "*-attachment*"));
assertThat(dataDirectory, hasFilesCount(321, "*-testcase.json"));
}

Expand Down
14 changes: 1 addition & 13 deletions allure-report-face/src/helpers/fileicon.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import typeByMime from '../util/attachmentType';

export default function(type) {
switch (typeByMime(type).type) {
case 'text':
return 'fa fa-file-text-o';
case 'image':
case 'svg':
return 'fa fa-file-image-o';
case 'code':
return 'fa fa-file-code-o';
case 'table':
return 'fa fa-table';
default:
return 'fa fa-file-o';
}
return typeByMime(type).icon;
}
39 changes: 30 additions & 9 deletions allure-report-face/src/util/attachmentType.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default function typeByMime(type) {
case 'image/png':
case 'image/*':
return {
type: 'image'
type: 'image',
icon: 'fa fa-file-image-o'
};
case 'text/xml':
case 'application/xml':
Expand All @@ -22,12 +23,14 @@ export default function typeByMime(type) {
case 'text/x-yaml':
return {
type: 'code',
icon: 'fa fa-file-code-o',
parser: d => d
};
case 'text/plain':
case 'text/*':
return {
type: 'text',
icon: 'fa fa-file-text-o',
parser: d => d
};
case 'text/html':
Expand All @@ -37,34 +40,52 @@ export default function typeByMime(type) {
case 'text/csv':
return {
type: 'table',
icon: 'fa fa-table',
parser: d => d3.csv.parseRows(d)
};
case 'text/tab-separated-values':
return {
type: 'table',
icon: 'fa fa-table',
parser: d => d3.tsv.parseRows(d)
};
case 'image/svg+xml':
return {
type: 'svg'
type: 'svg',
icon: 'fa fa-file-image-o'
};
case 'video/mp4':
case 'video/ogg':
case 'video/webm':
return {
type: 'video'
type: 'video',
icon: 'fa fa-file-video-o'
};
case 'text/uri-list':
return {
type: 'uri',
icon: 'fa fa-list-alt',
parser: d => d.split('\n')
.map(line => line.trim())
.filter(line => line.length > 0)
.map(line => ({
comment: line.startsWith('#'),
text: line
}))
.map(line => line.trim())
.filter(line => line.length > 0)
.map(line => ({
comment: line.startsWith('#'),
text: line
}))
};
case 'application/x-tar':
case 'application/x-gtar':
case 'application/x-bzip2':
case 'application/gzip':
case 'application/zip':
return {
type: 'archive',
icon: 'fa fa-file-archive-o'
};
default:
return {
type: null,
icon: 'fa fa-file-o'
};
}
}

0 comments on commit 091f64c

Please sign in to comment.