Skip to content

Commit

Permalink
Implement playwright acceptance tests for vertical full page map
Browse files Browse the repository at this point in the history
  • Loading branch information
likimmy committed Nov 20, 2023
1 parent 56b1688 commit 9d556b4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 51 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ node_modules
/blob-report/
/playwright/.cache/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
18 changes: 6 additions & 12 deletions e2e/vertical-full-page-map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ test.describe('full page map test suite', () => {
test('can search and get results', async ({ page }) => {
await page.getByPlaceholder('Search for locations').fill('virginia');
await page.getByPlaceholder('Search for locations').press('Enter');
await page.locator('#js-answersVerticalResults div').filter({ hasText: '1 Office Space 8.2 mi Close Card 7900 Westpark Drive Suite T200 McLean, VA 22102' }).nth(3).click();
const count = await page.locator('#js-answersVerticalResults').count();
expect(count).toBeGreaterThan(0);
});

test('clicking on a pin focuses on a result card', async ({ page }) => {
Expand All @@ -20,7 +21,6 @@ test.describe('full page map test suite', () => {
await expect(locator).toHaveClass(/pinFocused/);
});

// search when map moves works
test('search when map moves works', async ({ page }) => {
const searchLogo = '#js-yext-submit';
await page.mouse.move(600, 300);
Expand All @@ -35,13 +35,9 @@ test.describe('full page map test suite', () => {
test('search this area button works', async ({ page }) => {
await page.getByPlaceholder('Search for locations').fill('virginia');
await page.getByPlaceholder('Search for locations').press('Enter');
// search bar yext logo remounts when search occurs
const searchLogo = '#js-yext-submit';
const responsePromise = page.waitForResponse(/https:\/\/prod-cdn\.us\.yextapis\.com\/v2\/accounts\/me\/search\/vertical/i);
await page.getByLabel('Map controls').getByText('Search When Map Moves').click();
await page.locator('canvas').click();
await page.waitForSelector(searchLogo, { state: 'detached' });
const detachedSearchLogo = await page.$(searchLogo);
expect(detachedSearchLogo).toBeFalsy();
const response = await responsePromise;
});

test('default initial search works and is enabled by default', async ({ page }) => {
Expand All @@ -62,10 +58,8 @@ test.describe('full page map test suite', () => {
await page.getByPlaceholder('Search for locations').fill('virginia');
await page.getByPlaceholder('Search for locations').press('Enter');
await page.getByLabel('Go to the next page of results').click();
const isScrolledUp = await page.evaluate(() => {
return window.scrollY === 0;
});
expect(isScrolledUp).toBe(true);
const locator = page.locator('#js-answersVerticalResults div').nth(0);
await expect(locator).toBeVisible();
});

});
Expand Down
Loading

0 comments on commit 9d556b4

Please sign in to comment.