mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 18:18:27 -05:00
fix(tests): remove hard-coding + wait for responses (#56728)
Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
This commit is contained in:
committed by
GitHub
parent
07c3067db1
commit
4f2d879cd1
@@ -30,7 +30,7 @@ ports:
|
||||
tasks:
|
||||
- before: |
|
||||
echo '
|
||||
export COOKIE_DOMAIN=gitpod.io
|
||||
export COOKIE_DOMAIN=.gitpod.io
|
||||
export HOME_LOCATION=$(gp url 8000)
|
||||
export API_LOCATION=$(gp url 3000)
|
||||
export CHALLENGE_EDITOR_API_LOCATION=$(gp url 3200)
|
||||
@@ -45,7 +45,7 @@ tasks:
|
||||
docker compose up -d
|
||||
|
||||
- name: server
|
||||
before: export COOKIE_DOMAIN=gitpod.io && export HOME_LOCATION=$(gp url 8000) && export API_LOCATION=$(gp url 3000)
|
||||
before: export COOKIE_DOMAIN=.gitpod.io && export HOME_LOCATION=$(gp url 8000) && export API_LOCATION=$(gp url 3000)
|
||||
# init is not executed for prebuilt workspaces and restarts,
|
||||
# so we should put all the heavy initialization here
|
||||
init: >
|
||||
|
||||
@@ -36,7 +36,7 @@ test.describe('failed update flushing', () => {
|
||||
}) => {
|
||||
// Initially, the user has no completed challenges.
|
||||
const userRes = await request.get(
|
||||
'http://localhost:3000/user/get-session-user'
|
||||
new URL('/user/get-session-user', process.env.API_LOCATION).toString()
|
||||
);
|
||||
const completedChallenges = (await userRes.json()).user.developmentuser
|
||||
.completedChallenges;
|
||||
@@ -55,16 +55,27 @@ test.describe('failed update flushing', () => {
|
||||
|
||||
// The update epic sends two requests and this lets us wait for both.
|
||||
const submitRes = page
|
||||
.waitForResponse('http://localhost:3000/modern-challenge-completed')
|
||||
.waitForResponse(
|
||||
new URL(
|
||||
'/modern-challenge-completed',
|
||||
process.env.API_LOCATION
|
||||
).toString()
|
||||
)
|
||||
|
||||
.then(() =>
|
||||
page.waitForResponse('http://localhost:3000/modern-challenge-completed')
|
||||
page.waitForResponse(
|
||||
new URL(
|
||||
'/modern-challenge-completed',
|
||||
process.env.API_LOCATION
|
||||
).toString()
|
||||
)
|
||||
);
|
||||
|
||||
await page.reload();
|
||||
await submitRes;
|
||||
|
||||
const updatedUserRes = await request.get(
|
||||
'http://localhost:3000/user/get-session-user'
|
||||
new URL('/user/get-session-user', process.env.API_LOCATION).toString()
|
||||
);
|
||||
|
||||
// Now the user should have both completed challenges.
|
||||
|
||||
@@ -1,6 +1,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 curriculum from './fixtures/js-ads-projects.json';
|
||||
@@ -8,6 +9,7 @@ import { authedRequest } from './utils/request';
|
||||
|
||||
import { focusEditor, getEditors, clearEditor } from './utils/editor';
|
||||
import { isMacOS } from './utils/user-agent';
|
||||
import { alertToBeVisible } from './utils/alerts';
|
||||
|
||||
interface Meta {
|
||||
challengeOrder: { id: string; title: string }[];
|
||||
@@ -201,7 +203,7 @@ test.describe('JavaScript projects can be submitted and then viewed in /settings
|
||||
});
|
||||
await expect(solutionModal).toBeVisible();
|
||||
await solutionModal
|
||||
.getByRole('button', { name: 'Close' })
|
||||
.getByRole('button', { name: translations.buttons['close'] })
|
||||
.first()
|
||||
.click();
|
||||
// Wait for the modal to disappear before continue
|
||||
@@ -210,16 +212,23 @@ test.describe('JavaScript projects can be submitted and then viewed in /settings
|
||||
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: "I agree to freeCodeCamp's Academic Honesty Policy."
|
||||
name: translations.buttons['agree-honesty']
|
||||
})
|
||||
.click();
|
||||
|
||||
await alertToBeVisible(page, translations.buttons['accepted-honesty']);
|
||||
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: 'Claim Certification Legacy JavaScript Algorithms and Data Structures'
|
||||
})
|
||||
.click();
|
||||
|
||||
await alertToBeVisible(
|
||||
page,
|
||||
'@developmentuser, you have successfully claimed the Legacy JavaScript Algorithms and Data Structures Certification! Congratulations on behalf of the freeCodeCamp.org team!'
|
||||
);
|
||||
|
||||
const showCertLink = page.getByRole('link', {
|
||||
name: 'Show Certification Legacy JavaScript Algorithms and Data Structures'
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ test.describe('third-party donation tests', () => {
|
||||
);
|
||||
|
||||
await page.route(
|
||||
'http://localhost:3000/donate/charge-stripe-card',
|
||||
new URL('donate/charge-stripe-card', process.env.API_LOCATION).toString(),
|
||||
async route => {
|
||||
await route.fulfill({ json: { isDonating: true } });
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ export async function addGrowthbookCookie({
|
||||
{
|
||||
name: 'gbuuid',
|
||||
value: variation,
|
||||
domain: 'localhost',
|
||||
// Weirdly, it seems necessary to prefix the domain with a dot. This seems
|
||||
// to be a peculiarity of Playwright.
|
||||
domain: process.env.COOKIE_DOMAIN || 'localhost',
|
||||
path: '/',
|
||||
expires: Math.floor(Date.now() / 1000) + 400 * 24 * 60 * 60 // 400 days from now
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user