File size: 916 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Page } from 'playwright';
import { EditorComponent } from './editor-component';

const panel = '.entities-saved-states__panel';
const selectors = {
	saveButton: `${ panel } button:has-text("Save")`,
};

/**
 * Represents an instance of the FSE save confirmation panel (comparable publish panel).
 */
export class FullSiteEditorSavePanelComponent {
	private page: Page;
	private editor: EditorComponent;

	/**
	 * Constructs an instance of the component.
	 *
	 * @param {Page} page The underlying page.
	 * @param {EditorComponent} editor The EditorComponent instance.
	 */
	constructor( page: Page, editor: EditorComponent ) {
		this.page = page;
		this.editor = editor;
	}

	/**
	 * Publish or schedule the article.
	 */
	async confirmSave(): Promise< void > {
		const editorParent = await this.editor.parent();
		const locator = editorParent.locator( selectors.saveButton );
		await locator.click();
	}
}