Skip to content

Commit 917f8e8

Browse files
Merge pull request #84 from aquality-automation/Bug/36-table-export-with-special-symbols
Bug/36 table export with special symbols
2 parents 1eb511f + 8a66083 commit 917f8e8

File tree

8 files changed

+164
-14
lines changed

8 files changed

+164
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Features:
77
- Test Run view: Add stability indicator -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/60)
88

99
Bugfixes:
10+
- Csv export with special symbols -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/36)
1011

1112
## 0.3.5 (2020-02-15)
1213

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Test Name,Fail Reason,Last Results,Result,Resolution,Assignee,Comment
2+
"Test Feature with all results: step failed","step was failed !”#$%&’()*+,-./:;<=>?@[\]^_`{|}~","","Failed","Not Assigned",,
3+
"Test Feature with all results: All passed","","","Passed",,,
4+
"Test Feature with all results: Step skipped","step was skippedstep was skipped","","Pending","Not Assigned",,
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
[
2+
{
3+
"description": "Test Report",
4+
"keyword": "Feature",
5+
"name": "Test Feature with all results",
6+
"line": 2,
7+
"id": "Test-Report",
8+
"tags": [],
9+
"uri": "features/testdeature.feature",
10+
"elements": [
11+
{
12+
"id": "passed",
13+
"keyword": "Scenario",
14+
"line": 7,
15+
"name": "All passed",
16+
"tags": [],
17+
"type": "scenario",
18+
"steps": [
19+
{
20+
"arguments": [],
21+
"keyword": "Given ",
22+
"line": 8,
23+
"name": "passed step",
24+
"match": {
25+
"location": "Projects/nodejs-cucumber-sample-master/node_modules/cucumber/lib/support_code_library_builder/define_helpers.js:135"
26+
},
27+
"result": {
28+
"status": "passed",
29+
"duration": 7033
30+
}
31+
},
32+
{
33+
"arguments": [],
34+
"keyword": "Then ",
35+
"line": 9,
36+
"name": "passed step",
37+
"match": {
38+
"location": "Projects/nodejs-cucumber-sample-master/node_modules/cucumber/lib/support_code_library_builder/define_helpers.js:135"
39+
},
40+
"result": {
41+
"status": "passed",
42+
"duration": 86
43+
}
44+
}
45+
]
46+
}, {
47+
"id": "failed",
48+
"keyword": "Scenario",
49+
"line": 7,
50+
"name": "step failed",
51+
"tags": [],
52+
"type": "scenario",
53+
"steps": [
54+
{
55+
"arguments": [],
56+
"keyword": "Given ",
57+
"line": 8,
58+
"name": "passed step",
59+
"match": {
60+
"location": "Projects/nodejs-cucumber-sample-master/node_modules/cucumber/lib/support_code_library_builder/define_helpers.js:135"
61+
},
62+
"result": {
63+
"status": "passed",
64+
"duration": 7033
65+
}
66+
},
67+
{
68+
"arguments": [],
69+
"keyword": "Then ",
70+
"line": 9,
71+
"name": "failed step",
72+
"match": {
73+
"location": "Projects/nodejs-cucumber-sample-master/node_modules/cucumber/lib/support_code_library_builder/define_helpers.js:135"
74+
},
75+
"result": {
76+
"status": "failed",
77+
"duration": 86,
78+
"error_message": "step was failed !”#$%&’()*+,-./:;<=>?@[\\]^_`{|}~"
79+
}
80+
}
81+
]
82+
}, {
83+
"id": "failed",
84+
"keyword": "Scenario",
85+
"line": 7,
86+
"name": "Step skipped",
87+
"tags": [],
88+
"type": "scenario",
89+
"steps": [
90+
{
91+
"arguments": [],
92+
"keyword": "Given ",
93+
"line": 8,
94+
"name": "passed step",
95+
"match": {
96+
"location": "Projects/nodejs-cucumber-sample-master/node_modules/cucumber/lib/support_code_library_builder/define_helpers.js:135"
97+
},
98+
"result": {
99+
"status": "passed",
100+
"duration": 7033
101+
}
102+
},
103+
{
104+
"arguments": [],
105+
"keyword": "Then ",
106+
"line": 9,
107+
"name": "skipped step",
108+
"match": {
109+
"location": "Projects/nodejs-cucumber-sample-master/node_modules/cucumber/lib/support_code_library_builder/define_helpers.js:135"
110+
},
111+
"result": {
112+
"status": "skipped",
113+
"duration": 86,
114+
"error_message": "step was skipped"
115+
}
116+
}
117+
]
118+
}
119+
]
120+
}
121+
]

