Skip to content
Merged
Changes from 1 commit
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
Next Next commit
add scenario navigator for uuids
  • Loading branch information
jbdalton committed Jan 9, 2026
commit f7b5cacbc6eab321367adb926c53a8c35a912684
31 changes: 30 additions & 1 deletion playwright/pages/item-metadata.page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Locator, Page, expect } from "@playwright/test";

// sets which UUID is to be used for sample record navigation
export type MetadataScenario = "DEFAULT" | "SAMPLE1" | "SAMPLE2";

class FieldLocatorService {
// Method returns an object containing both the Locator and the content/text Pattern
public getNameLocatorAndPattern(
Expand All @@ -24,13 +27,39 @@ class FieldLocatorService {
// return locator values and full-text for assertions
return { locator: locator, pattern: fullExpectedPattern };
}

public getBasicLocator(
allEntryContainers: Locator,
expectedText: string
): { locator: Locator; pattern: RegExp } {
// Pattern: define pattern here
const basicExpectedPattern = new RegExp(`^${expectedText}$`, "i");

// Filter the general locator to find the specific container
const locator = allEntryContainers.filter({
hasText: basicExpectedPattern,
});

// return locator values and full-text for assertions
return { locator: locator, pattern: basicExpectedPattern };
}
}

export default class ItemMetadataPage {
readonly page: Page;
private locatorService = new FieldLocatorService();

static itemResultURL: string = "/items/8b2b3160-c5d5-012f-d95c-58d385a7bc34";
// Sample URL-Record Mapping
private static readonly SCENARIOS: Record<MetadataScenario, string> = {
DEFAULT: "8b2b3160-c5d5-012f-d95c-58d385a7bc34",
SAMPLE1: "25a47180-c55f-012f-3759-58d385a7bc34", // Topics
SAMPLE2: "4649be20-9890-0138-2359-2360945aaf51", // Genres
};

async loadScenario(scenario: MetadataScenario): Promise<void> {
const uuid = ItemMetadataPage.SCENARIOS[scenario];
await this.page.goto(`/items/${uuid}`);
}

// item-metadata
readonly itemDataHeader: Locator;
Expand Down