forked from superdesk/superdesk-client-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix media metadata editor changes not being saved (superdesk#4572)
* fix media metadata editor changes not being saved it was calling authoring editor instances to generate html which then overwrote any changes done in modal. SDESK-7304 * trigger actions * add test from authoring to modal * trigger autosave when opening modal * only trigger autosave if dirty * fix protractor * fix failing protractor tests * handle feedback * docs * create picture authoring object * tweak test
- Loading branch information
Showing
16 changed files
with
192 additions
and
37 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
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,51 @@ | ||
import {test, expect} from '@playwright/test'; | ||
import {Monitoring} from './page-object-models/monitoring'; | ||
import {restoreDatabaseSnapshot} from './utils'; | ||
import {MediaEditor} from './page-object-models/media-editor'; | ||
import {PictureAuthoring} from './page-object-models/authoring'; | ||
import {MediaUpload} from './page-object-models/upload'; | ||
|
||
test.setTimeout(30000); | ||
|
||
/** | ||
* upload a picture | ||
* edit metadata | ||
* test metadata changes from modal are visible in the editor | ||
*/ | ||
test('media metadata editor', async ({page}) => { | ||
await restoreDatabaseSnapshot(); | ||
|
||
const upload = new MediaUpload(page); | ||
const monitoring = new Monitoring(page); | ||
const mediaEditor = new MediaEditor(page); | ||
const pictureAuthoring = new PictureAuthoring(page); | ||
|
||
await page.goto('/#/workspace/monitoring'); | ||
|
||
await monitoring.selectDeskOrWorkspace('Sports'); | ||
await monitoring.openMediaUploadView(); | ||
|
||
await upload.selectFile('iptc-photo.jpg'); | ||
|
||
await expect(mediaEditor.field('field--headline')).toContainText('The Headline'); | ||
|
||
await mediaEditor.field('field--headline').clear(); | ||
await mediaEditor.field('field--headline').fill('picture'); | ||
|
||
await upload.startUpload(); | ||
|
||
await monitoring.executeActionOnMonitoringItem(monitoring.getArticleLocator('picture'), 'Edit'); | ||
|
||
await pictureAuthoring.openMetadataEditor(); | ||
|
||
await mediaEditor.field('field--description_text').fill('test description'); | ||
await mediaEditor.saveMetadata(); | ||
|
||
await expect(pictureAuthoring.field('field--description_text')).toContainText('test description'); | ||
|
||
await pictureAuthoring.field('field--description_text').fill('new description'); | ||
|
||
await pictureAuthoring.openMetadataEditor(); | ||
|
||
await expect(mediaEditor.field('field--description_text')).toContainText('new description'); | ||
}); |
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,35 @@ | ||
import {Locator, Page} from '@playwright/test'; | ||
import {s} from '../utils'; | ||
|
||
export class Authoring { | ||
protected page: Page; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
} | ||
|
||
async executeActionInEditor(...actionPath: Array<string>): Promise<void> { | ||
await this.page.locator(s('authoring-topbar', 'actions-button')).click(); | ||
|
||
const actionsWithoutLast = actionPath.slice(0, actionPath.length - 1); | ||
|
||
for (const action of actionsWithoutLast) { | ||
await this.page.locator(s('actions-list')).getByRole('button', {name: action}).hover(); | ||
} | ||
|
||
await this.page.locator(s('actions-list')) | ||
.getByRole('button', {name: actionPath[actionPath.length - 1]}) | ||
.click(); | ||
} | ||
|
||
field(field: string): Locator { | ||
return this.page.locator(s('authoring', field)).getByRole('textbox'); | ||
} | ||
} | ||
|
||
export class PictureAuthoring extends Authoring { | ||
async openMetadataEditor(): Promise<void> { | ||
await this.page.locator(s('authoring-field=media', 'image-overlay')).hover(); | ||
await this.page.locator(s('authoring-field=media', 'edit-metadata')).click(); | ||
} | ||
} |
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,19 @@ | ||
import {Locator, Page} from '@playwright/test'; | ||
import {s} from '../utils'; | ||
|
||
export class MediaEditor { | ||
private page: Page; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
} | ||
|
||
field(field: string): Locator { | ||
return this.page.locator(s('media-metadata-editor', field)).getByRole('textbox'); | ||
} | ||
|
||
async saveMetadata(): Promise<void> { | ||
await this.page.locator(s('media-editor', 'apply-metadata-button')).click(); | ||
await this.page.locator(s('change-image', 'done')).click(); | ||
} | ||
} |
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,21 @@ | ||
import {Page} from '@playwright/test'; | ||
import {s} from '../utils'; | ||
import path from 'path'; | ||
|
||
export class MediaUpload { | ||
private page: Page; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
} | ||
|
||
async selectFile(filename: string): Promise<void> { | ||
await this.page.locator(s('file-upload', 'select-file-button')).click(); | ||
await this.page.locator(s('file-upload', 'image-upload-input')) | ||
.setInputFiles(path.join('test-files', filename)); | ||
} | ||
|
||
async startUpload(): Promise<void> { | ||
await this.page.locator(s('file-upload', 'multi-image-edit--start-upload')).click(); | ||
} | ||
} |
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.
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
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
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
Oops, something went wrong.