Skip to content

Commit 1389668

Browse files
committed
Delete and edit Annotations
1 parent 6620bda commit 1389668

7 files changed

Lines changed: 123 additions & 52 deletions

File tree

HTMLReport/preview.css

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ a.canvasjs-chart-credit {
2828
}
2929

3030
#export{
31-
clear:both;
31+
float:left;
32+
/*clear:both;*/
3233
margin-left:5px;
3334
margin-top: 4px;
3435
}
@@ -86,4 +87,28 @@ background: #F2F2F2;
8687
}
8788
.updatethVal{
8889
width: 100%;
90+
}
91+
.deleteBtn {
92+
width: 13px;
93+
}
94+
.deleteBtn:hover{
95+
cursor:pointer
96+
}
97+
#cancelDelete{
98+
margin-right: 8px;
99+
margin-left: 8px;
100+
}
101+
#divOverlay {
102+
display: none;
103+
background-color:lightcoral;
104+
text-align:center;
105+
position:absolute;
106+
z-index:10000;
107+
opacity:0.95;
108+
}
109+
#deleteDialog{
110+
margin-top: 8px;
111+
}
112+
#deleteDialog span{
113+
font-weight: bold;
89114
}

HTMLReport/preview.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,24 @@ <h1>Exploratory Session Report</h1>
3232
<div id="canvasHolder">
3333
<span>Graph</span>
3434
</div>
35-
</div>
36-
37-
</div>
35+
</div>
3836

37+
</div>
3938

4039
<div>
4140
<div id="sessionResults">
4241
<label>Data Table</label>
4342
</div>
44-
43+
44+
</div>
45+
<button id="export" class="actionButton" title="Get report in a plain HTML file">Export Session to HTML</button>
46+
<div id="divOverlay">
47+
<div id='deleteDialog'>
48+
<span>Delete this annotation?</span>
49+
<button id="cancelDelete" class="cancelButton" title="Cancel deletion">No</button>
50+
<button id="deleteYes" class="actionButton" title="Delete annotation">Yes</button>
51+
</div>
4552
</div>
46-
<button id="export" class="actionButton" title="Get report in a plain HTML file">Export Session to HTML</button>
4753
</body>
4854

4955
</html>

background.js

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
21
var session = new Session();
32

43
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
5-
switch(request.type) {
4+
switch (request.type) {
65
case "addBug":
7-
addAnnotation("Bug",request.name,request.imageURL);
6+
addAnnotation("Bug", request.name, request.imageURL);
87
break;
98
case "addIdea":
10-
addAnnotation("Idea",request.name,request.imageURL);
9+
addAnnotation("Idea", request.name, request.imageURL);
1110
break;
1211
case "addNote":
13-
addAnnotation("Note",request.name,request.imageURL);
12+
addAnnotation("Note", request.name, request.imageURL);
1413
break;
1514
case "addQuestion":
16-
addAnnotation("Question",request.name,request.imageURL);
15+
addAnnotation("Question", request.name, request.imageURL);
1716
break;
1817
case "updateAnnotationName":
1918
var AnnotationID = request.annotationID;
@@ -23,65 +22,75 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
2322
var annotation = annotations[AnnotationID];
2423
annotation.setName(newName);
2524

25+
break;
26+
case "deleteAnnotation":
27+
session.deleteAnnotation(request.annotationID);
2628
break;
2729
case "exportSessionCSV":
28-
if(!exportSessionCSV())
29-
sendResponse({status: "nothing to export"});
30+
if (!exportSessionCSV())
31+
sendResponse({
32+
status: "nothing to export"
33+
});
3034
break;
3135
case "clearSession":
3236
clearSession();
3337
break;
3438
}
35-
sendResponse({status: "ok"});
39+
sendResponse({
40+
status: "ok"
41+
});
3642
return true;
3743
});
3844

