mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(client): show project previews (#58761)
This commit is contained in:
committed by
GitHub
parent
552791879c
commit
0c754bf690
@@ -0,0 +1,86 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
import { test, expect, Page } from '@playwright/test';
|
||||
|
||||
import tributePage from './fixtures/tribute-page.json';
|
||||
|
||||
import { authedRequest } from './utils/request';
|
||||
|
||||
const unlockedProfile = {
|
||||
isLocked: false,
|
||||
showAbout: true,
|
||||
showCerts: true,
|
||||
showDonation: true,
|
||||
showHeatMap: true,
|
||||
showLocation: true,
|
||||
showName: true,
|
||||
showPoints: true,
|
||||
showPortfolio: true,
|
||||
showTimeLine: true
|
||||
};
|
||||
|
||||
async function expectPreviewToBeShown(page: Page) {
|
||||
await page
|
||||
.getByRole('button', { name: 'View Solution for Build a Tribute Page' })
|
||||
.first()
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: 'View Project' }).click();
|
||||
const modalHeading = page.getByRole('heading', {
|
||||
name: 'Build a Tribute Page',
|
||||
exact: true
|
||||
});
|
||||
await expect(modalHeading).toBeVisible();
|
||||
|
||||
const projectPreview = page.frameLocator('#fcc-project-preview-frame');
|
||||
await expect(projectPreview.getByText('Tribute page text')).toBeVisible();
|
||||
}
|
||||
|
||||
test.describe('Completed project preview', () => {
|
||||
test.use({ storageState: 'playwright/.auth/development-user.json' });
|
||||
|
||||
test.beforeEach(async ({ request }) => {
|
||||
execSync('node ./tools/scripts/seed/seed-demo-user');
|
||||
|
||||
await authedRequest({
|
||||
request,
|
||||
method: 'post',
|
||||
endpoint: '/modern-challenge-completed',
|
||||
data: {
|
||||
id: tributePage.id,
|
||||
challengeType: 14,
|
||||
files: [tributePage.htmlFile, tributePage.cssFile]
|
||||
}
|
||||
});
|
||||
|
||||
await authedRequest({
|
||||
request,
|
||||
endpoint: '/update-my-profileui',
|
||||
method: 'put',
|
||||
data: {
|
||||
profileUI: unlockedProfile
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('it should be viewable on the timeline', async ({ page }) => {
|
||||
await page.goto('/developmentuser');
|
||||
|
||||
if (!process.env.CI) {
|
||||
await page
|
||||
.getByRole('button', { name: 'Preview custom 404 page' })
|
||||
.click();
|
||||
}
|
||||
|
||||
await expect(
|
||||
page.getByRole('heading', { name: '@developmentuser' })
|
||||
).toBeVisible();
|
||||
|
||||
await expectPreviewToBeShown(page);
|
||||
});
|
||||
|
||||
test('it should be viewable on the settings page', async ({ page }) => {
|
||||
await page.goto('/settings');
|
||||
|
||||
await expectPreviewToBeShown(page);
|
||||
});
|
||||
});
|
||||
@@ -1,3 +1,5 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
import { test, expect } from '@playwright/test';
|
||||
import translations from '../client/i18n/locales/english/translations.json';
|
||||
import { authedRequest } from './utils/request';
|
||||
@@ -6,6 +8,10 @@ import { allowTrailingSlash } from './utils/url';
|
||||
const nextChallengeURL =
|
||||
'/learn/data-analysis-with-python/data-analysis-with-python-projects/demographic-data-analyzer';
|
||||
|
||||
test.beforeAll(() => {
|
||||
execSync('node ./tools/scripts/seed/seed-demo-user --certified-user');
|
||||
});
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(
|
||||
'/learn/data-analysis-with-python/data-analysis-with-python-projects/mean-variance-standard-deviation-calculator'
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"tribute-page-css": {
|
||||
"contents": "#image{max-width:100%;height:auto;display:block;margin:0 auto;}"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"tribute-page-html": {
|
||||
"contents": "<head><link rel=\"stylesheet\" href=\"styles.css\"></head><body><main id=\"main\"><div id=\"title\">D</div><div id=\"img-div\"><img id=\"image\" src=\"\" alt=\"D\" ><div id=\"img-caption\">s</div></div><div id=\"tribute-info\">s</div><a id=\"tribute-link\" href=\"\" target=\"_blank\">L</a></main></body></html>"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"id": "bd7158d8c442eddfaeb5bd18",
|
||||
"htmlFile": {
|
||||
"contents": "<head><link rel=\"stylesheet\" href=\"styles.css\"></head><body><main id=\"main\"><div id=\"title\">D</div><div id=\"img-div\"><img id=\"image\" src=\"\" alt=\"D\" ><div id=\"img-caption\">s</div></div><div id=\"tribute-info\">s</div><a id=\"tribute-link\" href=\"\" target=\"_blank\">L</a> Tribute page text</main></body></html>",
|
||||
"key": "indexhtml",
|
||||
"ext": "html",
|
||||
"name": "index",
|
||||
"history": ["index.html"]
|
||||
},
|
||||
"cssFile": {
|
||||
"contents": "#image{max-width:100%;height:auto;display:block;margin:0 auto;}",
|
||||
"key": "stylescss",
|
||||
"ext": "css",
|
||||
"name": "styles",
|
||||
"history": ["styles.css"]
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,7 @@ import { execSync } from 'child_process';
|
||||
import { test, expect, Page } from '@playwright/test';
|
||||
import { SuperBlocks } from '../shared/config/curriculum';
|
||||
import translations from '../client/i18n/locales/english/translations.json';
|
||||
import tributePageHtml from './fixtures/tribute-page-html.json';
|
||||
import tributePageCss from './fixtures/tribute-page-css.json';
|
||||
import tributePage from './fixtures/tribute-page.json';
|
||||
import curriculum from './fixtures/js-ads-projects.json';
|
||||
import { authedRequest } from './utils/request';
|
||||
|
||||
@@ -255,8 +254,8 @@ test.describe('Completion modal should be shown after submitting a project', ()
|
||||
await context.grantPermissions(['clipboard-read', 'clipboard-write']);
|
||||
|
||||
const tributeContent = [
|
||||
tributePageHtml['tribute-page-html'].contents,
|
||||
tributePageCss['tribute-page-css'].contents
|
||||
tributePage.htmlFile.contents,
|
||||
tributePage.cssFile.contents
|
||||
];
|
||||
|
||||
await page.goto(
|
||||
|
||||
Reference in New Issue
Block a user