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

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

declare const browser: Browser;

/**
 * Tests authentication requirements for the dashboard under /v2.
 *
 * This test verifies that unauthenticated users are redirected to the login page.
 */
describe( 'Dashboard: Authentication Test', function () {
	let page: Page;
	let dashboardPage: DashboardPage;

	beforeAll( async function () {
		// Create a fresh page without authentication
		page = await browser.newPage();
		dashboardPage = new DashboardPage( page );
	} );

	it( 'Redirects to login page when visiting dashboard without authentication', async function () {
		// Try to visit the dashboard without authentication
		await dashboardPage.visit();

		// Wait for navigation to complete
		await page.waitForLoadState( 'networkidle' );

		// Verify that we've been redirected to the login page
		const currentUrl = new URL( page.url() );
		expect( currentUrl.pathname ).toEqual( '/log-in' );
	} );
} );