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 6 commits
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
58 changes: 40 additions & 18 deletions e2e/vertical-full-page-map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,41 @@ test.describe('full page map test suite', () => {
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);
await expect(locator).toHaveClass(/pinFocused/);
const results = page.locator('#js-answersVerticalResults div');
const count = await results.count();
let hasPinFocused = false;

for (var i = 0; i < count; i++) {
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
const currResult = await results.nth(i);
const classes = await currResult.evaluate(node => Array.from(node.classList));

if (classes.includes('yxt-Card--pinFocused')) {
hasPinFocused = true;
break;
}
}

expect(hasPinFocused).toBe(true);
});

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();
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
await page.mouse.wheel(600, 300);
const response = await page.waitForResponse(resp =>
resp.url().includes('https:\/\/prod-cdn\.us\.yextapis\.com\/v2\/accounts\/me\/search\/vertical\/query'));
await expect(response.status()).toBe(200);
nmanu1 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
const responsePromise = await 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();
const response = responsePromise;
await page.locator('div').filter({ hasText: /^Search This Area$/ }).nth(1).click();
await page.mouse.move(1200, 450, {steps: 5});
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
const response = await page.waitForResponse(resp =>
resp.url().includes('https:\/\/prod-cdn\.us\.yextapis\.com\/v2\/accounts\/me\/search\/vertical\/query'));
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
await expect(response.status()).toBe(200);
});

test('default initial search works and is enabled by default', async ({ page }) => {
Expand Down Expand Up @@ -69,6 +83,10 @@ test.describe('full page map with filters test suite', () => {
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');
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')
&& !resp.url().includes('filters'));
await expect(response.status()).toBe(200);
});

test('clicking on a pin closes the filter view', async ({ page }) => {
Expand All @@ -81,16 +99,20 @@ test.describe('full page map with filters test suite', () => {
});

test('clicking on a cluster causes the map to zoom in', async ({ page }) => {
const mapboxPinCount = await page.locator('#js-answersMap div').count();
const originalCount = await page.locator('.yxt-Card').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);
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')
&& resp.url().includes('filters'));
await expect(response.status()).toBe(200);
const countAfterSelectingCluster = await page.locator('.yxt-Card').count();
expect(originalCount).toBeGreaterThan(countAfterSelectingCluster);
});

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 = await page.locator('#js-answersVerticalResults').count();
await page.getByRole('button', { name: 'Cluster of 4 results' }).click();
const responsePromise = await page.waitForResponse(/https:\/\/prod-cdn\.us\.yextapis\.com\/v2\/accounts\/me\/search\/vertical/i);
const response = responsePromise;
const response = await page.waitForResponse(resp =>
resp.url().includes('https:\/\/prod-cdn\.us\.yextapis\.com\/v2\/accounts\/me\/search\/vertical\/query'));
await expect(response.status()).toBe(200);
});
});
8 changes: 4 additions & 4 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export default defineConfig({
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
...(process.env.CI ? [] : [{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
}]),
],

/* Run your local dev server before starting the tests */
Expand Down
Loading
Loading