tests for hyperlink

This commit is contained in:
akshitasingh 2021-02-05 22:41:29 +05:30
parent 7b6285c761
commit d0802fa0ce
4 changed files with 1658 additions and 11 deletions

View File

@ -0,0 +1,17 @@
describe(__filename, function () {
it('Ensure multiple whitespaces are collapsed', function () {
const fixture = [
['tests'],
['2021-01-31https://www.google.com'],
['https://www.wikidata.org/wiki/Property:P670 https://www.wikidata.org/wiki/Property:P669 are now mapped to https://schema.org/streetAddress via https://www.wikidata.org/wiki/Property:P2235'],
['vhjhjjj https://github.com/OpenRefine/OpenRefine/issues/2519'],
]
cy.loadAndVisitProject(fixture)
cy.getCell(0,'tests').contains('2021-01-31https://www.google.com')
cy.getCell(1,'tests').children('div').children('a').should('have.attr','href');
cy.getCell(2,'tests').children('div').children('a').should('have.attr','href');
})
})

1607
main/tests/cypress/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
"test": "cypress run --browser electron --headless --quiet", "test": "cypress run --browser electron --headless --quiet",
"lint": "prettier --write .", "lint": "prettier --write .",
"check-lint": "prettier --check ." "check-lint": "prettier --check ."
}, },
"dependencies": { "dependencies": {
"cypress": "6.2.1", "cypress": "6.2.1",
"cypress-file-upload": "^5.0.2", "cypress-file-upload": "^5.0.2",

View File

@ -96,16 +96,39 @@ DataTableCellUI.prototype._render = function() {
nonstringSpan.className = 'data-table-value-nonstring'; nonstringSpan.className = 'data-table-value-nonstring';
nonstringSpan.textContent = cell.v; nonstringSpan.textContent = cell.v;
divContent.appendChild(nonstringSpan); divContent.appendChild(nonstringSpan);
} else if (URL.looksLikeUrl(cell.v)) { }
var url = document.createElement('a'); else{
url.textContent = cell.v; var arr = cell.v.split(" ");
url.setAttribute('href', cell.v); var spanArr =[];
url.setAttribute('target', '_blank'); for( var i=0;i<arr.length;i++){
divContent.appendChild(url); if(URL.looksLikeUrl(arr[i])){
} else { if(spanArr.length !=0 ){
var span = document.createElement('span'); var span = document.createElement('span');
span.textContent = cell.v; span.textContent = spanArr.join(" ");
divContent.appendChild(span); divContent.appendChild(span).appendChild(document.createTextNode('\u00A0'));
spanArr = [];
}
var url = document.createElement('a');
url.textContent = arr[i];
url.setAttribute('href', arr[i]);
url.setAttribute('target', '_blank');
divContent.appendChild(url);
if( i== arr.length-1){
divContent.appendChild(url)
}
else{
divContent.appendChild(url).appendChild(document.createTextNode('\u00A0'));
}
}
else{
spanArr.push(arr[i]);
}
}
if(spanArr.length !=0){
var span = document.createElement('span');
span.textContent = spanArr.join(" ");
divContent.appendChild(span);
}
} }
} else { } else {
var divContentRecon = $(divContent); var divContentRecon = $(divContent);