File size: 1,096 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
import { Page } from 'playwright';
import { NavbarComponent, MeSidebarComponent } from '../components';
import { AccountSettingsPage } from '../pages';
import type { LanguageSlug } from '@automattic/languages';

/**
 * Change the UI language.
 */
export class ChangeUILanguageFlow {
	private page: Page;

	/**
	 * Constructs an instance of the flow.
	 *
	 * @param {Page} page The underlying page.
	 */
	constructor( page: Page ) {
		this.page = page;
	}

	/**
	 * Changes the UI langauge.
	 *
	 * This method will navigate from the navbar to the /me page,
	 * then onto Account Settings.
	 */
	async changeUILanguage( localeSlug: LanguageSlug ): Promise< void > {
		const navbarComponent = new NavbarComponent( this.page );
		await navbarComponent.clickMe();

		const meSidebar = new MeSidebarComponent( this.page );
		await meSidebar.navigate( '/me/account' );

		const accountSettingsPage = new AccountSettingsPage( this.page );
		await accountSettingsPage.changeUILanguage( localeSlug );

		// Wait for settings save and page reload.
		await this.page.waitForLoadState( 'networkidle' );
	}
}