Skip to content
Merged
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
32 changes: 30 additions & 2 deletions playwright/pages/item-metadata.page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Locator, Page, expect } from "@playwright/test";

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

class FieldLocatorService {
// Method returns an object containing both the Locator and the content/text Pattern
Expand Down Expand Up @@ -54,6 +54,7 @@ export default class ItemMetadataPage {
DEFAULT: "8b2b3160-c5d5-012f-d95c-58d385a7bc34",
SAMPLE1: "25a47180-c55f-012f-3759-58d385a7bc34", // Topics
SAMPLE2: "4649be20-9890-0138-2359-2360945aaf51", // Genres
SAMPLE3: "52ec6dd0-ff9e-012f-fa96-58d385a7bc34", // Type of Resource
};

async loadScenario(scenario: MetadataScenario): Promise<void> {
Expand Down Expand Up @@ -144,6 +145,7 @@ export default class ItemMetadataPage {
linkCount: 1,
},
];
static readonly EXPECTED_RESOURCE_TYPES = ["Still Image", "Text"];

constructor(page: Page) {
this.page = page;
Expand Down Expand Up @@ -219,7 +221,7 @@ export default class ItemMetadataPage {
this.descriptionText = this.descriptionHeading.locator("+ p");

// Type of Resource
this.typeHeading = this.page.getByText("Type of Resource", { exact: true });
this.typeHeading = this.page.getByText("Type of Resource");
this.typeText = this.typeHeading.locator("+ p");

// Languages
Expand Down Expand Up @@ -576,6 +578,32 @@ export default class ItemMetadataPage {
expect(actualTotalLinksFound).toEqual(expectedTotalLinkCount);
}

// Check Type of Resource links count
async verifyTypeCount(): Promise<void> {
const typeLinks = this.typeText.getByRole("link");
await expect(typeLinks).toHaveCount(
ItemMetadataPage.EXPECTED_RESOURCE_TYPES.length
);
}

// Check Type or Resource text values
async verifyTypeValues(): Promise<void> {
const actualTypes = await this.getNormalizedLinesFromLocator(this.typeText);
expect(actualTypes).toEqual(ItemMetadataPage.EXPECTED_RESOURCE_TYPES);
}

// Verify correct links for Type of Resource text
async verifyTypeLinks(): Promise<void> {
const typeLinks = this.typeText.getByRole("link");

for (let i = 0; i < ItemMetadataPage.EXPECTED_RESOURCE_TYPES.length; i++) {
const expectedText = ItemMetadataPage.EXPECTED_RESOURCE_TYPES[i];
const currentLink = typeLinks.nth(i);
await expect(currentLink).toHaveText(expectedText);
await expect(currentLink).toBeVisible();
}
}

async verifyRightsContent(): Promise<void> {
// Structural check: Ensure the element exists and is visible
await expect(this.rightsHeading).toBeVisible();
Expand Down
20 changes: 20 additions & 0 deletions playwright/tests/item-metadata.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,23 @@ test.describe("Verify Sample Record 2", () => {
});
});
});

test.describe("Verify Sample Record 3", () => {
test.beforeEach(async ({ page }) => {
await itemMetadataPage.loadScenario("SAMPLE3");
});

test.describe("Type of Resource", () => {
test("should include correct resource type values", async () => {
await itemMetadataPage.verifyTypeValues();
});

test("should contain the correct number of resource types", async () => {
await itemMetadataPage.verifyTypeCount();
});

test("should display resource types as links", async () => {
await itemMetadataPage.verifyTypeLinks();
});
});
});