-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: test(image-io): add bio-rad browser test
- Loading branch information
Showing
7 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,10 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
defaultCommandTimeout: 8000, | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}); |
This file contains 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,69 @@ | ||
import { demoServer } from './common.ts' | ||
|
||
describe('compareImages', () => { | ||
beforeEach(function() { | ||
cy.visit(demoServer) | ||
|
||
const testPathPrefix = '../test/data/input/' | ||
|
||
const testImageFiles = [ | ||
'cake_easy.iwi.cbor', | ||
'cake_hard.iwi.cbor', | ||
'cake_easy.png', | ||
'cake_hard.png', | ||
'apple.jpg', | ||
'orange.jpg', | ||
] | ||
testImageFiles.forEach((fileName) => { | ||
cy.readFile(`${testPathPrefix}${fileName}`, null).as(fileName) | ||
}) | ||
}) | ||
|
||
it('Runs on double images', function () { | ||
cy.get('sl-tab[panel="compareImages-panel"]').click() | ||
|
||
const testFile = { contents: new Uint8Array(this['cake_easy.iwi.cbor']), fileName: 'cake_easy.iwi.cbor' } | ||
cy.get('#compareImagesInputs input[name="test-image-file"]').selectFile([testFile,], { force: true }) | ||
cy.get('#compareImages-test-image-details').should('contain', 'imageType') | ||
|
||
const baselineFile = { contents: new Uint8Array(this['cake_hard.iwi.cbor']), fileName: 'cake_hard.iwi.cbor' } | ||
cy.get('#compareImagesInputs input[name="baseline-images-file"]').selectFile([baselineFile,], { force: true }) | ||
cy.get('#compareImages-baseline-images-details').should('contain', 'imageType') | ||
|
||
cy.get('#compareImagesInputs sl-button[name="run"]').click() | ||
|
||
cy.get('#compareImages-metrics-details').should('contain', '"almostEqual": false') | ||
}) | ||
|
||
it('Runs on uint8 images', function () { | ||
cy.get('sl-tab[panel="compareImages-panel"]').click() | ||
|
||
const testFile = { contents: new Uint8Array(this['cake_easy.png']), fileName: 'cake_easy.png' } | ||
cy.get('#compareImagesInputs input[name="test-image-file"]').selectFile([testFile,], { force: true }) | ||
cy.get('#compareImages-test-image-details').should('contain', 'imageType') | ||
|
||
const baselineFile = { contents: new Uint8Array(this['cake_hard.png']), fileName: 'cake_hard.png' } | ||
cy.get('#compareImagesInputs input[name="baseline-images-file"]').selectFile([baselineFile,], { force: true }) | ||
cy.get('#compareImages-baseline-images-details').should('contain', 'imageType') | ||
|
||
cy.get('#compareImagesInputs sl-button[name="run"]').click() | ||
|
||
cy.get('#compareImages-metrics-details').should('contain', '"almostEqual": false') | ||
}) | ||
|
||
it('Runs on RGB images', function () { | ||
cy.get('sl-tab[panel="compareImages-panel"]').click() | ||
|
||
const testFile = { contents: new Uint8Array(this['apple.jpg']), fileName: 'apple.jpg' } | ||
cy.get('#compareImagesInputs input[name="test-image-file"]').selectFile([testFile,], { force: true }) | ||
cy.get('#compareImages-test-image-details').should('contain', 'imageType') | ||
|
||
const baselineFile = { contents: new Uint8Array(this['orange.jpg']), fileName: 'orange.jpg' } | ||
cy.get('#compareImagesInputs input[name="baseline-images-file"]').selectFile([baselineFile,], { force: true }) | ||
cy.get('#compareImages-baseline-images-details').should('contain', 'imageType') | ||
|
||
cy.get('#compareImagesInputs sl-button[name="run"]').click() | ||
|
||
cy.get('#compareImages-metrics-details').should('contain', '"almostEqual": false') | ||
}) | ||
}) |
This file contains 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 @@ | ||
export const demoServer = 'http://localhost:5173' |
This file contains 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,37 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************** | ||
// This example commands.ts shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
// | ||
// declare global { | ||
// namespace Cypress { | ||
// interface Chainable { | ||
// login(email: string, password: string): Chainable<void> | ||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element> | ||
// } | ||
// } | ||
// } |
This file contains 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,31 @@ | ||
// *********************************************************** | ||
// This example support/e2e.ts is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') | ||
|
||
Cypress.on('uncaught:exception', (err, runnable) => { | ||
// we expect a 3rd party library error with message 'list not defined' | ||
// and don't want to fail the test so we return false | ||
if (err.message.includes('ResizeObserver loop completed with undelivered notifications')) { | ||
return false | ||
} | ||
// we still want to ensure there are no other unexpected | ||
// errors, so we let them fail the test | ||
}) | ||
|
This file contains 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,12 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"include": [ | ||
"**/*.ts" | ||
], | ||
"compilerOptions": { | ||
"noEmit": false, | ||
"sourceMap": false, | ||
"inlineSourceMap": true, | ||
"types": ["cypress"] | ||
}, | ||
} |
This file contains 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