Skip to content

Commit b111fc3

Browse files
authored
test: added Image visual tests (#794)
1 parent 3079054 commit b111fc3

18 files changed

+238
-4
lines changed

src/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/ImgSettingsButton.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const ImgSettingsButton: React.FC<{
6363

6464
{isVisibleEditButton && (
6565
<Button
66+
qa="g-md-image-settings-button"
6667
onClick={togglePopup}
6768
ref={setAnchorElement}
6869
size="s"
@@ -79,9 +80,13 @@ export const ImgSettingsButton: React.FC<{
7980
onOpenChange={unsetPopupOpen}
8081
placement={placement}
8182
>
82-
<Menu>
83-
<Menu.Item onClick={handleEdit}>{i18nCommon('edit')}</Menu.Item>
84-
<Menu.Item onClick={onDelete}>{i18nCommon('delete')}</Menu.Item>
83+
<Menu qa="g-md-image-settings-menu">
84+
<Menu.Item extraProps={{'aria-label': i18nCommon('edit')}} onClick={handleEdit}>
85+
{i18nCommon('edit')}
86+
</Menu.Item>
87+
<Menu.Item extraProps={{'aria-label': i18nCommon('delete')}} onClick={onDelete}>
88+
{i18nCommon('delete')}
89+
</Menu.Item>
8590
</Menu>
8691
</Popup>
8792
</>

src/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/NodeView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const ImageNodeView: React.FC<ReactNodeViewProps> = ({
109109
);
110110

111111
return (
112-
<div ref={imageContainerRef}>
112+
<div ref={imageContainerRef} data-qa="g-md-image">
113113
<Resizable
114114
hover={isNodeHovered}
115115
resizing={state.resizing}

tests/playwright/core/editor.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,28 @@ class Colorify {
144144
}
145145
}
146146

147+
class Image {
148+
protected readonly imageSettingsButton: Locator;
149+
protected readonly imageSettingsMenu: Locator;
150+
protected readonly image: Locator;
151+
152+
constructor(page: Page) {
153+
this.imageSettingsButton = page.getByTestId('g-md-image-settings-button');
154+
this.imageSettingsMenu = page.getByTestId('g-md-image-settings-menu');
155+
this.image = page.getByTestId('g-md-image');
156+
}
157+
158+
async clickImageSettingsButton() {
159+
const button = this.imageSettingsButton;
160+
await button.click();
161+
}
162+
163+
async clickImageSettingsMenu(label: string) {
164+
const button = this.imageSettingsMenu.getByLabel(label);
165+
await button.click();
166+
}
167+
}
168+
147169
class YfmNote {
148170
protected readonly yfmNoteToolbar: Locator;
149171

@@ -205,6 +227,7 @@ export class MarkdownEditorPage {
205227
readonly yfmTable;
206228
readonly colorify;
207229
readonly yfmNote;
230+
readonly image;
208231
protected readonly page: Page;
209232
protected readonly expect: Expect;
210233

@@ -216,6 +239,7 @@ export class MarkdownEditorPage {
216239
this.yfmTable = new YfmTable(page);
217240
this.colorify = new Colorify(page, expect, this.locators);
218241
this.yfmNote = new YfmNote(page);
242+
this.image = new Image(page);
219243
}
220244

221245
/**

tests/playwright/playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const aliasesFromTsConf = (() => {
2323
})();
2424

2525
const ctViteConfig: InlineConfig = {
26+
publicDir: pathFromRoot('visual-tests/public'),
2627
css: {
2728
preprocessorOptions: {
2829
scss: {
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)