From 4c33c9f6ac58f73890301d738ed12daf60cc025a Mon Sep 17 00:00:00 2001 From: clau <1281581+dualcnhq@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:28:05 +0800 Subject: [PATCH 1/2] create test default identifiers --- config/index.ts | 24 ++++++++++++++++++++++++ tests/fixtures.ts | 21 ++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/config/index.ts b/config/index.ts index d71ca927..c2d44e23 100644 --- a/config/index.ts +++ b/config/index.ts @@ -12,3 +12,27 @@ export const config = { password: process.env.A_PASSWORD || '', }, } + +export const identifier = { + books: { + default: '/details/theworksofplato01platiala' + }, + details: { + default: '/details/theworksofplato01platiala' + }, + home: { + default: '/' + }, + collection: { + default: 'oldtimeradio' + }, + profile: { + default: 'brewster' + }, + search: { + default: '/search' + }, + profileUploads: { + default: 'brewster/uploads' + }, +}; diff --git a/tests/fixtures.ts b/tests/fixtures.ts index 8130c3a0..f7eda16c 100644 --- a/tests/fixtures.ts +++ b/tests/fixtures.ts @@ -9,6 +9,17 @@ import { BookPage } from './page-objects/book-page'; import { DetailsPage } from './page-objects/details-page'; import { LoginPage } from './page-objects/login-page'; +import { identifier } from '../config'; +const { + books, + collection, + home, + details, + profile, + search, + profileUploads +} = identifier; + type PageFixtures = { detailsPage: DetailsPage; bookPage: BookPage; @@ -42,7 +53,7 @@ export const test = base.extend({ // Set up the fixture. const bookPage = new BookPage(page); - await page.goto('/details/theworksofplato01platiala'); + await page.goto(books.default); await page.route(/(analytics|fonts)/, route => { route.abort(); @@ -58,7 +69,7 @@ export const test = base.extend({ // Set up the fixture. const homePage = new HomePage(page); - await page.goto('/'); + await page.goto(home.default); await page.route(/(analytics|fonts)/, route => { route.abort(); @@ -87,7 +98,7 @@ export const test = base.extend({ collectionPage: async ({ page }, use) => { // Set up the fixture. const collectionPage = new CollectionPage(page); - await collectionPage.visit('oldtimeradio'); + await collectionPage.visit(collection.default); await page.route(/(analytics|fonts)/, route => { route.abort(); @@ -117,7 +128,7 @@ export const test = base.extend({ profilePage: async ({ page }, use) => { // Set up the fixture. const profilePage = new ProfilePage(page); - await profilePage.visit('brewster'); + await profilePage.visit(profile.default); await page.route(/(analytics|fonts)/, route => { route.abort(); @@ -175,7 +186,7 @@ export const test = base.extend({ profilePageUploads: async ({ page }, use) => { // Set up the fixture. const profilePage = new ProfilePage(page); - await profilePage.visit('brewster/uploads'); + await profilePage.visit(profileUploads.default); await page.route(/(analytics|fonts)/, route => { route.abort(); From fc590a2cdc17ddc59f02570ca132074ed2aaddbe Mon Sep 17 00:00:00 2001 From: clau <1281581+dualcnhq@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:55:36 +0800 Subject: [PATCH 2/2] add new change for login identifiers --- config/index.ts | 16 +++++++++++++++- tests/page-objects/login-page.ts | 9 +++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/config/index.ts b/config/index.ts index c2d44e23..11d2b8cf 100644 --- a/config/index.ts +++ b/config/index.ts @@ -14,25 +14,39 @@ export const config = { } export const identifier = { + accountSettings: { + url: '/account/index.php?settings=1', + }, books: { + url: '/details', default: '/details/theworksofplato01platiala' }, details: { + url: '/details', default: '/details/theworksofplato01platiala' }, home: { - default: '/' + url: '/', + default: '/' }, collection: { + url: '', default: 'oldtimeradio' }, + login: { + url: '/account/login', + default: '', + }, profile: { + url: '', default: 'brewster' }, search: { + url: '', default: '/search' }, profileUploads: { + url: '', default: 'brewster/uploads' }, }; diff --git a/tests/page-objects/login-page.ts b/tests/page-objects/login-page.ts index dcf90205..9ee3d051 100644 --- a/tests/page-objects/login-page.ts +++ b/tests/page-objects/login-page.ts @@ -1,8 +1,9 @@ import { type Page, Locator, expect } from '@playwright/test'; -import { config } from '../../config'; +import { config, identifier } from '../../config'; import { UserType } from '../models'; +const { accountSettings, login } = identifier; export class LoginPage { readonly authTemplate: Locator; @@ -17,7 +18,7 @@ export class LoginPage { async loginAs(user: UserType) { const asUser = user === 'privs' ? config.privUser : config.patronUser; - await this.page.goto('/account/login'); + await this.page.goto(login.url); await this.page.fill( 'input.form-element.input-email[type=email]', asUser.email, @@ -35,7 +36,7 @@ export class LoginPage { async assertAccountSettingsDisplayed() { await this.page.waitForTimeout(3000); - await this.page.goto('/account/index.php?settings=1'); + await this.page.goto(accountSettings.url); await this.page.waitForLoadState('networkidle', { timeout: 60000 }); await expect(this.authTemplate).toBeVisible(); @@ -62,7 +63,7 @@ export class LoginPage { } async notLoggedIn() { - await this.page.goto('/account/index.php?settings=1'); + await this.page.goto(accountSettings.url); await this.page.waitForLoadState('networkidle', { timeout: 60000 }); await expect(this.authTemplate).not.toBeVisible();