| | import { BlockFlow, EditorContext, PublishedPostContext } from '.'; |
| |
|
| | |
| | |
| | interface ConfigurationData { |
| | firstEntry: string; |
| | secondEntry: string; |
| | } |
| |
|
| | const blockParentSelector = '[aria-label="Block: Timeline"]'; |
| | const selectors = { |
| | entryParagraph: ( nthIndex: number ) => |
| | `[aria-label="Block: Timeline Entry"]:nth-child(${ nthIndex }) [data-title=Paragraph]`, |
| | addEntryButton: `${ blockParentSelector } button:has-text("Add entry")`, |
| | }; |
| |
|
| | |
| | |
| | |
| | export class TimelineBlockFlow implements BlockFlow { |
| | private configurationData: ConfigurationData; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | constructor( configurationData: ConfigurationData ) { |
| | this.configurationData = configurationData; |
| | } |
| |
|
| | blockSidebarName = 'Timeline'; |
| | blockEditorSelector = blockParentSelector; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | async configure( context: EditorContext ): Promise< void > { |
| | const editorCanvas = await context.editorPage.getEditorCanvas(); |
| |
|
| | const firstParagraphLocator = editorCanvas.locator( selectors.entryParagraph( 1 ) ); |
| | await firstParagraphLocator.fill( this.configurationData.firstEntry ); |
| |
|
| | const addEntryButtonLocator = editorCanvas.locator( selectors.addEntryButton ); |
| | await addEntryButtonLocator.click(); |
| |
|
| | const secondParagraphLocator = editorCanvas.locator( selectors.entryParagraph( 2 ) ); |
| | await secondParagraphLocator.fill( this.configurationData.secondEntry ); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | async validateAfterPublish( context: PublishedPostContext ): Promise< void > { |
| | const expectedFirstTextLocator = context.page.locator( |
| | `main :text("${ this.configurationData.firstEntry }")` |
| | ); |
| | await expectedFirstTextLocator.waitFor(); |
| |
|
| | const expectedSecondTextLocator = context.page.locator( |
| | `main :text("${ this.configurationData.secondEntry }")` |
| | ); |
| | await expectedSecondTextLocator.waitFor(); |
| | } |
| | } |
| |
|