Skip to content

Commit

Permalink
fix(e2e, playwright): resolved mobile test failures preview.spec.ts (f…
Browse files Browse the repository at this point in the history
…reeCodeCamp#52519)

Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
  • Loading branch information
2 people authored and pull[bot] committed Feb 19, 2024
1 parent a76cc66 commit f0fc56c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions e2e/preview.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import translations from '../client/i18n/locales/english/translations.json';

test.beforeEach(async ({ page }) => {
Expand Down Expand Up @@ -27,9 +27,19 @@ test.describe('Challenge Preview Component', () => {

test('should render correct output of changed code', async ({
page,
browserName,
isMobile
}) => {
await page.getByLabel('Editor content').click();
// The editor has an overlay div, which prevents the click event from bubbling up in iOS Safari.
// This is a quirk in this browser-OS combination, and the workaround here is to use `.focus()`
// in place of `.click()` to focus on the editor.
// Ref: https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if (isMobile && browserName === 'webkit') {
await page.getByLabel('Editor content').focus();
} else {
await page.getByLabel('Editor content').click();
}

await page.keyboard.insertText('<h1>FreeCodeCamp</h1>');
if (isMobile) {
await page
Expand Down

0 comments on commit f0fc56c

Please sign in to comment.