File size: 4,835 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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
/**
* @group editor-tracking
*/
import {
DataHelper,
EditorPage,
envVariables,
getTestAccountByFeature,
envToFeatureKey,
TestAccount,
EditorTracksEventManager,
FullSiteEditorPage,
HeaderBlock,
} from '@automattic/calypso-e2e';
import { Browser, Page } from 'playwright';
import { skipDescribeIf } from '../../jest-helpers';
declare const browser: Browser;
// None of these toolbar actions are available in mobile.
skipDescribeIf( envVariables.VIEWPORT_NAME === 'mobile' )(
DataHelper.createSuiteTitle( 'Editor tracking: Toolbar-related events' ),
function () {
const features = envToFeatureKey( envVariables );
describe( 'wpcom_block_editor_list_view_toggle/select', function () {
let page: Page;
let editorPage: EditorPage;
let editorTracksEventManager: EditorTracksEventManager;
beforeAll( async () => {
page = await browser.newPage();
const accountName = getTestAccountByFeature( features );
const testAccount = new TestAccount( accountName );
await testAccount.authenticate( page );
editorTracksEventManager = new EditorTracksEventManager( page );
editorPage = new EditorPage( page );
} );
it( 'Start a new post', async function () {
await editorPage.visit( 'post' );
await editorPage.waitUntilLoaded();
} );
it( 'Enter some text', async function () {
await editorPage.enterText( 'The actual text does not matter for this test.' );
} );
it( 'Toggle open the list view', async function () {
await editorPage.openListView();
} );
it( '"wpcom_block_editor_list_view_toggle" event fires with "is_open" set to true', async function () {
const eventDidFire = await editorTracksEventManager.didEventFire(
'wpcom_block_editor_list_view_toggle',
{
matchingProperties: {
is_open: true,
},
}
);
expect( eventDidFire ).toBe( true );
} );
it( 'Select paragphraph block in list view', async function () {
await editorPage.clickFirstListViewEntryByType( 'Paragraph' );
} );
it( '"wpcom_block_editor_list_view_select" event fires with correct "block_name" property', async function () {
const eventDidFire = await editorTracksEventManager.didEventFire(
'wpcom_block_editor_list_view_select',
{
matchingProperties: {
block_name: 'core/paragraph',
},
}
);
expect( eventDidFire ).toBe( true );
} );
it( 'Close the list view', async function () {
await editorPage.closeListView();
} );
it( '"wpcom_block_editor_list_view_toggle" event fires again with "is_open" set to false', async function () {
const eventDidFire = await editorTracksEventManager.didEventFire(
'wpcom_block_editor_list_view_toggle',
{
matchingProperties: {
is_open: false,
},
}
);
expect( eventDidFire ).toBe( true );
} );
it( 'Close the page', async function () {
await page.close();
} );
} );
describe( 'wpcom_block_editor_undo/redo_performed', function () {
let page: Page;
let fullSiteEditorPage: FullSiteEditorPage;
let editorTracksEventManager: EditorTracksEventManager;
let testAccount: TestAccount;
beforeAll( async () => {
page = await browser.newPage();
const accountName = getTestAccountByFeature( { ...features, variant: 'siteEditor' } );
testAccount = new TestAccount( accountName );
await testAccount.authenticate( page );
editorTracksEventManager = new EditorTracksEventManager( page );
fullSiteEditorPage = new FullSiteEditorPage( page );
} );
it( 'Go to site editor', async function () {
await fullSiteEditorPage.visit( testAccount.getSiteURL( { protocol: true } ) );
await fullSiteEditorPage.prepareForInteraction( { leaveWithoutSaving: true } );
} );
it( 'Close the navigation sidebar', async function () {
await fullSiteEditorPage.closeNavSidebar();
} );
it( 'Add a Header block', async function () {
await fullSiteEditorPage.addBlockFromSidebar(
HeaderBlock.blockName,
HeaderBlock.blockEditorSelector
);
} );
it( 'Undo action', async function () {
await fullSiteEditorPage.undo();
} );
it( '"wpcom_block_editor_undo_performed" event fires', async function () {
const eventDidFire = await editorTracksEventManager.didEventFire(
'wpcom_block_editor_undo_performed'
);
expect( eventDidFire ).toBe( true );
} );
it( 'Redo action', async function () {
await fullSiteEditorPage.redo();
} );
it( '"wpcom_block_editor_redo_performed" event fires', async function () {
const eventDidFire = await editorTracksEventManager.didEventFire(
'wpcom_block_editor_redo_performed'
);
expect( eventDidFire ).toBe( true );
} );
it( 'Close the page', async function () {
await page.close();
} );
} );
}
);
|