feat(selectivity): consider png reference deps#1245
Conversation
c3be6ba to
4be4cdd
Compare
commit: |
4be4cdd to
d2c4c9d
Compare
| }); | ||
| }; | ||
|
|
||
| export const addTestplaneSelectivityPngDependency = (pngPath: string): void => { |
There was a problem hiding this comment.
When called during test run, adds png dependency to test dependencies
Called on "assert-view"
| let aInd = 0, | ||
| bInd = 0; | ||
|
|
||
| if (!a[depType]) { |
There was a problem hiding this comment.
Explicit checks "what if old format had no png dependencies property"
| }).catch(() => ({})); | ||
| }).catch(() => ({}))) as Record< | ||
| string, | ||
| Record<string, Partial<NormalizedDependencies> & Pick<NormalizedDependencies, "css" | "js" | "modules" | "png">> |
There was a problem hiding this comment.
Explicit type check "those properties were added on read and guaranteed to exist"
If new property will be added, typescript would complain:
Types of property 'newTypeDeps' are incompatible.
Type 'string[] | undefined' is not assignable to type 'string[]'.
Type 'undefined' is not assignable to type 'string[]'.ts(2322)
| if (isUpdatingRefs) { | ||
| addTestplaneSelectivityPngDependency(refImg.path); |
There was a problem hiding this comment.
"--update-refs" case
| }); | ||
| }); | ||
|
|
||
| it("should restore missing dependency properties", async () => { |
There was a problem hiding this comment.
Extra test to make sure "readTestDependencies" returns complete value, even if file was missing some properties
| readJsonWithCompressionStub.resolves(oldFormatDependencies); | ||
|
|
||
| const result = await utils.readTestDependencies("/test/selectivity/tests", mockTest, "none"); | ||
| const completeExpectedBrowserDependencies: NormalizedDependencies = { |
There was a problem hiding this comment.
Would also get type errors here, if any property will be missed
|
|
||
| const testDependencyWriter = getTestDependenciesWriter(testDependenciesPath, compression); | ||
| const browserDeps = transformSourceDependencies(cssDependencies, jsDependencies, mapBrowserDepsRelativePath); | ||
| const browserDeps = transformSourceDependencies( |
There was a problem hiding this comment.
давай просто объединим типы зависимостей в один аргумент deps. Сейчас набор аргументов вида null, jsDeps, null выглядит нечитаено. Ну и ты еще должен запоминать в какой последовательности нужно передать эти зависимости.
d2c4c9d to
4ac44ed
Compare
No description provided.