forked from JeremyHeleine/Photo-Sphere-Viewer
-
-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
213 additions
and
48 deletions.
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
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,86 @@ | ||
import type { CompassPlugin, CompassPluginConfig } from '@photo-sphere-viewer/compass-plugin'; | ||
import { getPlugin, getViewer, waitViewerReady } from '../utils'; | ||
|
||
describe('compass', () => { | ||
beforeEach(() => { | ||
cy.visit('e2e/compass.html'); | ||
waitViewerReady(); | ||
// createBaseSnapshot(); | ||
}); | ||
|
||
it('should have a compass', () => { | ||
cy.get('.psv-compass') | ||
.should('be.visible') | ||
.compareScreenshots('base'); | ||
}); | ||
|
||
it('should pan & zoom', () => { | ||
getViewer('rotate 90deg') | ||
.then(viewer => viewer.rotate({ pitch: 0, yaw: '90deg' })) | ||
.wait(200); | ||
|
||
cy.get('.psv-compass').compareScreenshots('rotate'); | ||
|
||
getViewer('zoom 100%') | ||
.then(viewer => viewer.zoom(100)) | ||
.wait(200); | ||
|
||
cy.get('.psv-compass').compareScreenshots('zoom'); | ||
}); | ||
|
||
it('should show navigation cone', () => { | ||
cy.get('.psv-compass').then(compass => { | ||
const { x, y, width, height } = compass[0].getBoundingClientRect(); | ||
|
||
// center-right | ||
const enterPoint = { clientX: x + width, clientY: y + height / 2 }; | ||
// above bottom-center | ||
const clickPoint = { clientX: x + width / 2, clientY: y + height - 20 }; | ||
// bottom-center | ||
const leavePoint = { clientX: x + width / 2, clientY: y + height }; | ||
|
||
cy.wrap(compass, { log: false }) | ||
.trigger('mouseenter', enterPoint) | ||
.compareScreenshots('navigation-1') | ||
.trigger('mousemove', clickPoint) | ||
.compareScreenshots('navigation-2') | ||
.trigger('mousedown', clickPoint) | ||
.trigger('mouseup', clickPoint) | ||
.trigger('mouseleave', leavePoint) | ||
.compareScreenshots('navigation-3'); | ||
}); | ||
|
||
cy.wait(200); | ||
|
||
getViewer('check position').then(viewer => { | ||
expect(viewer.getPosition()).to.deep.eq({ yaw: Math.PI, pitch: 0 }); | ||
}); | ||
}); | ||
|
||
Object.entries({ | ||
coneColor: '#00000055', | ||
navigationColor: 'rgba(0, 255, 0, 0.5)', | ||
size: '300px', | ||
backgroundSvg: '<svg viewBox="0 0 100 100"><circle cx="50" cy="50" r="50" fill="rgba(0, 0, 0, .5)"/></svg>', | ||
} satisfies CompassPluginConfig).forEach(([key, value]) => { | ||
it(`should set the ${key}`, () => { | ||
getPlugin<CompassPlugin>('compass', `set ${key}`) | ||
.then(compass => compass.setOption(key as any, value)) | ||
.wait(200); | ||
|
||
if (key === 'nabigationColor') { | ||
cy.get('.psv-compass').then(compass => { | ||
const { x, y, width, height } = compass[0].getBoundingClientRect(); | ||
|
||
cy.wrap(compass, { log: false }) | ||
.trigger('mousemove', { clientX: x + width / 2, clientY: y + height - 20 }) | ||
.compareScreenshots(`set-${key}`) | ||
.trigger('mouseleave'); | ||
}); | ||
} else { | ||
cy.get('.psv-compass').compareScreenshots(`set-${key}`); | ||
} | ||
}); | ||
}); | ||
|
||
}); |
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
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.21 KB
cypress/snapshots/base/cypress/e2e/compass.cy.ts/set-backgroundSvg.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.
Binary file added
BIN
+11.1 KB
cypress/snapshots/base/cypress/e2e/compass.cy.ts/set-navigationColor.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.
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.
Binary file modified
BIN
-7.13 KB
(39%)
cypress/snapshots/base/cypress/e2e/navbar.cy.ts/caption-notification.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
-9.1 KB
(33%)
cypress/snapshots/base/cypress/e2e/navbar.cy.ts/custom-element.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
-205 KB
(51%)
cypress/snapshots/base/cypress/e2e/navbar.cy.ts/description.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
-44.5 KB
(33%)
cypress/snapshots/base/cypress/e2e/navbar.cy.ts/disable-button.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
-44.3 KB
(33%)
cypress/snapshots/base/cypress/e2e/navbar.cy.ts/hide-button.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
-173 KB
(27%)
cypress/snapshots/base/cypress/e2e/navbar.cy.ts/menu-content.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
-28.7 KB
(31%)
cypress/snapshots/base/cypress/e2e/navbar.cy.ts/no-caption.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
-43.1 KB
(27%)
cypress/snapshots/base/cypress/e2e/navbar.cy.ts/update-buttons.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
-44.5 KB
(30%)
cypress/snapshots/base/cypress/e2e/navbar.cy.ts/update-caption.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
-14.8 KB
(38%)
cypress/snapshots/base/cypress/e2e/navbar.cy.ts/with-menu.png
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 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 |
---|---|---|
@@ -1,26 +1,42 @@ | ||
import 'cypress-real-events'; | ||
import 'cypress-mochawesome-reporter/register'; | ||
import 'cypress-real-events'; | ||
import { addCompareSnapshotCommand } from 'cypress-visual-regression/dist/command'; | ||
|
||
addCompareSnapshotCommand({ | ||
errorThreshold: 0.1, | ||
errorThreshold: 0.01, | ||
failSilently: !Cypress.config('isInteractive'), | ||
}); | ||
|
||
if (!Cypress.config('isInteractive')) { | ||
Cypress.Commands.overwrite('compareSnapshot', (originalFn, name, options = {}) => { | ||
return originalFn(name, options) | ||
.then(result => { | ||
if (result.images.diff) { | ||
// @ts-ignore | ||
Cypress.Mochawesome.context.push({ title: 'Visual regression diff', value: 'data:image/png;base64,' + result.images.diff }); | ||
} | ||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace Cypress { | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
interface Chainable { | ||
compareScreenshots(name: string, options?: { errorThreshold?: number, hideViewer?: boolean }): Chainable<JQuery<HTMLElement>>; | ||
} | ||
} | ||
} | ||
|
||
if (result.error) { | ||
throw new Error(result.error); | ||
} | ||
Cypress.Commands.add('compareScreenshots', { prevSubject: ['element'] }, (subject, name, options = {}) => { | ||
if (options.hideViewer !== false) { | ||
cy.get('.psv-canvas-container', { log: false }).then(container => container.hide()); | ||
} | ||
|
||
return result; | ||
}); | ||
}); | ||
} | ||
cy.wrap(subject, { log: false }).compareSnapshot(name, options) | ||
.then((result) => { | ||
if (result.images.diff) { | ||
// @ts-ignore | ||
Cypress.Mochawesome.context.push({ title: 'Visual regression diff', value: 'data:image/png;base64,' + result.images.diff }); | ||
} | ||
|
||
if (result.error) { | ||
throw new Error(result.error); | ||
} | ||
|
||
if (options.hideViewer !== false) { | ||
return cy.get('.psv-canvas-container', { log: false }).then(container => container.show()); | ||
} | ||
}); | ||
|
||
return cy.wrap(subject, { log: 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
Oops, something went wrong.