Skip to content

Commit

Permalink
Merge pull request #2967 from clari182/feature/playwright-integration…
Browse files Browse the repository at this point in the history
…-cset

Feature/playwright integration cset
  • Loading branch information
pdcp1 authored Jul 12, 2024
2 parents 4a3405a + 563d3cb commit c966cb5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 57 deletions.
57 changes: 0 additions & 57 deletions site/gatsby-site/cypress/e2e/integration/cset.cy.js

This file was deleted.

56 changes: 56 additions & 0 deletions site/gatsby-site/playwright/e2e/integration/cset.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { expect, Page } from '@playwright/test';
import { gql } from '@apollo/client';
import { query, test } from '../../utils';

const urls = [
{ namespace: 'CSETv0', url: '/taxonomy/csetv0' },
{ namespace: 'CSETv1', url: '/taxonomy/csetv1' },
];

urls.forEach(({ namespace, url }) => {
test(`successfully loads ${namespace}`, async ({ page }) => {
await page.goto(url);
});

if (namespace === 'CSETv0') {
test(`Should render ${namespace} fields list and Searchable status`, async ({ page }) => {
await page.goto(url);

const fieldListQuery = gql`
{
taxa(query: { namespace_in: ["${namespace}"] }) {
namespace
field_list {
long_name
short_name
instant_facet
public
}
}
}
`;

const result = await query({
query: fieldListQuery,
});

const field_list = result.data.taxa.field_list.filter(
(entry) => (entry.public === null || entry.public) && entry.short_name !== 'Publish'
);

await expect(page.locator('[data-cy*="field-"]')).toHaveCount(field_list.length);

for (const field of field_list) {
const fieldLocator = page.locator('h3', { hasText: field.long_name.replace(/\s{2,}/g, ' ') });
await expect(fieldLocator).toBeVisible();

const searchableLocator = fieldLocator.locator('span', { hasText: 'Searchable in Discover App' });
if (field.instant_facet) {
await expect(searchableLocator.first()).toBeVisible();
} else {
await expect(searchableLocator.first()).not.toBeVisible();
}
}
});
}
});

0 comments on commit c966cb5

Please sign in to comment.