-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add dashboard visual tests (#8470)
- Loading branch information
1 parent
9155ffa
commit e76c457
Showing
21 changed files
with
137 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,131 @@ | ||
import { fixtureSync, nextFrame } from '@vaadin/testing-helpers'; | ||
import { sendKeys } from '@web/test-runner-commands'; | ||
import { visualDiff } from '@web/test-runner-visual-regression'; | ||
import '../../../theme/lumo/vaadin-dashboard.js'; | ||
import { html, render } from 'lit'; | ||
import type { Dashboard } from '../../../src/vaadin-dashboard.js'; | ||
import { | ||
describeBidirectional, | ||
fireDragStart, | ||
fireResizeOver, | ||
fireResizeStart, | ||
getDraggable, | ||
getElementFromCell, | ||
getResizeHandle, | ||
} from '../../helpers.js'; | ||
|
||
describe('dashboard', () => { | ||
let focusElement: HTMLInputElement; | ||
let element: Dashboard; | ||
let div: HTMLDivElement; | ||
|
||
beforeEach(() => { | ||
div = document.createElement('div'); | ||
|
||
fixtureSync(` | ||
<style> | ||
.content { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
border: 1px solid #ddd; | ||
border-radius: 4px; | ||
height: 100%; | ||
padding: 5px; | ||
box-sizing: border-box; | ||
} | ||
</style> | ||
`); | ||
|
||
focusElement = fixtureSync(`<input type="text" />`); | ||
focusElement.focus(); | ||
}); | ||
|
||
describeBidirectional(`widgets and section`, () => { | ||
function getName(name: string) { | ||
return `${document.dir || 'ltr'}-${name}`; | ||
} | ||
|
||
beforeEach(async () => { | ||
element = fixtureSync(`<vaadin-dashboard editable></vaadin-dashboard>`, div); | ||
|
||
element.renderer = (wrapper) => { | ||
render( | ||
html`<vaadin-dashboard-widget widget-title="Widget title"> | ||
<div class="content" slot="header-content">Header content</div> | ||
<div class="content">Content</div> | ||
</vaadin-dashboard-widget>`, | ||
wrapper, | ||
); | ||
}; | ||
|
||
element.items = [ | ||
{ title: 'Widget 1', colspan: 1 }, | ||
{ title: 'Widget 2', colspan: 1 }, | ||
{ | ||
title: 'Section title', | ||
items: [{ colspan: 1, rowspan: 1 }, { colspan: 1 }], | ||
}, | ||
]; | ||
await nextFrame(); | ||
}); | ||
|
||
it('default', async () => { | ||
await visualDiff(div, getName('default')); | ||
}); | ||
|
||
it('focused widget', async () => { | ||
await sendKeys({ press: 'Tab' }); | ||
await visualDiff(div, getName('focused-widget')); | ||
}); | ||
|
||
it('selected widget', async () => { | ||
await sendKeys({ press: 'Tab' }); | ||
await sendKeys({ press: 'Enter' }); | ||
await visualDiff(div, getName('selected-widget')); | ||
}); | ||
|
||
it('resize mode', async () => { | ||
const firstWidget = getElementFromCell(element, 0, 0)!; | ||
const resizeHandle = getResizeHandle(firstWidget) as HTMLElement; | ||
resizeHandle.click(); | ||
await nextFrame(); | ||
await visualDiff(div, getName('resize-mode')); | ||
}); | ||
|
||
it('move mode', async () => { | ||
const firstWidget = getElementFromCell(element, 0, 0)!; | ||
const moveHandle = getDraggable(firstWidget) as HTMLElement; | ||
moveHandle.click(); | ||
await nextFrame(); | ||
await visualDiff(div, getName('move-mode')); | ||
}); | ||
|
||
it('dragged widget', async () => { | ||
fireDragStart(getElementFromCell(element, 0, 0)!); | ||
await nextFrame(); | ||
|
||
await visualDiff(div, getName('dragged-widget')); | ||
}); | ||
|
||
it('resized widget', async () => { | ||
fireResizeStart(getElementFromCell(element, 0, 0)!); | ||
await nextFrame(); | ||
fireResizeOver(getElementFromCell(element, 0, 0)!, 'end'); | ||
await nextFrame(); | ||
|
||
await visualDiff(div, getName('resized-widget')); | ||
}); | ||
|
||
it('no gap', async () => { | ||
element.style.setProperty('--vaadin-dashboard-gap', '0px'); | ||
await nextFrame(); | ||
await visualDiff(div, getName('no-gap')); | ||
}); | ||
|
||
it('non-editable', async () => { | ||
element.editable = false; | ||
await visualDiff(div, getName('non-editable')); | ||
}); | ||
}); | ||
}); |
Binary file added
BIN
+22.7 KB
packages/dashboard/test/visual/lumo/screenshots/dashboard/baseline/ltr-default.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 added
BIN
+21.1 KB
...ashboard/test/visual/lumo/screenshots/dashboard/baseline/ltr-dragged-widget.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 added
BIN
+21.7 KB
...ashboard/test/visual/lumo/screenshots/dashboard/baseline/ltr-focused-widget.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 added
BIN
+31.8 KB
...ges/dashboard/test/visual/lumo/screenshots/dashboard/baseline/ltr-move-mode.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 added
BIN
+23 KB
packages/dashboard/test/visual/lumo/screenshots/dashboard/baseline/ltr-no-gap.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 added
BIN
+16.5 KB
.../dashboard/test/visual/lumo/screenshots/dashboard/baseline/ltr-non-editable.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 added
BIN
+32.1 KB
...s/dashboard/test/visual/lumo/screenshots/dashboard/baseline/ltr-resize-mode.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 added
BIN
+31.2 KB
...ashboard/test/visual/lumo/screenshots/dashboard/baseline/ltr-resized-widget.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 added
BIN
+27.3 KB
...shboard/test/visual/lumo/screenshots/dashboard/baseline/ltr-selected-widget.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 added
BIN
+22.3 KB
packages/dashboard/test/visual/lumo/screenshots/dashboard/baseline/rtl-default.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 added
BIN
+20.8 KB
...ashboard/test/visual/lumo/screenshots/dashboard/baseline/rtl-dragged-widget.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 added
BIN
+21.3 KB
...ashboard/test/visual/lumo/screenshots/dashboard/baseline/rtl-focused-widget.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 added
BIN
+31.4 KB
...ges/dashboard/test/visual/lumo/screenshots/dashboard/baseline/rtl-move-mode.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 added
BIN
+22.3 KB
packages/dashboard/test/visual/lumo/screenshots/dashboard/baseline/rtl-no-gap.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 added
BIN
+16.1 KB
.../dashboard/test/visual/lumo/screenshots/dashboard/baseline/rtl-non-editable.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 added
BIN
+31.6 KB
...s/dashboard/test/visual/lumo/screenshots/dashboard/baseline/rtl-resize-mode.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 added
BIN
+30.6 KB
...ashboard/test/visual/lumo/screenshots/dashboard/baseline/rtl-resized-widget.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 added
BIN
+26.7 KB
...shboard/test/visual/lumo/screenshots/dashboard/baseline/rtl-selected-widget.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
describe('dashboard', () => { | ||
// Dashboard has no material theme | ||
}); |
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