File size: 1,731 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
import { Locator, Page } from 'playwright';
import { getCalypsoURL } from '../../data-helper';
/**
* Represents the Users > Subscribers page.
*/
export class SubscribersPage {
private page: Page;
private anchor: Locator;
/**
* Constructs an instance of the component.
*
* @param {Page} page The underlying page
*/
constructor( page: Page ) {
this.page = page;
this.anchor = this.page.getByRole( 'main' );
}
/**
* Visits the page.
*
* @param {string} siteSlug Site slug.
*/
async visit( siteSlug: string ) {
await this.page.goto( getCalypsoURL( `subscribers/${ siteSlug }` ) );
}
/**
* Validate that supplied `text` matches at least one subscriber.
*
* @param {string} identifier Identifier to locate the subscriber by.
*/
async validateSubscriber( identifier: string ) {
await this.anchor.getByRole( 'cell' ).filter( { hasText: identifier } ).waitFor();
}
/**
* Given a subscriber identifier, removes the subscriber.
*
* @param {string} identifier Identifier to locate and remove.
*/
async removeSubscriber( identifier: string ) {
// First open the hamburger menu of the row containing the subscriber
// to remove.
await this.anchor
.getByRole( 'row' )
.filter( { hasText: identifier } )
.getByRole( 'button', { name: 'Actions' } )
.click();
// Click on the remove menu item.
await this.page.getByRole( 'menuitem', { name: 'Remove' } ).click();
// Confirm.
await this.page
.getByRole( 'dialog' )
.getByRole( 'button', { name: 'Remove subscriber' } )
.click();
// Ensure the subscriber is no longer present.
await this.anchor
.getByRole( 'row' )
.filter( { hasText: identifier } )
.waitFor( { state: 'detached' } );
}
}
|