File size: 1,915 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
/**
 * @group calypso-pr
 * @group calypso-release
 */

import {
	TestAccount,
	getTestAccountByFeature,
	envToFeatureKey,
	envVariables,
	DataHelper,
} from '@automattic/calypso-e2e';
import { Page, Browser } from 'playwright';

declare const browser: Browser;

/**
 * Verifies the /me endpoint is functional.
 *
 * See: https://github.com/Automattic/wp-calypso/issues/76266
 */
describe( 'Me: Smoke Test', function () {
	let page: Page;
	const accountName = getTestAccountByFeature( envToFeatureKey( envVariables ) );
	const testAccount = new TestAccount( accountName );

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

		await testAccount.authenticate( page );
	} );

	it( 'Navigate to /me', async function () {
		await page.goto( DataHelper.getCalypsoURL( 'me' ) );
	} );

	it.each( [
		{ target: 'Account Settings', endpoint: 'account' },
		{ target: 'Purchases', endpoint: 'purchases' },
		{ target: 'Security', endpoint: 'security' },
		{ target: 'Privacy', endpoint: 'privacy' },
		{ target: 'Notification Settings', endpoint: 'notifications' },
		{ target: 'Blocked Sites', endpoint: 'site-blocks' },
	] )( 'Navigate to Me > $target', async function ( { target, endpoint } ) {
		if ( envVariables.VIEWPORT_NAME === 'desktop' ) {
			await page
				.getByRole( 'navigation' )
				.getByRole( 'link', { name: target, exact: true } )
				.click();
		} else {
			// In mobile, the Me Sidebar requires odd interactions (clicking twice)
			// to interact and dismiss.
			// We do not want to codify wrong behavior.
			// See: https://github.com/Automattic/wp-calypso/issues/78356
			await page.goto( DataHelper.getCalypsoURL( `me/${ endpoint }` ) );
		}

		// Ensure the URL changes depending on the endpoint.
		await page.waitForURL( new RegExp( endpoint ) );
		// Ensure the heading title loads.
		await page.getByRole( 'main' ).getByRole( 'heading', { name: target } ).waitFor();
	} );
} );