Skip to content

Commit

Permalink
Merge pull request #20 from unfoldingWord/RJHimprovements
Browse files Browse the repository at this point in the history
Upgrade packages; start looking at cypress tests
  • Loading branch information
RobH123 authored Sep 8, 2020
2 parents 01e8484 + de1f092 commit 5df8c37
Show file tree
Hide file tree
Showing 12 changed files with 1,315 additions and 1,061 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('Content Checker Basic Tests', function () {
describe('uW Content Validation Basic Tests', function () {
before(() => {
cy.visit('/')
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('Content Checker Repository Tests', function () {
describe('uW Content Validation Repository Tests', function () {
before(() => {
cy.visit('/')
})
Expand Down
9 changes: 6 additions & 3 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module.exports = (on, config) => {
on('task', require('@cypress/code-coverage/task'))
on('file:preprocessor', require('@cypress/code-coverage/use-browserify-istanbul'))
return config;
require('@cypress/code-coverage/task')(on, config)
on(
'file:preprocessor',
require('@cypress/code-coverage/use-browserify-istanbul')
)
return config
}
32 changes: 17 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"scripts": {
"build": "react-scripts build",
"prepublishOnly": "rm -fr ./dist & babel ./src --out-dir ./dist -s inline",
"predeploy": "yarn styleguide:build",
"deploy": "gh-pages -d styleguide",
"postpublish": "yarn deploy",
"start": "styleguidist server",
"styleguide:build": "styleguidist build",
"cypress:open": "cypress open",
Expand All @@ -25,12 +27,11 @@
"create-coverage-badge": "bash scripts/create-badge-json.sh"
},
"dependencies": {
"@date-io/core": "^1.3.6",
"@date-io/core": "^2.9.0",
"@material-ui/core": "^4.5.1",
"@material-ui/icons": "^4.5.1",
"axios": "^0.18.1",
"axios": "^0.20.0",
"axios-cache-adapter": "^2.5.0",
"cypress": "3.8.3",
"js-yaml-parser": "^1.0.0",
"jszip": "^3.2.0",
"localforage": "^1.7.3",
Expand All @@ -42,27 +43,28 @@
"react-dom": "^16.9.0",
"react-markdown": "^4.0.6",
"react-scripts": "^3.4.1",
"react-styleguidist": "^9.1.14",
"react-styleguidist": "^11.0.10",
"usfm-grammar": "^2.0.0-beta.4",
"usfm-js": "^2.1.0",
"yaml": "^1.10.0"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@babel/preset-env": "^7.11.5",
"@babel/preset-react": "^7.0.0",
"@cypress/code-coverage": "^1.10.2",
"@cypress/code-coverage": "^3.8.1",
"babel-loader": "^8.0.6",
"babel-plugin-istanbul": "^5.2.0",
"cross-env": "^6.0.3",
"css-loader": "^3.2.0",
"file-loader": "^4.2.0",
"gh-pages": "^2.0.1",
"istanbul-lib-coverage": "^2.0.5",
"markdown-translatable": "^0.11.0",
"nyc": "^14.1.1",
"babel-plugin-istanbul": "^6.0.0",
"cross-env": "^7.0.2",
"css-loader": "^4.2.2",
"cypress": "^5.1.0",
"file-loader": "^6.1.0",
"gh-pages": "^3.1.0",
"istanbul-lib-coverage": "^3.0.0",
"markdown-translatable": "^1.0.3",
"nyc": "^15.1.0",
"start-server-and-test": "^1.10.6",
"style-loader": "^1.0.0",
"webpack": "^4.39.1"
Expand Down
4 changes: 0 additions & 4 deletions src/core/annotation-row-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,6 @@ async function checkAnnotationTSVDataRow(annotationType, line, bookID, C, V, giv
}
const haveBibleBookID = numChaptersThisBook !== undefined;

// let inString;
// if (rowLocation) inString = rowLocation;
// else inString = ` in line ${rowNumber.toLocaleString()}`;

let fields = line.split('\t');
if (fields.length === NUM_EXPECTED_TSV_FIELDS) {
const [reference, fieldID, tags, supportReference, quote, occurrence, annotation] = fields;
Expand Down
5 changes: 2 additions & 3 deletions src/core/markdown-text-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ function checkMarkdownText(textName, markdownText, givenLocation, optionalChecki
let lastNumLeadingSpaces = 0;
let lastLineContents;
for (let n = 1; n <= lines.length; n++) {
const atString = ` in line ${n.toLocaleString()}${ourLocation}`;

const line = lines[n - 1];
let numLeadingSpaces;
Expand All @@ -140,14 +139,14 @@ function checkMarkdownText(textName, markdownText, givenLocation, optionalChecki
const thisHeaderLevel = line.match(/^#*/)[0].length;
// console.log(`Got thisHeaderLevel=${thisHeaderLevel} for ${line}${atString}`);
if (thisHeaderLevel > headerLevel + 1)
addNotice6({priority:172, message:"Header levels should only increment by one", lineNumber:n, characterIndex:0, location:atString});
addNotice6({priority:172, message:"Header levels should only increment by one", lineNumber:n, characterIndex:0, location:ourLocation});
if (thisHeaderLevel > 0)
headerLevel = thisHeaderLevel;

numLeadingSpaces = line.match(/^ */)[0].length;
// console.log(`Got numLeadingSpaces=${numLeadingSpaces} for ${line}${atString}`);
if (numLeadingSpaces && lastNumLeadingSpaces && numLeadingSpaces !== lastNumLeadingSpaces)
addNotice6({priority:472, message:"Nesting seems confused", lineNumber:n, characterIndex:0, location:atString});
addNotice6({priority:472, message:"Nesting seems confused", lineNumber:n, characterIndex:0, location:ourLocation});

checkMarkdownLineContents(`line ${n.toLocaleString()}`, line, ourLocation);
} else {
Expand Down
1 change: 0 additions & 1 deletion src/core/plain-text-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ function checkPlainText(textName, plainText, givenLocation, optionalCheckingOpti
let lastNumLeadingSpaces = 0;
let lastLineContents;
for (let n= 1; n <= lines.length; n++) {
const atString = ` in line ${n.toLocaleString()}${ourLocation}`;

const line = lines[n - 1];
if (line) {
Expand Down
4 changes: 0 additions & 4 deletions src/core/tn-table-row-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,6 @@ async function checkTN_TSVDataRow(line, bookID, C, V, givenRowLocation, optional
}
const haveGoodBookID = numChaptersThisBook !== undefined;

// let inString;
// if (rowLocation) inString = rowLocation;
// else inString = ` in line ${rowNumber.toLocaleString()}`;

let fields = line.split('\t');
if (fields.length === NUM_EXPECTED_TSV_FIELDS) {
const [B, C, V, fieldID, supportReference, origQuote, occurrence, GLQuote, occurrenceNote] = fields;
Expand Down
1 change: 0 additions & 1 deletion src/core/yaml-text-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ function checkYAMLText(textName, YAMLText, givenLocation, optionalCheckingOption
let lastNumLeadingSpaces = 0;
let lastLineContents;
for (let n= 1; n <= lines.length; n++) {
const atString = ` in line ${n.toLocaleString()}${ourLocation}`;

const line = lines[n - 1];
// let numLeadingSpaces;
Expand Down
16 changes: 7 additions & 9 deletions src/demos/RenderProcessedResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function RenderLines({ text }) {
}


const MAX_ARRAY_ITEMS_TO_DISPLAY = 10;
const MAX_ARRAY_ITEMS_TO_DISPLAY = 8; // Or do we want this as a parameter?
export function RenderObject({ thisObject, excludeList }) {
/**
* @description - Displays whatever is in the object
Expand All @@ -60,7 +60,7 @@ export function RenderObject({ thisObject, excludeList }) {
if (!excludeList || excludeList.indexOf(key) < 0) {
let displayObject = thisObject[key];
if (Array.isArray(displayObject) && displayObject.length > MAX_ARRAY_ITEMS_TO_DISPLAY)
displayObject = `(only first ${MAX_ARRAY_ITEMS_TO_DISPLAY} displayed here) ${JSON.stringify(displayObject.slice(0,MAX_ARRAY_ITEMS_TO_DISPLAY))}, etc…`;
displayObject = `(only first ${MAX_ARRAY_ITEMS_TO_DISPLAY} displayed here) ${JSON.stringify(displayObject.slice(0, MAX_ARRAY_ITEMS_TO_DISPLAY))}, etc…`;
return (
<li key={keyIndex}>&nbsp;&nbsp;&nbsp;&nbsp;
<span><b>{key}</b>{Array.isArray(thisObject[key]) ? ` (${thisObject[key].length.toLocaleString()}) ` : ''}: {typeof displayObject === 'object' ? JSON.stringify(displayObject) : displayObject}</span>
Expand Down Expand Up @@ -105,14 +105,14 @@ export function RenderRawResults({ results }) {
// If we get here, we have notices.
// console.log(`Got ${results.noticeList.length} notices`);

// Discover what fields we have in our notice objects
// Discover what fields we have in our notice objects (in order to set our table headers below)
const allPropertiesSet = new Set();
let haveOBS = false, haveBible = false;
// console.log( "allPropertiesSet-A", JSON.stringify([...allPropertiesSet]));
results.noticeList.map(function (noticeEntry) {
for (const noticeEntry of results.noticeList)
// console.log("noticeEntry", JSON.stringify(noticeEntry));
// console.log(`Found (${Object.keys(noticeEntry).length}) ${Object.keys(noticeEntry)}`);
Object.entries(noticeEntry).map(function ([noticePropertyName, noticePropertyValue]) {
for (const [noticePropertyName, noticePropertyValue] of Object.entries(noticeEntry))
// console.log(" Found", noticePropertyName, "=", noticeEntry[noticePropertyName]);
if (noticePropertyValue !== undefined) {
allPropertiesSet.add(noticePropertyName);
Expand All @@ -121,11 +121,9 @@ export function RenderRawResults({ results }) {
else haveBible = true;
}
}
});
});
// console.log( "allPropertiesSet-Z", JSON.stringify([...allPropertiesSet]));

// Adjust the headers according to the column sets that we actually have
// Adjust the headers according to the column sets that we actually have in the noticeList
let headerData = [
{ title: 'Priority', field: 'priority', type: 'numeric' },
{ title: 'Message', field: 'message' },
Expand Down Expand Up @@ -156,7 +154,7 @@ export function RenderRawResults({ results }) {
<RenderObject thisObject={results} />
<MaterialTable
// icons={tableIcons}
title='Raw Notices'
title={`All ${results.noticeList.length.toLocaleString()} Raw Notices`}
columns={headerData}
data={results.noticeList}
options={{ sorting: true, exportButton: true, exportAllData: true }}
Expand Down
5 changes: 3 additions & 2 deletions src/demos/file-check/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ and then validates the content of one file selected from the repo.
// If we don't put the branch here, the default branch is used
// branch='master'

// Of course, the filename must be correct for the chosen repository
// filename= '01-GEN.usfm' // e.g., for UHB, ULT, or UST
// filename= '08-RUT.usfm' // e.g., for UHB, ULT, or UST
// filename= '41-MAT.usfm' // e.g., for UGNT, ULT, or UST
// filename= '42-MRK.usfm' // e.g., for UGNT, ULT, or UST
// filename= '45-ACT.usfm' // e.g., for UGNT, ULT, or UST
// filename= '48-2CO.usfm' // e.g., for UGNT, ULT, or UST
// filename= '50-EPH.usfm' // e.g., for UGNT, ULT, or UST
filename= '65-3JN.usfm' // e.g., for UGNT, ULT, or UST
filename= '50-EPH.usfm' // e.g., for UGNT, ULT, or UST
// filename= '65-3JN.usfm' // e.g., for UGNT, ULT, or UST
// filename= '67-REV.usfm' // e.g., for UGNT, ULT, or UST
// filename= 'en_tn_01-GEN.tsv' // for TN
// filename= 'en_tn_16-NEH.tsv' // for TN
Expand Down
Loading

0 comments on commit 5df8c37

Please sign in to comment.