parent
cbfb17cc8a
commit
9ffb1d5b43
|
@ -43,7 +43,7 @@ test('should render the modal content correctly', async ({ page }) => {
|
|||
await expectToRenderResetModal(page);
|
||||
});
|
||||
|
||||
test('User can reset challenge', async ({ page, isMobile }) => {
|
||||
test('User can reset challenge', async ({ page, isMobile, browserName }) => {
|
||||
const initialText = 'CatPhotoApp';
|
||||
const initialFrame = page
|
||||
.frameLocator('iframe[title="challenge preview"]')
|
||||
|
@ -64,7 +64,7 @@ test('User can reset challenge', async ({ page, isMobile }) => {
|
|||
// Modify the text in the editor pane, clearing first, otherwise the existing
|
||||
// text will be selected before typing
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
await getEditors(page).fill(updatedText);
|
||||
await expect(updatedFrame).toBeVisible({ timeout: 10000 });
|
||||
|
||||
|
@ -160,7 +160,11 @@ test('should close when the user clicks the close button', async ({ page }) => {
|
|||
).toBeHidden();
|
||||
});
|
||||
|
||||
test('User can reset on a multi-file project', async ({ page, isMobile }) => {
|
||||
test('User can reset on a multi-file project', async ({
|
||||
page,
|
||||
isMobile,
|
||||
browserName
|
||||
}) => {
|
||||
const sampleText = 'function palindrome() { return true; }';
|
||||
|
||||
await page.goto(
|
||||
|
@ -168,7 +172,7 @@ test('User can reset on a multi-file project', async ({ page, isMobile }) => {
|
|||
);
|
||||
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
await getEditors(page).fill(sampleText);
|
||||
await expect(page.getByText(sampleText)).toBeVisible();
|
||||
|
||||
|
@ -198,7 +202,8 @@ test.describe('Signed in user', () => {
|
|||
|
||||
test('User can reset on a multi-file project after reloading and saving', async ({
|
||||
page,
|
||||
isMobile
|
||||
isMobile,
|
||||
browserName
|
||||
}) => {
|
||||
test.setTimeout(60000);
|
||||
const savedText = 'function palindrome() { return true; }';
|
||||
|
@ -210,7 +215,7 @@ test.describe('Signed in user', () => {
|
|||
|
||||
// This first edit should reappear after the reset
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
await getEditors(page).fill(savedText);
|
||||
await page.keyboard.press('Control+S');
|
||||
|
||||
|
@ -218,7 +223,7 @@ test.describe('Signed in user', () => {
|
|||
|
||||
// This second edit should be reset
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
await getEditors(page).fill(updatedText);
|
||||
|
||||
await page
|
||||
|
@ -237,7 +242,8 @@ test.describe('Signed in user', () => {
|
|||
|
||||
test('User can reset on a multi-file project without reloading', async ({
|
||||
page,
|
||||
isMobile
|
||||
isMobile,
|
||||
browserName
|
||||
}) => {
|
||||
test.setTimeout(60000);
|
||||
const savedText = 'function palindrome() { return true; }';
|
||||
|
@ -249,13 +255,13 @@ test.describe('Signed in user', () => {
|
|||
|
||||
// This first edit should reappear after the reset
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
await getEditors(page).fill(savedText);
|
||||
await page.keyboard.press('Control+S');
|
||||
|
||||
// This second edit should be reset
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
await getEditors(page).fill(updatedText);
|
||||
|
||||
await page
|
||||
|
|
|
@ -36,9 +36,11 @@ const completeFrontEndCert = async (page: Page) => {
|
|||
|
||||
const completeThreeChallenges = async ({
|
||||
page,
|
||||
browserName,
|
||||
isMobile
|
||||
}: {
|
||||
page: Page;
|
||||
browserName: string;
|
||||
isMobile: boolean;
|
||||
}) => {
|
||||
await page.goto(
|
||||
|
@ -64,7 +66,7 @@ const completeThreeChallenges = async ({
|
|||
await page.waitForURL(challenge.url);
|
||||
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
|
||||
await page.evaluate(
|
||||
async contents => await navigator.clipboard.writeText(contents),
|
||||
|
@ -80,9 +82,11 @@ const completeThreeChallenges = async ({
|
|||
|
||||
const completeTenChallenges = async ({
|
||||
page,
|
||||
browserName,
|
||||
isMobile
|
||||
}: {
|
||||
page: Page;
|
||||
browserName: string;
|
||||
isMobile: boolean;
|
||||
}) => {
|
||||
await page.goto(
|
||||
|
@ -136,7 +140,7 @@ const completeTenChallenges = async ({
|
|||
await page.waitForURL(challenge.url);
|
||||
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
|
||||
await page.evaluate(
|
||||
async contents => await navigator.clipboard.writeText(contents),
|
||||
|
|
|
@ -33,14 +33,15 @@ test.describe('Editor Component', () => {
|
|||
test.describe('Python Terminal', () => {
|
||||
test('should display error message when the user enters invalid code', async ({
|
||||
page,
|
||||
isMobile
|
||||
isMobile,
|
||||
browserName
|
||||
}) => {
|
||||
await page.goto(
|
||||
'learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-2'
|
||||
);
|
||||
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
// Then enter invalid code
|
||||
await page.keyboard.insertText('def');
|
||||
const preview = page.getByTestId('preview-pane');
|
||||
|
|
|
@ -79,6 +79,7 @@ test('Checks hotkeys when instruction is focused', async ({
|
|||
|
||||
test('Focuses on the submit button after tests passed', async ({
|
||||
page,
|
||||
browserName,
|
||||
isMobile
|
||||
}) => {
|
||||
const editor = getEditors(page);
|
||||
|
@ -87,7 +88,7 @@ test('Focuses on the submit button after tests passed', async ({
|
|||
name: 'Submit and go to next challenge'
|
||||
});
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
|
||||
await editor.fill(
|
||||
'<h2>Cat Photos</h2>\n<p>See more cat photos in our gallery.</p>'
|
||||
|
@ -99,6 +100,7 @@ test('Focuses on the submit button after tests passed', async ({
|
|||
|
||||
test('Prompts unauthenticated user to sign in to save progress', async ({
|
||||
page,
|
||||
browserName,
|
||||
isMobile
|
||||
}) => {
|
||||
await signout(page);
|
||||
|
@ -109,7 +111,7 @@ test('Prompts unauthenticated user to sign in to save progress', async ({
|
|||
name: 'Sign in to save your progress'
|
||||
});
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
|
||||
await editor.fill(
|
||||
'<h2>Cat Photos</h2>\n<p>See more cat photos in our gallery.</p>'
|
||||
|
|
|
@ -61,12 +61,13 @@ test.describe('Should take you to the next superblock (with editor solution)', (
|
|||
test('at the end of a superblock should take you to the superblock page with the current block hash', async ({
|
||||
page,
|
||||
isMobile,
|
||||
browserName,
|
||||
context
|
||||
}) => {
|
||||
await context.grantPermissions(['clipboard-read', 'clipboard-write']);
|
||||
await page.goto(rwdChallenge.url);
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
|
||||
await page.evaluate(
|
||||
async solution => await navigator.clipboard.writeText(solution.content),
|
||||
|
|
|
@ -70,14 +70,15 @@ test.describe('For classic challenges', () => {
|
|||
|
||||
test('shows test output when the tests are run', async ({
|
||||
page,
|
||||
isMobile
|
||||
isMobile,
|
||||
browserName
|
||||
}) => {
|
||||
const closeButton = page.getByRole('button', { name: 'Close' });
|
||||
await expect(page).toHaveTitle(
|
||||
'Basic HTML and HTML5: Say Hello to HTML Elements |' + ' freeCodeCamp.org'
|
||||
);
|
||||
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ browserName, page });
|
||||
await insertTextInCodeEditor({
|
||||
page,
|
||||
isMobile,
|
||||
|
@ -94,10 +95,11 @@ test.describe('For classic challenges', () => {
|
|||
|
||||
test('shows test output when the tests are triggered by the keyboard', async ({
|
||||
page,
|
||||
isMobile
|
||||
isMobile,
|
||||
browserName
|
||||
}) => {
|
||||
const closeButton = page.getByRole('button', { name: 'Close' });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ browserName, page });
|
||||
await insertTextInCodeEditor({
|
||||
page,
|
||||
isMobile,
|
||||
|
|
|
@ -6,7 +6,8 @@ test.use({ storageState: 'playwright/.auth/certified-user.json' });
|
|||
test.describe('Progress bar component', () => {
|
||||
test('Should appear with the correct content after the user has submitted their code', async ({
|
||||
page,
|
||||
isMobile
|
||||
isMobile,
|
||||
browserName
|
||||
}) => {
|
||||
await page.goto(
|
||||
'/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-3'
|
||||
|
@ -15,7 +16,7 @@ test.describe('Progress bar component', () => {
|
|||
// large. There's a bug that means `scrollIntoView` does not work in the
|
||||
// editor and so we have to pick less verbose challenges until that's fixed.
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
|
||||
await page.keyboard.insertText(
|
||||
'<html><body><h1>CatPhotoApp</h1><h2>Cat Photos</h2><p>See more cat photos in our gallery.</p></body></html>'
|
||||
|
@ -35,13 +36,14 @@ test.describe('Progress bar component', () => {
|
|||
|
||||
test('should appear in the completion modal after user has submitted their code', async ({
|
||||
page,
|
||||
isMobile
|
||||
isMobile,
|
||||
browserName
|
||||
}) => {
|
||||
await page.goto(
|
||||
'/learn/javascript-algorithms-and-data-structures/basic-javascript/declare-javascript-variables'
|
||||
);
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
|
||||
await page.keyboard.insertText('var myName;');
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ test.describe('JavaScript projects can be submitted and then viewed in /settings
|
|||
|
||||
test('projects are submitted and viewed correctly', async ({
|
||||
page,
|
||||
browserName,
|
||||
isMobile,
|
||||
request,
|
||||
context
|
||||
|
@ -148,7 +149,7 @@ test.describe('JavaScript projects can be submitted and then viewed in /settings
|
|||
);
|
||||
|
||||
await focusEditor({ page, isMobile });
|
||||
await clearEditor({ page });
|
||||
await clearEditor({ page, browserName });
|
||||
|
||||
await page.evaluate(
|
||||
async contents => await navigator.clipboard.writeText(contents),
|
||||
|
|
|
@ -24,7 +24,18 @@ export const focusEditor = async ({
|
|||
await getEditors(page).focus();
|
||||
};
|
||||
|
||||
export async function clearEditor({ page }: { page: Page }) {
|
||||
await page.keyboard.press('ControlOrMeta+a');
|
||||
export async function clearEditor({
|
||||
page,
|
||||
browserName
|
||||
}: {
|
||||
page: Page;
|
||||
browserName: string;
|
||||
}) {
|
||||
// TODO: replace with ControlOrMeta when it's supported
|
||||
if (browserName === 'webkit') {
|
||||
await page.keyboard.press('Meta+a');
|
||||
} else {
|
||||
await page.keyboard.press('Control+a');
|
||||
}
|
||||
await page.keyboard.press('Backspace');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue