Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with repoCode for linked articles; add test for newLine in TN single line field that crashed tC build #206

Merged
merged 4 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
476 changes: 245 additions & 231 deletions noticeList.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "uw-content-validation",
"description": "Functions for Checking Door43.org Scriptural Content/Resources.",
"version": "2.2.1",
"version": "2.2.2",
"private": false,
"homepage": "https://unfoldingword.github.io/uw-content-validation/",
"repository": {
Expand Down
31 changes: 31 additions & 0 deletions src/__tests__/__snapshots__/tn-tsv7-table-row-check.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,37 @@ Object {
}
`;

exports[`checkNotesTSV7DataRow() - should find invalid newline in single-line field 1`] = `
Object {
"noticeList": Array [
Object {
"C": "1",
"V": "2",
"bookID": "GEN",
"characterIndex": 15,
"excerpt": "…imperative\\\\n",
"fieldName": "GLQuote",
"location": " from test line",
"message": "Unexpected line break in single-line field",
"priority": 971,
"rowID": "v7qw",
},
Object {
"C": "1",
"V": "2",
"bookID": "GEN",
"details": "SR='figs-imperative\\\\n'",
"excerpt": "figs-imperative",
"fieldName": "OccurrenceNote",
"location": " from test line",
"message": "Should have a SupportReference when Note has a TA link",
"priority": 789,
"rowID": "v7qw",
},
],
}
`;

exports[`checkNotesTSV7DataRow() - should find language code instead of asterisk 1`] = `
Object {
"noticeList": Array [
Expand Down
45 changes: 45 additions & 0 deletions src/__tests__/__snapshots__/tn-tsv9-table-row-check.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,51 @@ Object {
}
`;

exports[`checkTN_TSV9DataRow() - should find invalid newline in single-line field 1`] = `
Object {
"noticeList": Array [
Object {
"C": "1",
"V": "2",
"bookID": "GEN",
"characterIndex": 15,
"excerpt": "…imperative<br>",
"fieldName": "SupportReference",
"location": " from test line",
"message": "Unexpected line break in single-line field",
"priority": 971,
"rowID": "v7qw",
},
Object {
"C": "1",
"V": "2",
"bookID": "GEN",
"characterIndex": 90,
"excerpt": "…e: [[rc://*/ta/man/t…",
"fieldName": "OccurrenceNote",
"lineNumber": 1,
"location": " from test line",
"message": "tC cannot yet process '*' language code",
"priority": 950,
"repoCode": "TN",
"rowID": "v7qw",
},
Object {
"C": "1",
"V": "2",
"bookID": "GEN",
"details": "SR='figs-imperative<br>'",
"excerpt": "figs-imperative",
"fieldName": "OccurrenceNote",
"location": " from test line",
"message": "Should have a SupportReference when OccurrenceNote has a TA link",
"priority": 789,
"rowID": "v7qw",
},
],
}
`;

exports[`checkTN_TSV9DataRow() - should find language code instead of asterisk -- disabled 1`] = `
Object {
"noticeList": Array [],
Expand Down
9 changes: 8 additions & 1 deletion src/__tests__/tn-tsv7-table-row-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,17 @@ describe('checkNotesTSV7DataRow() - ', () => {
expect(rawResults).toMatchSnapshot();
});

it('should find invalid newline in single-line field', async () => {
const chosenLine = "1:2\tv7qw\t\tfigs-imperative\\n\tוְ⁠חֹ֖שֶׁךְ\t1\tThis is a command. By commanding that light should exist, God made it exist. (See: [[rc://*/ta/man/translate/figs-imperative]])";
const rawResults = await checkNotesTSV7DataRow(languageCode, repoCode, chosenLine, 'GEN', '1', '2', 'from test line', optionalCheckingOptions);
expect(rawResults.noticeList.length).toBeGreaterThanOrEqual(2);
expect(rawResults).toMatchSnapshot();
});

it('should be valid', async () => {
const chosenLine = "1:2\tv7qw\t\tfigs-imperative\tוְ⁠חֹ֖שֶׁךְ\t1\tThis is a command. By commanding that light should exist, God made it exist. (See: [[rc://*/ta/man/translate/figs-imperative]])";
const rawResults = await checkNotesTSV7DataRow(languageCode, repoCode, chosenLine, 'GEN', '1', '2', 'from test line', optionalCheckingOptions);
expect(rawResults.noticeList.length).toBeGreaterThanOrEqual(1);
expect(rawResults.noticeList.length).toBeLessThanOrEqual(1);
});

})
9 changes: 8 additions & 1 deletion src/__tests__/tn-tsv9-table-row-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,17 @@ describe('checkTN_TSV9DataRow() - ', () => {
expect(rawResults).toMatchSnapshot();
});

it('should find invalid newline in single-line field', async () => {
const chosenLine = "GEN\t1\t2\tv7qw\tfigs-imperative<br>\tוְ⁠חֹ֖שֶׁךְ\t1\tDarkness\tThis is a command. By commanding that light should exist, God made it exist. (See: [[rc://*/ta/man/translate/figs-imperative]])";
const rawResults = await checkTN_TSV9DataRow(languageCode, repoCode, chosenLine, 'GEN', '1', '2', 'from test line', optionalCheckingOptions);
expect(rawResults.noticeList.length).toBeGreaterThanOrEqual(3);
expect(rawResults).toMatchSnapshot();
});

it('should be valid', async () => {
const chosenLine = "GEN\t1\t2\tv7qw\tfigs-imperative\tוְ⁠חֹ֖שֶׁךְ\t1\tDarkness\tThis is a command. By commanding that light should exist, God made it exist. (See: [[rc://*/ta/man/translate/figs-imperative]])";
const rawResults = await checkTN_TSV9DataRow(languageCode, repoCode, chosenLine, 'GEN', '1', '2', 'from test line', optionalCheckingOptions);
expect(rawResults.noticeList.length).toEqual(1);
expect(rawResults.noticeList.length).toBeLessThanOrEqual(1);
});

})
10 changes: 8 additions & 2 deletions src/core/markdown-file-contents-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function checkMarkdownFileContents(languageCode, repoCode, markdown

Returns a result object containing a successList and a noticeList
*/
// functionLog(`checkMarkdownFileContents(lC=${languageCode}, rC=${repoCode}, fn=${markdownFilename}, ${markdownText.length}, ${givenLocation})…`);
// functionLog(`checkMarkdownFileContents(lC=${languageCode}, rC=${repoCode}, fn=${markdownFilename}, (${markdownText.length}), ${givenLocation})…`);
//parameterAssert(languageCode !== undefined, "checkMarkdownFileContents: 'languageCode' parameter should be defined");
//parameterAssert(typeof languageCode === 'string', `checkMarkdownFileContents: 'languageCode' parameter should be a string not a '${typeof languageCode}': ${languageCode}`);
// TODO: Check if/why we have both forms below
Expand Down Expand Up @@ -82,8 +82,14 @@ export async function checkMarkdownFileContents(languageCode, repoCode, markdown
//parameterAssert(noticeObject.location !== undefined, "cMdT addNoticePartial: 'location' parameter should be defined");
//parameterAssert(typeof noticeObject.location === 'string', `cMdT addNoticePartial: 'location' parameter should be a string not a '${typeof noticeObject.location}': ${noticeObject.location}`);

if (incompleteNoticeObject.repoCode === undefined) {
// debugLog(`checkMarkdownFileContents addNoticePartial added rC=${repoCode} to ${JSON.stringify(incompleteNoticeObject)}`);
incompleteNoticeObject.repoCode = repoCode;
}
// else if (repoCode !== incompleteNoticeObject.repoCode) debugLog(`checkMarkdownFileContents addNoticePartial DIDN'T ADD rC=${repoCode} to ${JSON.stringify(incompleteNoticeObject)}`);

if (incompleteNoticeObject.debugChain) incompleteNoticeObject.debugChain = `checkMarkdownFileContents ${incompleteNoticeObject.debugChain}`; // Prepend our name
mfccResult.noticeList.push({ ...incompleteNoticeObject, repoCode, filename: markdownFilename });
mfccResult.noticeList.push({ ...incompleteNoticeObject, filename: markdownFilename });
}
// end of addNoticePartial function

Expand Down
12 changes: 9 additions & 3 deletions src/core/markdown-text-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { removeDisabledNotices } from './disabled-notices';
import { parameterAssert, dataAssert, debugLog, functionLog } from './utilities';


const MARKDOWN_TEXT_VALIDATOR_VERSION_STRING = '0.8.0';
const MARKDOWN_TEXT_VALIDATOR_VERSION_STRING = '0.8.1';


/**
Expand All @@ -28,7 +28,7 @@ export async function checkMarkdownText(languageCode, repoCode, textOrFileName,

Returns a result object containing a successList and a noticeList
*/
// functionLog(`checkMarkdownText(${languageCode}, ${repoCode}, ${textOrFileName}, ${markdownText.length}, ${givenLocation}, …)…`);
// functionLog(`checkMarkdownText(${languageCode}, ${repoCode}, ${textOrFileName}, (${markdownText.length}), ${givenLocation}, …)…`);
//parameterAssert(languageCode !== undefined, "checkMarkdownText: 'languageCode' parameter should be defined");
//parameterAssert(typeof languageCode === 'string', `checkMarkdownText: 'languageCode' parameter should be a string not a '${typeof languageCode}': ${languageCode}`);
//parameterAssert(languageCode !== 'unfoldingWord', `checkMarkdownText: 'languageCode' ${languageCode} parameter should be not be 'unfoldingWord'`);
Expand Down Expand Up @@ -87,7 +87,13 @@ export async function checkMarkdownText(languageCode, repoCode, textOrFileName,
//parameterAssert(typeof incompleteNoticeObject.location === 'string', `cMdT addNoticePartial: 'location' parameter should be a string not a '${typeof incompleteNoticeObject.location}': ${incompleteNoticeObject.location}`);

// incompleteNoticeObject.debugChain = incompleteNoticeObject.debugChain ? `checkMarkdownText(${languageCode}, ${textOrFileName}) ${incompleteNoticeObject.debugChain}` : `checkMarkdownText(${languageCode}, ${textOrFileName})`;
result.noticeList.push({ ...incompleteNoticeObject, repoCode }); // Used to have filename: textName, but that isn’t always a filename !!!
if (incompleteNoticeObject.repoCode === undefined) {
// debugLog(`checkMarkdownText addNoticePartial added rC=${repoCode} to ${JSON.stringify(incompleteNoticeObject)}`);
incompleteNoticeObject.repoCode = repoCode;
}
// else if (repoCode !== incompleteNoticeObject.repoCode) debugLog(`checkMarkdownText addNoticePartial DIDN'T ADD rC=${repoCode} to ${JSON.stringify(incompleteNoticeObject)}`);

result.noticeList.push(incompleteNoticeObject); // Used to have filename: textName, but that isn’t always a filename !!!
}
// end of addNoticePartial function

Expand Down
Loading