-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Remove file-type dependency via jimp #137214
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
d2e6fca
Removed file-type from package.json deps.
jeramysoucy d94a7e5
Replaced jimp with sharp and pixelmatch. Eliminates several deps, inc…
jeramysoucy 229e032
Fixed copy paste error, which lead to pass positives and errors.
jeramysoucy 14f18b1
Integrated updateBaselines flag into dashboards report testing.
jeramysoucy c159935
Removed accidental '.only'
jeramysoucy 49d2edf
Reverted area chart baseline.
jeramysoucy 23bfa8d
Removed explicit declaration of sharp from package.json.
jeramysoucy ba4699e
Merge branch 'main' into remove-file-type-dep
jeramysoucy 3c93a29
Adjusted dashboard screenshot size in attempt to eliminate layout sca…
jeramysoucy a080e82
Reverted dashboard screenshot size. Lowered tolerance in dashboard PN…
jeramysoucy e23c946
Changed session save location for dashboard report images for better …
jeramysoucy ca03c91
Fixed small dashboard baseline screenshot with correct aspect ratio.
jeramysoucy c1b3f41
Updated 2 basline screenshots from CI. Lowered PNG match tolerance fo…
jeramysoucy b830b9c
Update of dashboard controls light mode baseline.
jeramysoucy 8a20c05
Updated dashboard controls dark mode baseline screenshot.
jeramysoucy 59ada75
Lowering tolerance of PNG compare tests from 9% to 1% for troubleshoo…
jeramysoucy 13897c0
Reverting tolerance of PNG compares to 0.09. Will create GH issues fo…
jeramysoucy f6bfe88
Implemented PngService to provide an accessible single reference to P…
jeramysoucy 759aa2e
Updated service reference and call to png compare function left out o…
jeramysoucy f6a4d8c
Updated another missed PNG reference.
jeramysoucy ee00e7f
Removed superfluous parameter.
jeramysoucy 41751ca
Merge remote-tracking branch 'upstream/main' into remove-file-type-dep
jeramysoucy e1546be
Update after bootstrap
jeramysoucy c2669d0
Updated area chart baseline to match new render with panel filters.
jeramysoucy 080a9ea
Reverted limits in dashboard snapshot tests to original values.
jeramysoucy 7a1a18d
Merge branch 'main' into remove-file-type-dep
kibanamachine 64467a4
Merge remote-tracking branch 'upstream/main' into remove-file-type-dep
jeramysoucy ac8ccec
Merge and rebuild.
jeramysoucy 7cf3519
Merge branch 'remove-file-type-dep' of github.com:jeramysoucy/kibana …
jeramysoucy ebc5505
Rebuild after merge.
jeramysoucy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-5.05 KB
(93%)
test/functional/screenshots/baseline/dashboard_controls_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-6.58 KB
(90%)
test/functional/screenshots/baseline/dashboard_controls_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import { dirname } from 'path'; | ||
| import { promisify } from 'util'; | ||
| import { promises as fs, writeFile, readFileSync, mkdir } from 'fs'; | ||
| import path from 'path'; | ||
| import { comparePngs, PngDescriptor } from '../lib/compare_pngs'; | ||
| import { FtrProviderContext, FtrService } from '../../ftr_provider_context'; | ||
|
|
||
| const mkdirAsync = promisify(mkdir); | ||
| const writeFileAsync = promisify(writeFile); | ||
|
|
||
| export class PngService extends FtrService { | ||
| private readonly log = this.ctx.getService('log'); | ||
|
|
||
| constructor(ctx: FtrProviderContext) { | ||
| super(ctx); | ||
| } | ||
|
|
||
| async comparePngs( | ||
| sessionInfo: string | PngDescriptor, | ||
| baselineInfo: string | PngDescriptor, | ||
| diffPath: string, | ||
| sessionDirectory: string | ||
| ) { | ||
| return await comparePngs(sessionInfo, baselineInfo, diffPath, sessionDirectory, this.log); | ||
| } | ||
|
|
||
| async checkIfPngsMatch(actualpngPath: string, baselinepngPath: string, folder: string) { | ||
| this.log.debug(`checkIfpngsMatch: ${actualpngPath} vs ${baselinepngPath}`); | ||
| // Copy the pngs into the session directory, as that's where the generated pngs will automatically be | ||
| // stored. | ||
| const sessionDirectoryPath = path.resolve(folder, 'session'); | ||
| const failureDirectoryPath = path.resolve(folder, 'failure'); | ||
|
|
||
| await fs.mkdir(sessionDirectoryPath, { recursive: true }); | ||
| await fs.mkdir(failureDirectoryPath, { recursive: true }); | ||
|
|
||
| const actualpngFileName = path.basename(actualpngPath, '.png'); | ||
| const baselinepngFileName = path.basename(baselinepngPath, '.png'); | ||
|
|
||
| const baselineCopyPath = path.resolve( | ||
| sessionDirectoryPath, | ||
| `${baselinepngFileName}_baseline.png` | ||
| ); | ||
| const actualCopyPath = path.resolve(sessionDirectoryPath, `${actualpngFileName}_actual.png`); | ||
|
|
||
| // Don't cause a test failure if the baseline snapshot doesn't exist - we don't have all OS's covered and we | ||
| // don't want to start causing failures for other devs working on OS's which are lacking snapshots. We have | ||
| // mac and linux covered which is better than nothing for now. | ||
| try { | ||
| this.log.debug(`writeFile: ${baselineCopyPath}`); | ||
| await fs.writeFile(baselineCopyPath, await fs.readFile(baselinepngPath)); | ||
| } catch (error) { | ||
| throw new Error(`No baseline png found at ${baselinepngPath}`); | ||
| } | ||
| this.log.debug(`writeFile: ${actualCopyPath}`); | ||
| await fs.writeFile(actualCopyPath, await fs.readFile(actualpngPath)); | ||
|
|
||
| let diffTotal = 0; | ||
|
|
||
| const diffPngPath = path.resolve(failureDirectoryPath, `${baselinepngFileName}-${1}.png`); | ||
| diffTotal += await this.comparePngs( | ||
| actualCopyPath, | ||
| baselineCopyPath, | ||
| diffPngPath, | ||
| sessionDirectoryPath | ||
| ); | ||
|
|
||
| return diffTotal; | ||
| } | ||
|
|
||
| async compareAgainstBaseline( | ||
| sessionPath: string, | ||
| baselinePath: string, | ||
| folder: string, | ||
| updateBaselines: boolean | ||
| ) { | ||
| this.log.debug(`compareAgainstBaseline: ${sessionPath} vs ${baselinePath}`); | ||
|
|
||
| if (updateBaselines) { | ||
| this.log.debug('Updating baseline PNG'); | ||
| await mkdirAsync(dirname(baselinePath), { recursive: true }); | ||
| await writeFileAsync(baselinePath, readFileSync(sessionPath)); | ||
| return 0; | ||
| } else { | ||
| return await this.checkIfPngsMatch(sessionPath, baselinePath, folder); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.