mirror of
				https://github.com/filebrowser/filebrowser.git
				synced 2025-10-31 17:23:09 +00:00 
			
		
		
		
	 5100e587d7
			
		
	
	
		5100e587d7
		
			
		
	
	
	
	
		
			
			--------- Co-authored-by: Joep <jcbuhre@gmail.com> Co-authored-by: Omar Hussein <omarmohammad1951@gmail.com> Co-authored-by: Oleg Lobanov <oleg@lobanov.me>
		
			
				
	
	
		
			41 lines
		
	
	
		
			965 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			965 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import {
 | |
|   type Page,
 | |
|   type Locator,
 | |
|   test as base,
 | |
|   expect,
 | |
| } from "@playwright/test";
 | |
| 
 | |
| export class AuthPage {
 | |
|   public readonly wrongCredentials: Locator;
 | |
| 
 | |
|   constructor(public readonly page: Page) {
 | |
|     this.wrongCredentials = this.page.locator("div.wrong");
 | |
|   }
 | |
| 
 | |
|   async goto() {
 | |
|     await this.page.goto("/login");
 | |
|   }
 | |
| 
 | |
|   async loginAs(username = "admin", password = "admin") {
 | |
|     await this.page.getByPlaceholder("Username").fill(username);
 | |
|     await this.page.getByPlaceholder("Password").fill(password);
 | |
|     await this.page.getByRole("button", { name: "Login" }).click();
 | |
|   }
 | |
| 
 | |
|   async logout() {
 | |
|     await this.page.getByRole("button", { name: "Logout" }).click();
 | |
|   }
 | |
| }
 | |
| 
 | |
| const test = base.extend<{ authPage: AuthPage }>({
 | |
|   authPage: async ({ page }, use) => {
 | |
|     const authPage = new AuthPage(page);
 | |
|     await authPage.goto();
 | |
|     await authPage.loginAs();
 | |
|     await use(authPage);
 | |
|     // await authPage.logout();
 | |
|   },
 | |
| });
 | |
| 
 | |
| export { test, expect };
 |