Skip to content
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

Merged
merged 31 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
56b1688
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
9d556b4
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
83d05c1
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
43a8063
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
fd2bee8
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
ec8e130
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
766fad2
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
eb3436b
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
c71f355
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
c563add
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
843b6d6
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
3b781e0
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
980b667
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
f04d28a
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
8fd3fd2
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
b5318ba
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
f13569b
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
dc814cf
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
14de8da
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
45d6554
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
55f11bd
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
ae618ed
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
f5e4d76
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
6c58224
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
968720b
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
9464f5c
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
00e07cc
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
b639059
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
95365c5
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
9ea02e2
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
8466eca
Implement playwright acceptance tests for vertical full page map
likimmy Nov 17, 2023
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
4 changes: 3 additions & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Playwright Tests

on: [push]
on:
push:
branches-ignore: dev/*

jobs:
test:
Expand Down
51 changes: 37 additions & 14 deletions e2e/vertical-full-page-map.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
import { test, expect } from '@playwright/test';

async function getAnswersVerticalResults(page) {
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
const result = page.locator('#js-answersVerticalResults div').nth(0);
await expect(result).toBeAttached();
}

test.describe('full page map test suite', () => {
test.beforeEach(async ({page}) => {
await page.goto('http://localhost:5042/locations_full_page_map');
});

test('can search and get results', async ({ page }) => {
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
const prevResponse = await page.waitForResponse(resp =>
resp.url().includes('https:\/\/prod-cdn\.us\.yextapis\.com\/v2\/accounts\/me\/search\/vertical\/query')
&& resp.url().includes('queryTrigger'));
const prevResponseJson = await prevResponse.json();
const prevResultsCount = prevResponseJson.resultsCount;

await page.getByPlaceholder('Search for locations').fill('virginia');
await page.getByPlaceholder('Search for locations').press('Enter');
const count = await page.locator('#js-answersVerticalResults').count();
expect(count).toBeGreaterThan(0);
const response = await page.waitForResponse(resp =>
resp.url().includes('https:\/\/prod-cdn\.us\.yextapis\.com\/v2\/accounts\/me\/search\/vertical\/query')
&& resp.url().includes('input=virginia'));
const responseJson = await response.json();
const resultsCount = responseJson.resultsCount;

expect(prevResultsCount).not.toBe(resultsCount);
});

test('clicking on a pin focuses on a result card', async ({ page }) => {
Expand All @@ -19,10 +35,7 @@ test.describe('full page map test suite', () => {
});

test('search when map moves 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
const result = page.locator('#js-answersVerticalResults div').nth(0);
await expect(result).toBeAttached();
await getAnswersVerticalResults(page);
const map = page.locator('.mapboxgl-canvas');
await map.dragTo(map, {
sourcePosition: { x: 788, y: 345},
Expand All @@ -49,20 +62,32 @@ test.describe('full page map test suite', () => {
});

test('default initial search works and is enabled by default', async ({ page }) => {
await page.getByPlaceholder('Search for locations').press('Enter');
const result = page.locator('#js-answersVerticalResults div').nth(0);
await expect(result).toBeAttached();
const response = await page.waitForResponse(resp =>
resp.url().includes('https:\/\/prod-cdn\.us\.yextapis\.com\/v2\/accounts\/me\/search\/vertical\/query')
&& resp.url().includes('queryTrigger'));
expect(response.status()).toBe(200);
});

test('empty search works', async ({ page }) => {
await page.getByPlaceholder('Search for locations').press('Enter');
const response = await page.waitForResponse(resp =>
resp.url().includes('https:\/\/prod-cdn\.us\.yextapis\.com\/v2\/accounts\/me\/search\/vertical\/query')
&& resp.url().includes('input=&'));
expect(response.status()).toBe(200);
})

test('pagination works', async ({ page }) => {
const firstPage = page.locator('#js-answersVerticalResultsCount');
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
await expect(firstPage).toHaveText(/20/);
await page.getByLabel('Go to the next page of results').click();
const secondPage = page.locator('#js-answersVerticalResultsCount');
await expect(secondPage).toHaveText(/21/);
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.getByLabel('Go to the next page of results').click();
const topOfResults = page.locator('#js-answersVerticalResults div').nth(0);
await expect(topOfResults).not.toBeVisible();
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
await page.getByLabel('Go to the next page of results').click();
await expect(topOfResults).toBeVisible();
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
});

Expand All @@ -88,8 +113,7 @@ test.describe('full page map with filters test suite', () => {
&& resp.url().includes('input=virginia')
&& !resp.url().includes('filters'));

const result = page.locator('#js-answersVerticalResults div').nth(0);
await expect(result).toBeAttached();
await getAnswersVerticalResults(page);

const originalCount = await page.locator('.yxt-Card').count();

Expand All @@ -98,8 +122,7 @@ test.describe('full page map with filters test suite', () => {
&& resp.url().includes('input=virginia')
&& resp.url().includes('filters'));

const newResult = page.locator('#js-answersVerticalResults div').nth(0);
await expect(newResult).toBeAttached();
await getAnswersVerticalResults(page);

const countAfterSelectingCluster = await page.locator('.yxt-Card').count();
expect(originalCount).toBeGreaterThan(countAfterSelectingCluster);
Expand Down
Loading