-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement playwright acceptance tests for vertical full page map #1155
Changes from 1 commit
56b1688
9d556b4
83d05c1
43a8063
fd2bee8
ec8e130
766fad2
eb3436b
c71f355
c563add
843b6d6
3b781e0
980b667
f04d28a
8fd3fd2
b5318ba
f13569b
dc814cf
14de8da
45d6554
55f11bd
ae618ed
f5e4d76
6c58224
968720b
9464f5c
00e07cc
b639059
95365c5
9ea02e2
8466eca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Playwright Tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Install Playwright Browsers | ||
run: npx playwright install --with-deps | ||
- name: Run Playwright tests | ||
run: npx playwright test | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('full page map test suite', () => { | ||
test.beforeEach(async ({page}) => { | ||
await page.goto('http://localhost:5042/locations_full_page_map'); | ||
await page.getByPlaceholder('Search for locations').click(); | ||
nmanu1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
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(); | ||
likimmy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
test('clicking on a pin focuses on a result card', async ({ page }) => { | ||
await page.getByPlaceholder('Search for locations').fill('virginia'); | ||
nmanu1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await page.getByPlaceholder('Search for locations').press('Enter'); | ||
await page.getByRole('button', { name: 'Result number 5' }).click(); | ||
const locator = page.locator('#js-answersVerticalResults div').nth(134); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the 134 value here? is there another way to target it that is makes easier to understand what is being selected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from what I was able to see there isn't a better way to target this component. js-answersVerticalResults has several children, each of which have nested children as well and this is the only component i could use to drill down into the specific div that has the pinFocused class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it's possible to write a query that checks for the
likimmy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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); | ||
await page.mouse.down(); | ||
await page.mouse.move(1200, 450, {steps: 5}); | ||
await page.mouse.up(); | ||
await page.waitForSelector(searchLogo, { state: 'detached' }); | ||
const detachedSearchLogo = await page.$(searchLogo); | ||
expect(detachedSearchLogo).toBeFalsy(); | ||
likimmy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
test('search this area button works', async ({ page }) => { | ||
await page.getByPlaceholder('Search for locations').fill('virginia'); | ||
await page.getByPlaceholder('Search for locations').press('Enter'); | ||
nmanu1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// search bar yext logo remounts when search occurs | ||
likimmy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const searchLogo = '#js-yext-submit'; | ||
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(); | ||
}); | ||
|
||
test('default initial search works and is enabled by default', async ({ page }) => { | ||
await page.getByPlaceholder('Search for locations').press('Enter'); | ||
const result = await page.locator('#js-answersVerticalResults div').nth(0); | ||
await expect(result).toBeAttached(); | ||
nmanu1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
test('pagination works', async ({ page }) => { | ||
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 secondPage = page.locator('#js-answersVerticalResultsCount'); | ||
await expect(secondPage).toHaveText(/21/); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm cautious about this check because this would break if an entity is added to the account because it would change the results count. Another idea is checking the query params of the web page to see if the offset changed. But if it's too much effort I think we can stick with this because the slapshot test account is pretty stable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used 21 because the offset is set to 20 for each page, so i think as long as the results size is more than 20, even if the total results count changes the check for 21 should work, but let me know if i am misunderstanding your comment!
nmanu1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
test('pagination scrolls the results to the top', async ({ page }) => { | ||
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; | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should check the scrollTop of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was struggling getting the correct component because Answers.resultsWrapper didn't seem to work/have a scrollTop member. Instead I just checked if the first element of the results was visible, but let me know if this is not robust enough for what we are testing here! |
||
expect(isScrolledUp).toBe(true); | ||
}); | ||
|
||
}); | ||
|
||
test.describe('full page map with filters test suite', () => { | ||
test.beforeEach(async ({page}) => { | ||
await page.goto('http://localhost:5042/locations_full_page_map_with_filters'); | ||
await page.getByPlaceholder('Search for locations').fill('virginia'); | ||
await page.getByPlaceholder('Search for locations').press('Enter'); | ||
}); | ||
|
||
test('clicking on a pin closes the filter view', async ({ page }) => { | ||
await page.getByRole('button', { name: 'filter results' }).click(); | ||
await page.getByText('Cats (1)').click(); | ||
const filterView = page.getByLabel('Main location search').locator('div').filter({ hasText: 'Filters Services reset Cats (1) Dogs (1) Sleep (1)' }).first(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this text always be exactly like this? I'm worried the order/number might change. Would you be able to select the element using something like classname/label or do a regex match of the text? |
||
await expect(filterView).toBeVisible(); | ||
await page.getByRole('button', { name: 'Result number 1' }).click(); | ||
await expect(filterView).not.toBeVisible(); | ||
}); | ||
|
||
test('clicking on a cluster causes the map to zoom in', async ({ page }) => { | ||
const mapboxPinCount = await page.locator('#js-answersMap div').count(); | ||
await page.getByRole('button', { name: 'Cluster of 2 results' }).click(); | ||
const mapboxPinCountAfterSelectingCluster = await page.locator('#js-answersMap div').count(); | ||
expect(mapboxPinCount).not.toBe(mapboxPinCountAfterSelectingCluster); | ||
likimmy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
test('clicking on a cluster causes a new search to be run', async ({ page }) => { | ||
nmanu1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const numResults = page.locator('#js-answersVerticalResults').count(); | ||
await page.getByRole('button', { name: 'Cluster of 4 results' }).click(); | ||
const numResultsAfterSelectingCluster = await page.locator('#js-answersVerticalResults').count(); | ||
expect(numResults).not.toBe(numResultsAfterSelectingCluster); | ||
}); | ||
|
||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is duplicated, delete?