Skip to content

Commit

Permalink
Add e2e tests for JS disabled search and menu
Browse files Browse the repository at this point in the history
  • Loading branch information
lhsazevedo committed Oct 12, 2024
1 parent afaaa2e commit 2f3da84
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions tests/EndToEnd/DisabledJavascriptTest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { test, expect } from '@playwright/test';
import { test, expect, devices } from '@playwright/test';

const httpHost = process.env.HTTP_HOST

if (typeof httpHost !== 'string') {
throw new Error('Environment variable "HTTP_HOST" is not set.')
}

test.beforeEach(async ({ page }) => {
await page.goto(httpHost);
});

test.use({ javaScriptEnabled: false });

test('search should fallback when javascript is disabled', async ({ page }) => {
await page.goto(httpHost);
let searchInput = await page.getByRole('searchbox', { name: 'Search docs' });
await searchInput.fill('strpos');
await searchInput.press('Enter');
Expand All @@ -23,3 +20,32 @@ test('search should fallback when javascript is disabled', async ({ page }) => {
await searchInput.press('Enter');
await expect(page).toHaveURL(`http://${httpHost}/manual-lookup.php?pattern=php+basics&scope=quickref`);
});

test('search should fallback when javascript is disabled on mobile', async ({ browser }) => {
const context = await browser.newContext({
...devices['iPhone SE']
});
const page = await context.newPage();
await page.goto(httpHost);
await page
.getByRole('link', { name: 'Search docs' })
.click();
await expect(page).toHaveURL(`http://${httpHost}/lookup-form.php`);

const searchInput = await page.getByRole('searchbox', { name: 'Lookup docs' });
await searchInput.fill('strpos');
await searchInput.press('Enter');
await expect(page).toHaveURL(`http://${httpHost}/manual/en/function.strpos.php`);
});

test('menu should fallback when javascript is disabled on mobile', async ({ browser }) => {
const context = await browser.newContext({
...devices['iPhone SE']
});
const page = await context.newPage();
await page.goto(httpHost);
await page
.getByRole('link', { name: 'Menu' })
.click();
await expect(page).toHaveURL(`http://${httpHost}/menu.php`);
});

0 comments on commit 2f3da84

Please sign in to comment.