From d27cb280c7b263891e40e7fa58ab323935c3728e Mon Sep 17 00:00:00 2001 From: Mateusz Duda Date: Thu, 11 Jul 2024 14:09:18 +0200 Subject: [PATCH] fixed not changable relevancy, added case for long adf --- .vscode/launch.json | 6 ++ package.json | 2 +- src/Git/GitRepository.ts | 31 ++++-- src/Relevancy/RelevancyManager.ts | 36 ++----- src/Report/ADFValidator.ts | 8 +- src/Report/JiraBuilder.ts | 8 +- test/commits/relevancy.test.ts | 150 +++++++++++++++++++++++++++++- test/report/adfValidator.test.ts | 34 +++++++ test/utils/utils.ts | 8 +- 9 files changed, 236 insertions(+), 47 deletions(-) create mode 100644 test/report/adfValidator.test.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index 2e30805..ece8bb2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,12 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "command": "npm run build && npm run test", + "name": "Build & run tests", + "request": "launch", + "type": "node-terminal" + }, { "command": "npm run build && scope --report-for-commit-list buildData.json log.html", "name": "Run test of --report-for-commit-list", diff --git a/package.json b/package.json index e30ea76..fba50bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scope-tags", - "version": "0.3.4", + "version": "0.3.5", "description": "Output human readable test scope report for QA", "main": "dist/scope.js", "types": "dist/scope.d.ts", diff --git a/src/Git/GitRepository.ts b/src/Git/GitRepository.ts index acf4b55..830b021 100644 --- a/src/Git/GitRepository.ts +++ b/src/Git/GitRepository.ts @@ -1,11 +1,11 @@ +import { execSync } from "child_process"; import { Commit, Note, Oid, Repository, Revwalk, Signature } from "nodegit"; -import { FileData, GitDeltaType, VerificationInfo } from "./Types"; import path from "path"; -import { FileTagsDatabase, FileStatusInDatabase } from "../Scope/FileTagsDatabase"; +import { RelevancyMap } from "../Relevancy/Relevancy"; import { RelevancyManager } from "../Relevancy/RelevancyManager"; import { ConfigFile } from "../Scope/ConfigFile"; -import { execSync } from "child_process"; -import { RelevancyMap } from "../Relevancy/Relevancy"; +import { FileStatusInDatabase, FileTagsDatabase } from "../Scope/FileTagsDatabase"; +import { FileData, GitDeltaType, VerificationInfo } from "./Types"; export class GitRepository { @@ -18,6 +18,10 @@ export class GitRepository { this._root = root; } + public get root() { + return this._root; + } + public async getFileDataForUnpushedCommits(maxCommitCount: number = 20): Promise { const unpushedCommits = await this.getUnpushedCommits(maxCommitCount); @@ -274,7 +278,11 @@ export class GitRepository { return commitId; } - public async amendMostRecentCommit(files: string[], newCommitMessage: string) { + public async amendMostRecentCommit(files: string[], newCommitMessage: string, useGitNatively = false) { + if(useGitNatively) { + this._amendFilesUsingNativeGitCommand(files, newCommitMessage); + return; + } const repository = await this._getRepository(); const index = await repository.refreshIndex(); @@ -458,7 +466,16 @@ export class GitRepository { } } - public get root() { - return this._root; + /** + * Used for tests only, because nodeGit's commit.amend blocks them + */ + private _amendFilesUsingNativeGitCommand(files: string[], newCommitMessage: string) { + const normalizedCommitMessage = newCommitMessage.replace(/(\r\n|\n|\r)/gm, ""); + + files.forEach(file => { + execSync(`cd ${this._root} && git add ${file}`); + }) + + execSync(`cd ${this._root} && git commit --amend -m ${JSON.stringify(normalizedCommitMessage)}`); } } diff --git a/src/Relevancy/RelevancyManager.ts b/src/Relevancy/RelevancyManager.ts index 863fc55..48ac47f 100644 --- a/src/Relevancy/RelevancyManager.ts +++ b/src/Relevancy/RelevancyManager.ts @@ -1,7 +1,7 @@ import { Commit } from "nodegit"; import { FileData } from "../Git/Types"; -import { CommitMessageRelevancyInfo, Relevancy, RelevancyDescriptions, RelevancyMap } from "./Relevancy"; import { FileTagsDatabase } from "../Scope/FileTagsDatabase"; +import { CommitMessageRelevancyInfo, Relevancy, RelevancyDescriptions, RelevancyMap } from "./Relevancy"; const { Scale } = require('enquirer'); @@ -82,37 +82,19 @@ export class RelevancyManager { } as CommitMessageRelevancyInfo; }); - // Merge relevancies - if some are duplicates, select those with higher relevancy - TODO: This should be testable -> add test - const allRelevancies: CommitMessageRelevancyInfo[] = relevancyArray.concat(relevancyArrayFromCurrentCommit); - const mergedRelevancies: CommitMessageRelevancyInfo[] = []; - - relevancyArray.concat(relevancyArrayFromCurrentCommit).forEach(relevancy => { - - if (mergedRelevancies.some(mergedRelevancy => mergedRelevancy.path === relevancy.path)) { - return; - } + // Merge relevancies - if some are duplicates, overwrite them + relevancyArray.forEach(relevancyEntry => { + const matchingRelevancyFromCurrentCommit = relevancyArrayFromCurrentCommit.find(relevancy => relevancy.path === relevancyEntry.path); - const relevanciesForThisFileData = allRelevancies.filter(mergedRelevancy => mergedRelevancy.path === relevancy.path); - - if (relevanciesForThisFileData.length === 0) { - throw new Error("[RelevancyManager] Could not merge relevancy data to current head commit"); - } else if (relevanciesForThisFileData.length === 1) { - mergedRelevancies.push(relevancy); - return; + if(matchingRelevancyFromCurrentCommit) { + matchingRelevancyFromCurrentCommit.relevancy = relevancyEntry.relevancy; + matchingRelevancyFromCurrentCommit.commit = relevancyEntry.commit; } else { - // Find highest relevancy for this file - let highestPossibleRelevancyData = relevanciesForThisFileData[0]; - - for (let i = 1; i < relevanciesForThisFileData.length; i++) { - if (this._getIndexByRelevancy(relevanciesForThisFileData[i].relevancy) > this._getIndexByRelevancy(highestPossibleRelevancyData.relevancy)) { - highestPossibleRelevancyData = relevanciesForThisFileData[i]; - } - } - mergedRelevancies.push(highestPossibleRelevancyData); + relevancyArrayFromCurrentCommit.push(relevancyEntry); } }); - const outputRelevancyArray = JSON.stringify(mergedRelevancies); + const outputRelevancyArray = JSON.stringify(relevancyArray); const commitMessageWithoutRelevancy = headCommit.message().replace(/__relevancy__.+__relevancy__/gs, ""); diff --git a/src/Report/ADFValidator.ts b/src/Report/ADFValidator.ts index 8ab2f96..1fa7a24 100644 --- a/src/Report/ADFValidator.ts +++ b/src/Report/ADFValidator.ts @@ -4,7 +4,8 @@ import Ajv from "ajv"; import { Logger } from "../Logger/Logger"; export class ADFValidator { - private static SCHEMA_URL = "https://unpkg.com/@atlaskit/adf-schema@36.8.5/dist/json-schema/v1/full.json"; + private static SCHEMA_URL = "http://go.atlassian.com/adf-json-schema"; + private static JIRA_COMMENT_MAX_LENGTH = 32_767; private _schema: unknown; @@ -34,6 +35,11 @@ export class ADFValidator { const ajv = new Ajv({ jsonPointers: true }); + if(commentJSON.length > ADFValidator.JIRA_COMMENT_MAX_LENGTH) { + console.log(`[ADFValidator] Maximum length of Jira comment (${ADFValidator.JIRA_COMMENT_MAX_LENGTH}) exceeded`); + return false; + } + const data = JSON.parse(commentJSON); const validate = ajv.compile(this._schema); diff --git a/src/Report/JiraBuilder.ts b/src/Report/JiraBuilder.ts index f3c04cb..1ce4e35 100644 --- a/src/Report/JiraBuilder.ts +++ b/src/Report/JiraBuilder.ts @@ -1,10 +1,10 @@ -import { formatDate } from "./TimeUtils"; -import { expand, table, doc, tableRow, tableHeader, p, strong, text, link, nestedExpand } from "./AdfUtils"; import { ReferencedFileInfo } from "../References/IReferenceFinder"; -import { TagIdentifier } from "../Scope/FileTagsDatabase"; -import { FileInfo } from "./ReportGenerator"; import { Relevancy } from "../Relevancy/Relevancy"; import { getScriptVersion } from "../scope"; +import { TagIdentifier } from "../Scope/FileTagsDatabase"; +import { doc, expand, link, nestedExpand, p, strong, table, tableHeader, tableRow, text } from "./AdfUtils"; +import { FileInfo } from "./ReportGenerator"; +import { formatDate } from "./TimeUtils"; export type TagIdentifierWithRelevancy = TagIdentifier & { relevancy: Relevancy; diff --git a/test/commits/relevancy.test.ts b/test/commits/relevancy.test.ts index 8868a92..68409de 100644 --- a/test/commits/relevancy.test.ts +++ b/test/commits/relevancy.test.ts @@ -1,7 +1,10 @@ -import { RelevancyManager } from "../../src/Relevancy/RelevancyManager"; +import { Commit } from "nodegit"; import { FileData, GitDeltaType } from "../../src/Git/Types"; import { CommitMessageRelevancyInfo, Relevancy } from "../../src/Relevancy/Relevancy"; -import { Commit } from "nodegit"; +import { RelevancyManager } from "../../src/Relevancy/RelevancyManager"; +import { FileTagsDatabase } from "../../src/Scope/FileTagsDatabase"; +import { TagsDefinitionFile } from "../../src/Scope/TagsDefinitionFile"; +import { cloneMockRepositoryToFolder, commitModitication, makeUniqueFolderForTest } from "../utils/utils"; const fs = require('fs'); @@ -173,5 +176,146 @@ describe("Relevancy manager tests", () => { checkRelevancyAndFileData(generatedRelevancyData[0], mockFileData1, mockRelevancyData.get(mockFileData1), "sha"); checkRelevancyAndFileData(generatedRelevancyData[1], mockFileData2, mockRelevancyData.get(mockFileData2), "sha"); checkRelevancyAndFileData(generatedRelevancyData[2], mockFileData3, mockRelevancyData.get(mockFileData3), "sha"); - }) + }); + + it("Correctly replaces existing relevancy in a commit message (low -> high relevancy)", async () => { + const FOLDER_PATH = makeUniqueFolderForTest(); + const REPO_PATH = cloneMockRepositoryToFolder(FOLDER_PATH); + + // Assume relevancy is already added + + const repository = await commitModitication( + ["src/tagged-file.js"], + REPO_PATH, + `[TEST - 1234] There is correct relevancy data in this commit message + + __relevancy__[{"path":"src/tagged-file.js","relevancy":"LOW","commit":"__current__"}]__relevancy__ + `); + + const relevancyManager = new RelevancyManager(); + + const headCommit = (await repository.getUnpushedCommits())[0]; + + expect(headCommit).toBeDefined(); + expect(relevancyManager.doesCommitMessageHaveRelevancyData(headCommit.message())).toBe(true); + + // And user selects new relevancy using npx scope --add + + const userSelectedRelevancy = new Map([ + [{ + oldPath: "src/tagged-file.js", + newPath: "src/tagged-file.js", + change: GitDeltaType.MODIFIED, + linesAdded: 100, + linesRemoved: 200, + } as FileData, + Relevancy.HIGH] + ]); + + const newCommitMessage = relevancyManager.convertRelevancyDataToCommitMessage(userSelectedRelevancy, headCommit); + + expect(relevancyManager.doesCommitMessageHaveRelevancyData(newCommitMessage)).toBe(true); + + const extractedRelevancy = relevancyManager.convertCommitMessageToRelevancyData({ + message: () => newCommitMessage, + sha: () => "sha", + } as Commit); + + expect(extractedRelevancy[0]).toBeDefined(); + expect(extractedRelevancy[0].path).toBe("src/tagged-file.js"); + expect(extractedRelevancy[0].relevancy).toBe(Relevancy.HIGH); + + const tagsDefinitionFile = new TagsDefinitionFile(REPO_PATH); + const fileTagsDatabase = new FileTagsDatabase(REPO_PATH); + + await repository.amendMostRecentCommit([fileTagsDatabase.getPath(), tagsDefinitionFile.getPath()], newCommitMessage, true); + + const headCommitAfterChange = (await repository.getUnpushedCommits())[0]; + + expect(headCommitAfterChange).toBeDefined(); + const msg = headCommitAfterChange.message(); + + expect(relevancyManager.doesCommitMessageHaveRelevancyData(headCommitAfterChange.message())).toBe(true); + + + const newExtractedRelevancy = relevancyManager.convertCommitMessageToRelevancyData({ + message: () => headCommitAfterChange.message(), + sha: () => "sha", + } as Commit); + + expect(newExtractedRelevancy[0]).toBeDefined(); + expect(newExtractedRelevancy[0].path).toBe("src/tagged-file.js"); + expect(newExtractedRelevancy[0].relevancy).toBe(Relevancy.HIGH); + }); + + + it("Correctly replaces existing relevancy in a commit message (high -> low relevancy)", async () => { + const FOLDER_PATH = makeUniqueFolderForTest(); + const REPO_PATH = cloneMockRepositoryToFolder(FOLDER_PATH); + + // Assume relevancy is already added + + const repository = await commitModitication( + ["src/tagged-file.js"], + REPO_PATH, + `[TEST - 1234] There is correct relevancy data in this commit message + + __relevancy__[{"path":"src/tagged-file.js","relevancy":"HIGH","commit":"__current__"}]__relevancy__ + `); + + const relevancyManager = new RelevancyManager(); + + const headCommit = (await repository.getUnpushedCommits())[0]; + + expect(headCommit).toBeDefined(); + expect(relevancyManager.doesCommitMessageHaveRelevancyData(headCommit.message())).toBe(true); + + // And user selects new relevancy using npx scope --add + + const userSelectedRelevancy = new Map([ + [{ + oldPath: "src/tagged-file.js", + newPath: "src/tagged-file.js", + change: GitDeltaType.MODIFIED, + linesAdded: 100, + linesRemoved: 200, + } as FileData, + Relevancy.LOW] + ]); + + const newCommitMessage = relevancyManager.convertRelevancyDataToCommitMessage(userSelectedRelevancy, headCommit); + + expect(relevancyManager.doesCommitMessageHaveRelevancyData(newCommitMessage)).toBe(true); + + const extractedRelevancy = relevancyManager.convertCommitMessageToRelevancyData({ + message: () => newCommitMessage, + sha: () => "sha", + } as Commit); + + expect(extractedRelevancy[0]).toBeDefined(); + expect(extractedRelevancy[0].path).toBe("src/tagged-file.js"); + expect(extractedRelevancy[0].relevancy).toBe(Relevancy.LOW); + + const tagsDefinitionFile = new TagsDefinitionFile(REPO_PATH); + const fileTagsDatabase = new FileTagsDatabase(REPO_PATH); + + await repository.amendMostRecentCommit([fileTagsDatabase.getPath(), tagsDefinitionFile.getPath()], newCommitMessage, true); + + const headCommitAfterChange = (await repository.getUnpushedCommits())[0]; + + expect(headCommitAfterChange).toBeDefined(); + const msg = headCommitAfterChange.message(); + + expect(relevancyManager.doesCommitMessageHaveRelevancyData(headCommitAfterChange.message())).toBe(true); + + + const newExtractedRelevancy = relevancyManager.convertCommitMessageToRelevancyData({ + message: () => headCommitAfterChange.message(), + sha: () => "sha", + } as Commit); + + expect(newExtractedRelevancy[0]).toBeDefined(); + expect(newExtractedRelevancy[0].path).toBe("src/tagged-file.js"); + expect(newExtractedRelevancy[0].relevancy).toBe(Relevancy.LOW); + }); }); diff --git a/test/report/adfValidator.test.ts b/test/report/adfValidator.test.ts new file mode 100644 index 0000000..f9265a7 --- /dev/null +++ b/test/report/adfValidator.test.ts @@ -0,0 +1,34 @@ +import { ADFValidator } from "../../src/Report/ADFValidator"; + +// Tests for Jira ADF validator + +describe("ADF Validator", () => { + it("Correctly identifies valid sample ADF", async () => { + const validADF = `{"type":"doc","version":1,"content":[{"type":"expand","attrs":{"title":"'Project' scope tags v0.3.4 │ 11.07.2024 10:15 │ -"},"content":[{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Affected tags","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{"colwidth":[20]},"content":[{"type":"paragraph","content":[{"type":"text","text":"Lines","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Used by module","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Used by tags","marks":[{"type":"strong"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"3 untagged files"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/HTMLCreator/HTMLCreator.tssrc/Logger/Logger.tssrc/Report/ADFValidator.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 77-- 26"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"Third module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Some new tag"}]}]},{"type":"nestedExpand","attrs":{"title":"Fourth module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Fourth tag"}]}]},{"type":"nestedExpand","attrs":{"title":"3 untagged files"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/Logger/Logger.tssrc/HTMLCreator/HTMLCreator.tssrc/Report/ADFValidator.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]},{"type":"nestedExpand","attrs":{"title":"Some new tag"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module"}]}]},{"type":"nestedExpand","attrs":{"title":"Fourth tag"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Fourth module"}]}]}]}]}],"attrs":{"layout":"full-width"}}]}]}`; + + const validator = new ADFValidator(); + await validator.loadSchema(); + + expect(validator.validateADF(validADF)).toBe(true); + }); + + it("Correctly identifies invalid sample ADF", async () => { + const invalidADF = `{"ype":"doc","version":1,"content":[{"type":"expand","attrs":{"title":"'Project' scope tags v0.3.4 │ 11.07.2024 10:15 │ -"},"content":[{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Affected tags","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{"colwidth":[20]},"content":[{"type":"paragraph","content":[{"type":"text","text":"Lines","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Used by module","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Used by tags","marks":[{"type":"strong"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tabeHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"cntent":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"3 untagged files"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/HTMLCreator/HTMLCreator.tssrc/Logger/Logger.tssrc/Report/ADFValidator.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 77-- 26"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"Third module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Some new tag"}]}]},{"type":"nestedExpand","atrs":{"title":"Fourth module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Fourth tag"}]}]},{"type":"nestedExpand","attrs":{"title":"3 untagged files"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/Logger/Logger.tssrc/HTMLCreator/HTMLCreator.tssrc/Report/ADFValidator.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]},{"type":"nestedExpand","attrs":{"title":"Some new tag"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module"}]}]},{"type":"nestedExpand","attrs":{"title":"Fourth tag"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Fourth module"}]}]}]}]}],"attrs":{"layout":"full-width"}}]}]}`; + + const validator = new ADFValidator(); + await validator.loadSchema(); + + expect(validator.validateADF(invalidADF)).toBe(false); + }); + + + it("Correctly marks valid ADF as invalid when is has more than 32,767 characters", async () => { + const validAdfButLength = `{"type":"doc","version":1,"content":[{"type":"expand","attrs":{"title":"'Project' scope tags v0.3.4 │ 11.07.2024 10:58 │ -"},"content":[{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Affected tags","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{"colwidth":[20]},"content":[{"type":"paragraph","content":[{"type":"text","text":"Lines","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Used by module","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Used by tags","marks":[{"type":"strong"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module / asdflkj"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 20-- 5"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"1 untagged file"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/scope.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module / Some new tag"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 2-- 2"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"3 untagged files"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/HTMLCreator/HTMLCreator.tssrc/Logger/Logger.tssrc/Report/ADFValidator.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"++ 77-- 26"}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"Second module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"asdflkj"}]}]},{"type":"nestedExpand","attrs":{"title":"Third module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Some new tag"}]}]},{"type":"nestedExpand","attrs":{"title":"Fourth module"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Fourth tag"}]}]},{"type":"nestedExpand","attrs":{"title":"3 untagged files"},"content":[{"type":"paragraph","content":[{"type":"text","text":"src/Logger/Logger.tssrc/HTMLCreator/HTMLCreator.tssrc/Report/ADFValidator.ts"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"nestedExpand","attrs":{"title":"asdflkj"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Second module"}]}]},{"type":"nestedExpand","attrs":{"title":"Some new tag"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Third module"}]}]},{"type":"nestedExpand","attrs":{"title":"Fourth tag"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Fourth module"}]}]}]}]}],"attrs":{"layout":"full-width"}}]}]}`; + + const validator = new ADFValidator(); + await validator.loadSchema(); + expect(validAdfButLength.length).toBeGreaterThan(32767); + expect(validator.validateADF(validAdfButLength)).toBe(false); + }); +}); + diff --git a/test/utils/utils.ts b/test/utils/utils.ts index 14ff90b..9c032d7 100644 --- a/test/utils/utils.ts +++ b/test/utils/utils.ts @@ -1,13 +1,13 @@ -import { resolve, join, sep, posix } from "path"; import { appendFileSync, existsSync, mkdirSync } from "fs"; +import { join, posix, resolve, sep } from "path"; import { MOCK_REMOTE_URL, MOCK_REPOSITORY, TEST_DATA_FOLDER } from "./globals"; -import * as uuid from "uuid"; -import { GitRepository } from "../../src/Git/GitRepository"; import { execSync } from "child_process"; -import * as rimraf from "rimraf"; import fs from "fs"; import readline from "readline"; +import * as rimraf from "rimraf"; +import * as uuid from "uuid"; +import { GitRepository } from "../../src/Git/GitRepository"; // Mocked repository