39-
function addAnnotation(type, name, imageURL){
45+
function addAnnotation(type, name, imageURL) {
4046

4147
var currentUrl;
4248
var now = Date.now();
4349

44-
if(session.getAnnotations().length == 0) this.startSession();
45-
46-
chrome.tabs.query({currentWindow: true, active: true},
47-
function(tabs){
48-
currentUrl = tabs[0].url;
49-
//alert(currentUrl);
50-
switch(type){
51-
case "Bug":
52-
var newBug = new Bug(name,currentUrl, now,imageURL);
53-
session.addBug(newBug);
54-
break;
55-
case "Note":
56-
var newNote = new Note(name,currentUrl, now,imageURL);
57-
session.addNote(newNote);
58-
break;
59-
case "Idea":
60-
var newIdea = new Idea(name,currentUrl, now,imageURL);
61-
session.addIdea(newIdea);
62-
break;
63-
case "Question":
64-
var newQuestion = new Question(name,currentUrl, now,imageURL);
65-
session.addQuestion(newQuestion);
66-
break;
67-
}
68-
});
50+
if (session.getAnnotations().length == 0) this.startSession();
51+
52+
chrome.tabs.query({
53+
currentWindow: true,
54+
active: true
55+
},
56+
function(tabs) {
57+
currentUrl = tabs[0].url;
58+
//alert(currentUrl);
59+
switch (type) {
60+
case "Bug":
61+
var newBug = new Bug(name, currentUrl, now, imageURL);
62+
session.addBug(newBug);
63+
break;
64+
case "Note":
65+
var newNote = new Note(name, currentUrl, now, imageURL);
66+
session.addNote(newNote);
67+
break;
68+
case "Idea":
69+
var newIdea = new Idea(name, currentUrl, now, imageURL);
70+
session.addIdea(newIdea);
71+
break;
72+
case "Question":
73+
var newQuestion = new Question(name, currentUrl, now, imageURL);
74+
session.addQuestion(newQuestion);
75+
break;
76+
}
77+
});
6978
}
7079

71-
function startSession(){
72-
var browser=get_browser_info();
80+
function startSession() {
81+
var browser = get_browser_info();
7382
var browserInfoString = browser.name + "_" + browser.version;
7483

75-
session = new Session(Date.now(),browserInfoString);
84+
session = new Session(Date.now(), browserInfoString);
7685
};
7786

78-
function clearSession(){
87+
function clearSession() {
7988
session.clearAnnotations();
8089
};
8190

82-
function exportSessionCSV(){
91+
function exportSessionCSV() {
8392

84-
if(session.getAnnotations().length == 0) return false;
93+
if (session.getAnnotations().length == 0) return false;
8594

8695
var exportService = new ExportSessionCSV(session);
8796
var csvData = exportService.getCSVData();
@@ -94,10 +103,11 @@ function exportSessionCSV(){
94103
var fileName = "ExploratorySession_" + browserInfo + "_" + startDateTime + ".csv";
95104

96105
var pom = document.createElement('a');
97-
var blob = new Blob([csvData],{type: 'text/csv;charset=utf-8;'});
106+
var blob = new Blob([csvData], {
107+
type: 'text/csv;charset=utf-8;'
108+
});
98109
var url = URL.createObjectURL(blob);
99110
pom.href = url;
100111
pom.setAttribute('download', fileName);
101112
pom.click();
102-
};
103-
113+
};

images/delete84.png

381 Bytes
Loading

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"short_name": "Chrome Exploratory Testing",
55
"description": "Exploratory testing session using Chrome",
66
"author": "@morvader",
7-
"version": "1.0.5",
7+
"version": "1.1.0",
88
"icons": {
99
"16": "/icons/iconbig.png",
1010
"48": "/icons/iconbig.png",

src/Session.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ Session.prototype.setAnnotations = function(newAnnotations) {
2121
this.annotations = newAnnotations;
2222
};
2323

24+
Session.prototype.deleteAnnotation = function(annotationID) {
25+
if (annotationID > -1) {
26+
this.annotations.splice(annotationID, 1);
27+
}
28+
};
29+
2430
Session.prototype.getAnnotations = function() {
2531
return this.annotations;
2632
};

test/spec/ExploratorySessionSpec.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("Exploratory Session", function() {
1515

1616
});
1717

18-
describe("shloud store annotations: bugs, ideas, questions and notes", function() {
18+
describe("should manage annotations: bugs, ideas, questions and notes", function() {
1919

2020
var session;
2121

@@ -177,6 +177,30 @@ describe("Exploratory Session", function() {
177177

178178
});
179179

180+
it("session annotaitons can be deleted", function() {
181+
182+
session.addBug(new Bug("Add Bug"));
183+
session.addIdea(new Idea("Add Idea"));
184+
session.addNote(new Note("Add Note"));
185+
session.addQuestion(new Question("Add Question"));
186+
187+
var annotations = session.getAnnotations();
188+
189+
expect(annotations.length).toEqual(4);
190+
191+
session.deleteAnnotation(1);
192+
193+
annotations = session.getAnnotations();
194+
195+
expect(annotations.length).toEqual(3);
196+
197+
expect(annotations[0].getName()).toEqual("Add Bug");
198+
expect(annotations[1].getName()).toEqual("Add Note");
199+
expect(annotations[2].getName()).toEqual("Add Question");
200+
201+
202+
});
203+
180204
});
181205

182206
});

0 commit comments

Comments
 (0)