Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WEBDEV-6814 Create test identifiers #56

Draft
wants to merge 2 commits into
base: collated-fix-me
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,41 @@ export const config = {
password: process.env.A_PASSWORD || '',
},
}

export const identifier = {
accountSettings: {
url: '/account/index.php?settings=1',
},
books: {
url: '/details',
default: '/details/theworksofplato01platiala'
},
details: {
url: '/details',
default: '/details/theworksofplato01platiala'
},
home: {
url: '/',
default: '/'
},
collection: {
url: '',
default: 'oldtimeradio'
},
login: {
url: '/account/login',
default: '',
},
profile: {
url: '',
default: 'brewster'
},
search: {
url: '',
default: '/search'
},
profileUploads: {
url: '',
default: 'brewster/uploads'
},
};
21 changes: 16 additions & 5 deletions tests/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,7 +53,7 @@ export const test = base.extend<PageFixtures>({
// 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();
Expand All @@ -58,7 +69,7 @@ export const test = base.extend<PageFixtures>({
// 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();
Expand Down Expand Up @@ -87,7 +98,7 @@ export const test = base.extend<PageFixtures>({
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();
Expand Down Expand Up @@ -117,7 +128,7 @@ export const test = base.extend<PageFixtures>({
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();
Expand Down Expand Up @@ -175,7 +186,7 @@ export const test = base.extend<PageFixtures>({
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();
Expand Down
9 changes: 5 additions & 4 deletions tests/page-objects/login-page.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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,
Expand All @@ -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();
Expand All @@ -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();
Expand Down