File size: 2,322 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
/**
 * @group gutenberg
 * @group jetpack-wpcom-integration
 */

import {
	DataHelper,
	MediaHelper,
	EditorPage,
	TestAccount,
	StoryBlock,
	envVariables,
	getTestAccountByFeature,
	envToFeatureKey,
	TestFile,
} from '@automattic/calypso-e2e';
import { Page, Browser } from 'playwright';
import { ALT_TEST_IMAGE_PATH, TEST_IMAGE_PATH } from '../constants';

declare const browser: Browser;

/**
 * Isolated block test for the Story block due to accessiblity issues,
 * making it unable to be run using the BlockFlow pattern.
 *
 * @see https://github.com/Automattic/jetpack/issues/32976
 *
 * Keywords: Jetpack, Media Block, Story
 */
describe( DataHelper.createSuiteTitle( 'Blocks: Jetpack Story' ), function () {
	const features = envToFeatureKey( envVariables );
	const accountName = getTestAccountByFeature( features );
	const testFiles: TestFile[] = [];

	let page: Page;
	let testAccount: TestAccount;
	let editorPage: EditorPage;

	beforeAll( async () => {
		page = await browser.newPage();

		testAccount = new TestAccount( accountName );
		await testAccount.authenticate( page );

		for ( const path of [ TEST_IMAGE_PATH, ALT_TEST_IMAGE_PATH ] ) {
			const testFile = await MediaHelper.createTestFile( path );
			testFiles.push( testFile );
		}
	} );

	it( 'Start new post', async function () {
		editorPage = new EditorPage( page );

		await editorPage.visit( 'post', { siteSlug: testAccount.getSiteURL( { protocol: false } ) } );
		await editorPage.enterTitle( DataHelper.getRandomPhrase() );
	} );

	it( 'Add Story block', async function () {
		await editorPage.addBlockFromSidebar( StoryBlock.blockName, StoryBlock.blockEditorSelector, {
			noSearch: true,
		} );
	} );

	it( 'Upload images', async function () {
		const storyBlock = new StoryBlock( page );
		await storyBlock.upload( testFiles );
	} );

	it( 'Publish and visit post', async function () {
		// Must separate out the publish and visit steps here.
		// The single call used elsewhere checks whether
		// `getByRole('main')` resolves, which will fail with the Story
		// block due to https://github.com/Automattic/jetpack/issues/32976.
		const postURL = await editorPage.publish();
		await page.goto( postURL.href );
	} );

	it( 'Validate the published post', async function () {
		await StoryBlock.validatePublishedContent( page );
	} );
} );