e2e/pages/testrun/view.po/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class TestRunView extends BasePage {
182182
return +(url.match(regexp)[1]);
183183
}
184184

185-
checkIfTableEqualToCSv(path: string): Promise<{ result: boolean, message: string }> {
185+
checkIfTableEqualToCSV(path: string): Promise<{ result: boolean, message: string }> {
186186
return elements.resultsTable.checkIfTableEqualToCSv(path);
187187
}
188188
}

e2e/specs/import/importNunit3.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('Import Test Run: Nunit V3', () => {
8383
await testRunList.openTestRun(featureName.buildName);
8484
await testRunView.sortResultsByName();
8585

86-
const tableComparisonResult = await testRunView.checkIfTableEqualToCSv('/resultsTable/nunitV3FeatureName.csv');
86+
const tableComparisonResult = await testRunView.checkIfTableEqualToCSV('/resultsTable/nunitV3FeatureName.csv');
8787
return expect(tableComparisonResult.result).toBe(true, tableComparisonResult.message);
8888
});
8989

@@ -109,7 +109,7 @@ describe('Import Test Run: Nunit V3', () => {
109109
await testRunList.openTestRun(className.buildName);
110110
await testRunView.sortResultsByName();
111111

112-
const tableComparisonResult = await testRunView.checkIfTableEqualToCSv('/resultsTable/nunitV3ClassName.csv');
112+
const tableComparisonResult = await testRunView.checkIfTableEqualToCSV('/resultsTable/nunitV3ClassName.csv');
113113
return expect(tableComparisonResult.result).toBe(true, tableComparisonResult.message);
114114
});
115115
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { logIn } from '../../pages/login.po';
2+
import { projectView } from '../../pages/project/view.po';
3+
import { testRunView } from '../../pages/testrun/view.po';
4+
import { testRunList } from '../../pages/testrun/list.po';
5+
import { ProjectHelper } from '../../helpers/project.helper';
6+
import users from '../../data/users.json';
7+
import cucumberImport from '../../data/import/cucumberSpecialSymbols.json';
8+
9+
describe('TestRun view manual:', () => {
10+
const projectHelper: ProjectHelper = new ProjectHelper();
11+
const builds = projectHelper.generateBuilds(1);
12+
13+
beforeAll(async () => {
14+
await projectHelper.init();
15+
await projectHelper.importer.executeCucumberImport('test', [cucumberImport], builds.filenames)[0];
16+
await logIn.logInAs(users.admin.user_name, users.admin.password);
17+
await projectHelper.openProject();
18+
await projectView.menuBar.testRuns();
19+
return testRunList.openTestRun(builds.names.build_1);
20+
});
21+
22+
afterAll(async () => {
23+
return projectHelper.dispose();
24+
});
25+
26+
it('Can download test run as csv with special symbols', async () => {
27+
const tableComparisonResult = await testRunView.checkIfTableEqualToCSV('/expected/testRunSpecialSymbols.csv');
28+
return expect(tableComparisonResult.result).toBe(true, tableComparisonResult.message);
29+
});
30+
});

e2e/utils/aqualityTrackingAPI.util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ const serializeToQueryString = (object: object) => {
2020
return '';
2121
}
2222
const str = [];
23-
for (const proprty in object) {
24-
if (object.hasOwnProperty(proprty)) {
25-
str.push(encodeURIComponent(proprty) + '=' + encodeURIComponent(object[proprty]));
23+
for (const property in object) {
24+
if (object.hasOwnProperty(property)) {
25+
str.push(encodeURIComponent(property) + '=' + encodeURIComponent(object[property]));
2626
}
2727
}
2828
return `?${str.join('&')}`;

src/app/elements/table/table.filter.component.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -586,16 +586,10 @@ export class TableFilterComponent implements OnInit, AfterViewInit, OnDestroy, O
586586

587587
downloadCSV() {
588588
let data: string, filename: string, link: HTMLAnchorElement;
589-
let csv = this.getCSV();
589+
const csv = this.getCSV();
590590
if (csv === null) { return; }
591-
592591
filename = `export${Date.now()}.csv`;
593-
594-
if (!csv.match(/^data:text\/csv/i)) {
595-
csv = 'data:text/csv;charset=utf-8,' + csv;
596-
}
597-
data = encodeURI(csv);
598-
592+
data = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv);
599593
link = document.createElement('a');
600594
document.body.appendChild(link);
601595
link.setAttribute('type', 'hidden');

0 commit comments

Comments
 (0)