Skip to content

Commit

Permalink
Merge pull request #68 from DCMLab/fix_css_tests_old_code
Browse files Browse the repository at this point in the history
Fix css tests old code
  • Loading branch information
pettter authored Mar 17, 2021
2 parents cb13ae8 + 71b0bd7 commit 2424052
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 92 deletions.
8 changes: 4 additions & 4 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('reductive_analysis_test_suite', () => {
// Confirm that the selected note has been styled accordingly.
// (I *think* that Jest-Puppeteer does not provide async monitoring of global state,
// so checking for DOM changes before global state seems generally prudent. This might be worth revisiting.)
await expect(page).toMatchElement(svg_first_note_selector + `[style*="fill: green;"]`);
await expect(page).toMatchElement(svg_first_note_selector + `[class*="selectednote"]`);

// Confirm that the selected note has been added to the `selected` array.
await expect(page.evaluate(`$(selected[0]).attr('id')`)).resolves.toEqual(svg_first_note_id);
Expand All @@ -165,7 +165,7 @@ describe('reductive_analysis_test_suite', () => {
await expect(page).toClick(svg_first_notehead_selector);

// Confirm that the selected note has been styled accordingly.
await expect(page).toMatchElement(svg_first_note_selector + `[style*="fill: black;"]`);
await expect(page).toMatchElement(svg_first_note_selector + `:not([class*="selectednote"])`);

// Confirm that the selected note has been added to the `selected` array.
await expect(page.evaluate(`$(selected[0]).attr('id')`)).resolves.toBeFalsy();
Expand All @@ -188,7 +188,7 @@ describe('reductive_analysis_test_suite', () => {
// Confirm that the selected note has been styled accordingly.
// (I *think* that Jest-Puppeteer does not provide async monitoring of global state,
// so checking for DOM changes before global state seems generally prudent. This might be worth revisiting.)
await expect(page).toMatchElement(svg_first_note_selector + `[style*="fill: red;"]`);
await expect(page).toMatchElement(svg_first_note_selector + `[class*="extraselectednote"]`);

// Confirm that the selected note has been added to the `selected` array.
await expect(page.evaluate(`$(extraselected[0]).attr('id')`)).resolves.toEqual(svg_first_note_id);
Expand All @@ -200,7 +200,7 @@ describe('reductive_analysis_test_suite', () => {
await page.keyboard.up('Shift');

// Confirm that the selected note has been styled accordingly.
await expect(page).toMatchElement(svg_first_note_selector + `[style*="fill: black;"]`);
await expect(page).toMatchElement(svg_first_note_selector + `:not([class*="extraselectednote"])`);

// Confirm that the selected note has been added to the `selected` array.
await expect(page.evaluate(`$(extraselected[0]).attr('id')`)).resolves.toBeFalsy();
Expand Down
84 changes: 8 additions & 76 deletions js/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function draw_relation(id,type) {
elem.setAttribute("id",id);
elem.classList.add("relation");
elem.setAttribute("type",type);
// elem.style.fillOpacity = "0.5";
elem.onwheel = (e) => {
var elem1 = e.target;
var paren = elem1.parentElement;
Expand All @@ -57,31 +56,12 @@ function draw_relation(id,type) {
added.push(elem);
elem.onclick = function(ev) {toggle_selected(elem,ev.shiftKey);};
elem.onmouseover = function (ev) {

primaries.forEach((item) => { item.classList.add("extrahover");});
/* if(item.style.filter == ""){
item.style.transform = "translate3d(0,0,0)";
item.style.filter = "url(\"#extraFilter\")";
}});*/
secondaries.forEach((item) => { item.classList.add("selecthover");});
/* if(item.style.filter == ""){
item.style.transform = "translate3d(0,0,0)";
item.style.filter = "url(\"#selectFilter\")";
}});*/
}
elem.onmouseout = function (ev) {
primaries.forEach((item) => { item.classList.remove("extrahover");});
/* primaries.forEach((item) => {
if(item.style.filter == "url(\"#extraFilter\")") {
item.style.transform = "";
item.style.filter = "";
}});*/
secondaries.forEach((item) => { item.classList.remove("selecthover");});
/* secondaries.forEach((item) => {
if(item.style.filter == "url(\"#selectFilter\")") {
item.style.transform = "";
item.style.filter = "";
}});*/
}

return added;
Expand All @@ -103,8 +83,6 @@ function draw_metarelation(id,type) {
g_elem.setAttribute("id",id);
g_elem.classList.add("metarelation");
g_elem.setAttribute("type",type);
/* g_elem.style.fillOpacity = "0.5";
g_elem.style.strokeOpacity = "0.1";*/
g_elem.onwheel = (e) => {
var elem1 = e.target;
var paren = elem1.parentElement;
Expand All @@ -121,21 +99,10 @@ function draw_metarelation(id,type) {
added.push(g_elem);
g_elem.onclick = function(ev) {toggle_selected(g_elem,ev.shiftKey);};
g_elem.onmouseover = function (ev) {

targets.forEach((item) => {
item.classList.add("relationhover");
/* if(item.style.filter == ""){
item.style.transform = "translate3d(0,0,0)";
item.style.filter = "url(\"#glowFilter\")";
}*/});
targets.forEach((item) => { item.classList.add("relationhover"); });
}
g_elem.onmouseout = function (ev) {
targets.forEach((item) => {
item.classList.remove("relationhover");
/* if(item.style.filter == "url(\"#glowFilter\")") {
item.style.transform = "";
item.style.filter = "";
}*/});
targets.forEach((item) => { item.classList.remove("relationhover"); });
}
return added;

Expand Down Expand Up @@ -164,7 +131,6 @@ function draw_relation_arg(draw_context, mei_graph, g_elem) {
elem.setAttribute("id",id);
elem.classList.add("relation");
elem.setAttribute("type",type);
// elem.style.fillOpacity = "0.5";
elem.onwheel = (ev) => {
var elem1 = ev.target;
flip_to_bg(elem1);
Expand All @@ -177,33 +143,12 @@ function draw_relation_arg(draw_context, mei_graph, g_elem) {
added.push(elem);
elem.onclick = function(ev) {toggle_selected(elem,ev.shiftKey);};
elem.onmouseover = function (ev) {

primaries.forEach((item) => {
item.classList.add("extrahover");
/* if(item.style.filter == ""){
item.style.transform = "translate3d(0,0,0)";
item.style.filter = "url(\"#extraFilter\")";
}*/});
secondaries.forEach((item) => {
item.classList.add("selecthover");
/* if(item.style.filter == ""){
item.style.transform = "translate3d(0,0,0)";
item.style.filter = "url(\"#selectFilter\")";
}*/});
primaries.forEach( (item) => { item.classList.add("extrahover"); });
secondaries.forEach((item) => { item.classList.add("selecthover"); });
}
elem.onmouseout = function (ev) {
primaries.forEach((item) => {
item.classList.remove("extrahover");
/* if(item.style.filter == "url(\"#extraFilter\")") {
item.style.transform = "";
item.style.filter = "";
}*/});
secondaries.forEach((item) => {
item.classList.remove("selecthover");
/* if(item.style.filter == "url(\"#selectFilter\")") {
item.style.transform = "";
item.style.filter = "";
}*/});
primaries.forEach( (item) => { item.classList.remove("extrahover"); });
secondaries.forEach((item) => { item.classList.remove("selecthover"); });
}
//TODO: Set up more onhover stuff for The Same Relation
//Elsewhere - but perhaps that's a separate thing?
Expand Down Expand Up @@ -232,8 +177,6 @@ function draw_metarelation_arg(draw_context, mei_graph, g_elem) {
g_elem.setAttribute("id",id);
g_elem.classList.add("metarelation");
g_elem.setAttribute("type",type);
// elem.style.fillOpacity = "0.5";
// elem.style.strokeOpacity = "0.1";
g_elem.onwheel = (e) => {
var elem1 = e.target;
var paren = elem1.parentElement;
Expand All @@ -250,21 +193,10 @@ function draw_metarelation_arg(draw_context, mei_graph, g_elem) {
added.push(g_elem);
elem.onclick = function(ev) {toggle_selected(g_elem,ev.shiftKey);};
g_elem.onmouseover = function (ev) {

targets.forEach((item) => {
item.classList.add("relationhover");
/* if(item.style.filter == ""){
item.style.transform = "translate3d(0,0,0)";
item.style.filter = "url(\"#glowFilter\")";
}*/});
targets.forEach((item) => { item.classList.add("relationhover"); });
}
g_elem.onmouseout = function (ev) {
targets.forEach((item) => {
item.classList.remove("relationhover");
/* if(item.style.filter == "url(\"#glowFilter\")") {
item.style.transform = "";
item.style.filter = "";
}*/});
targets.forEach((item) => { item.classList.remove("relationhover"); });
}
return added;
}
12 changes: 0 additions & 12 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,29 +177,17 @@ function toggle_selected(item,extra) {
toggle_he_selected(true);
}
if(selected.find(x => x === item) || extraselected.find(x => x === item)) {
// item.style.fillOpacity = 0.5;
// item.style.strokeOpacity = 0.1;
item.classList.remove("extraselectedrelation");
item.classList.remove("selectedrelation");
selected = selected.filter(x => x !== item);
extraselected = extraselected.filter(x => x !== item);
// item.style.transform = "";
// item.style.filter = "";
} else {
if(extra){
item.classList.add("extraselectedrelation");
// item.style.fillOpacity = 0.9;
// item.style.strokeOpacity = 0.8;
extraselected.push(item);
// item.style.transform = "translate3d(0,0,0)";
// item.style.filter = "url(\"#extraFilter\")";
}else{
item.classList.add("selectedrelation");
// item.style.fillOpacity = 0.9;
// item.style.strokeOpacity = 0.8;
selected.push(item);
// item.style.transform = "translate3d(0,0,0)";
// item.style.filter = "url(\"#selectFilter\")";
}
}
if(selected.concat(extraselected).length == 0){
Expand Down

0 comments on commit 2424052

Please sign in to comment.