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

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

declare const browser: Browser;

/**
 * Tests the routing functionality of the dashboard under /v2.
 *
 * This test verifies that valid routes load correctly and
 * invalid routes show a 404 page.
 */
describe( 'Dashboard: Routing Test', function () {
	let page: Page;
	let dashboardPage: DashboardPage;
	const accountName = getTestAccountByFeature( envToFeatureKey( envVariables ) );
	const testAccount = new TestAccount( accountName );

	beforeAll( async function () {
		page = await browser.newPage();
		await testAccount.authenticate( page );
		dashboardPage = new DashboardPage( page );
	} );

	it( 'Main dashboard page loads successfully', async function () {
		await dashboardPage.visit();
		const isLoaded = await dashboardPage.isLoaded();
		expect( isLoaded ).toBe( true );
	} );

	it( 'Nonexistent path shows a 404 page', async function () {
		await dashboardPage.visitPath( 'unicorn' );
		await dashboardPage.is404Page();
	} );
} );