From 02ccd67ba5988682eede23e4c6aa468897b3f663 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 10 Jul 2024 12:29:57 -0300 Subject: [PATCH 1/3] Create cset.spec.ts --- .../playwright/e2e/integration/cset.spec.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 site/gatsby-site/playwright/e2e/integration/cset.spec.ts diff --git a/site/gatsby-site/playwright/e2e/integration/cset.spec.ts b/site/gatsby-site/playwright/e2e/integration/cset.spec.ts new file mode 100644 index 0000000000..3636a21b3d --- /dev/null +++ b/site/gatsby-site/playwright/e2e/integration/cset.spec.ts @@ -0,0 +1,56 @@ +import { test, expect, Page } from '@playwright/test'; +import { gql } from '@apollo/client'; +import { query } 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(); + } + } + }); + } +}); From 1a7f3623958dc0bf929db9677593a12d099fbdc4 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 10 Jul 2024 12:29:59 -0300 Subject: [PATCH 2/3] Delete cset.cy.js --- .../cypress/e2e/integration/cset.cy.js | 57 ------------------- 1 file changed, 57 deletions(-) delete mode 100644 site/gatsby-site/cypress/e2e/integration/cset.cy.js diff --git a/site/gatsby-site/cypress/e2e/integration/cset.cy.js b/site/gatsby-site/cypress/e2e/integration/cset.cy.js deleted file mode 100644 index 9f74d18a2c..0000000000 --- a/site/gatsby-site/cypress/e2e/integration/cset.cy.js +++ /dev/null @@ -1,57 +0,0 @@ -const { gql } = require('@apollo/client'); - -describe('The CSET taxonomy page', () => { - const urls = [ - { namespace: 'CSETv0', url: '/taxonomy/csetv0' }, - { namespace: 'CSETv1', url: '/taxonomy/csetv1' }, - ]; - - urls.forEach(({ namespace, url }) => { - it.skip(`successfully loads ${namespace}`, () => { - cy.visit(url); - }); - - it.skip(`Should render ${namespace} fields list and Searchable status`, () => { - cy.visit(url); - - cy.waitForStableDOM(); - - cy.query({ - query: gql` - { - taxa(query: { namespace_in: ["${namespace}"] }) { - namespace - field_list { - long_name - short_name - instant_facet - public - } - } - } - `, - }) - .then( - ({ - data: { - taxa: { field_list }, - }, - }) => { - return field_list.filter( - (entry) => (entry.public === null || entry.public) && entry.short_name !== 'Publish' - ); - } - ) - .then((field_list) => { - cy.get('[data-cy*="field-"]').should('have.length', field_list.length); - - field_list.forEach((field) => { - cy.contains('h3', field.long_name.replace(/\s{2,}/g, ' ')) - .should('exist') - .contains('span', 'Searchable in Discover App') - .should(field.instant_facet ? 'exist' : 'not.exist'); - }); - }); - }); - }); -}); From 563d3cb372318b8cf2e0374235f7536deebaa411 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 10 Jul 2024 14:04:44 -0300 Subject: [PATCH 3/3] Use test from utils --- site/gatsby-site/playwright/e2e/integration/cset.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/gatsby-site/playwright/e2e/integration/cset.spec.ts b/site/gatsby-site/playwright/e2e/integration/cset.spec.ts index 3636a21b3d..2725b68961 100644 --- a/site/gatsby-site/playwright/e2e/integration/cset.spec.ts +++ b/site/gatsby-site/playwright/e2e/integration/cset.spec.ts @@ -1,6 +1,6 @@ -import { test, expect, Page } from '@playwright/test'; +import { expect, Page } from '@playwright/test'; import { gql } from '@apollo/client'; -import { query } from '../../utils'; +import { query, test } from '../../utils'; const urls = [ { namespace: 'CSETv0', url: '/taxonomy/csetv0' },