File tree Expand file tree Collapse file tree 5 files changed +38
-8
lines changed Expand file tree Collapse file tree 5 files changed +38
-8
lines changed Original file line number Diff line number Diff line change 2
2
export const username = "admin"
3
3
export const password = "password"
4
4
export const organization = "acme-crop"
5
- export const email = "admin@coder.com"
5
+ export const email = "admin@coder.com"
Original file line number Diff line number Diff line change
1
+ import { Page } from "@playwright/test"
2
+
3
+ export abstract class BasePom {
4
+ abstract readonly url : string
5
+
6
+ protected page : Page
7
+ protected baseURL : string | undefined
8
+
9
+ constructor ( baseURL : string | undefined , page : Page ) {
10
+ this . page = page
11
+ this . baseURL = baseURL
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ import { Page } from "@playwright/test"
2
+ import { BasePom } from "./BasePom"
3
+
4
+ export class ProjectsPage extends BasePom {
5
+ public get url ( ) : string {
6
+ return this . baseURL + "/projects"
7
+ }
8
+
9
+ constructor ( baseURL : string | undefined , page : Page ) {
10
+ super ( baseURL , page )
11
+ }
12
+ }
Original file line number Diff line number Diff line change 1
1
import { Page } from "@playwright/test"
2
+ import { BasePom } from "./BasePom"
2
3
3
- export class SignInPage {
4
- private page : Page
4
+ export class SignInPage extends BasePom {
5
+ public get url ( ) : string {
6
+ return this . baseURL + "/login"
7
+ }
5
8
6
- constructor ( page : Page ) {
7
- this . page = page
9
+ constructor ( baseURL : string | undefined , page : Page ) {
10
+ super ( baseURL , page )
8
11
}
9
12
10
13
async submitBuiltInAuthentication ( email : string , password : string ) : Promise < void > {
Original file line number Diff line number Diff line change 1
1
import { test } from "@playwright/test"
2
2
import { SignInPage } from "../pom"
3
3
import { email , password } from "../constants"
4
+ import ProjectPage from "../../pages/projects/[organization]/[project]"
4
5
5
- test ( "Login takes user to /projects" , async ( { page , baseURL } ) => {
6
+ test ( "Login takes user to /projects" , async ( { baseURL , page } ) => {
6
7
await page . goto ( baseURL + "/" , { waitUntil : "networkidle" } )
7
8
8
9
// Log-in with the default credentials we set up in the development server
9
- const signInPage = new SignInPage ( page )
10
+ const signInPage = new SignInPage ( baseURL , page )
10
11
await signInPage . submitBuiltInAuthentication ( email , password )
11
12
12
- await page . waitForNavigation ( { url : baseURL + "/projects" , waitUntil : "networkidle" } )
13
+ const projectsPage = new ProjectPage ( baseURL , page )
14
+ await page . waitForNavigation ( { url : projectsPage . url , waitUntil : "networkidle" } )
13
15
14
16
await page . waitForSelector ( "text=Projects" )
15
17
} )
You can’t perform that action at this time.
0 commit comments