Skip to content

Commit 7f0b069

Browse files
authored
chore: change other instances of port 3000 being hardcoded in tests (#16290)
Changes the remaining instances of port 3000 being hard coded in our test suite
1 parent fcbc987 commit 7f0b069

23 files changed

Lines changed: 38 additions & 34 deletions

File tree

test/__helpers/shared/NextRESTClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class NextRESTClient {
7878

7979
private token: string
8080

81-
serverURL: string = 'http://localhost:3000'
81+
serverURL: string = `http://localhost:${process.env.PORT || 3000}`
8282

8383
constructor(config: SanitizedConfig) {
8484
this.config = config

test/__helpers/shared/getSDK.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const getSDK = (config: SanitizedConfig) => {
2121
baseURL: ``,
2222
fetch: (path: string, init: RequestInit) => {
2323
const [slugs, search] = path.slice(1).split('?')
24-
const url = `${config.serverURL || 'http://localhost:3000'}${config.routes.api}/${slugs}${search ? `?${search}` : ''}`
24+
const url = `${config.serverURL || `http://localhost:${process.env.PORT || 3000}`}${config.routes.api}/${slugs}${search ? `?${search}` : ''}`
2525

2626
if (init.body instanceof FormData) {
2727
const file = init.body.get('file') as Blob

test/admin-bar/app/admin-bar/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
1717
<PayloadAdminBar
1818
adminPath="/admin"
1919
apiPath="/api"
20-
cmsURL="http://localhost:3000"
20+
cmsURL={process.env.NEXT_PUBLIC_SERVER_URL || 'http://localhost:3000'}
2121
collection="pages"
2222
devMode
2323
id="1"

test/admin-root/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default buildConfigWithDefaults({
3131
},
3232
},
3333
},
34-
cors: ['http://localhost:3000', 'http://localhost:3001'],
34+
cors: [`http://localhost:${process.env.PORT || 3000}`, 'http://localhost:3001'],
3535
globals: [MenuGlobal],
3636
routes: {
3737
admin: adminRoute,

test/admin/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export default buildConfigWithDefaults({
155155
},
156156
livePreview: {
157157
collections: [reorderTabsSlug, editMenuItemsSlug],
158-
url: 'http://localhost:3000',
158+
url: `http://localhost:${process.env.PORT || 3000}`,
159159
},
160160
meta: {
161161
description: 'This is a custom meta description',

test/base-path/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default buildConfigWithDefaults({
1818
},
1919
],
2020
onInit: seed,
21-
serverURL: 'http://localhost:3000',
21+
serverURL: `http://localhost:${process.env.PORT || 3000}`,
2222
endpoints: [
2323
{
2424
handler: () => {

test/dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ nextEnvImport.updateInitialEnv(process.env)
7878

7979
// Open the admin if the -o flag is passed
8080
if (args.o) {
81-
await open(`http://localhost:3000${adminRoute}`)
81+
await open(`http://localhost:${process.env.PORT || 3000}${adminRoute}`)
8282
}
8383

8484
const findOpenPort = (startPort: number): Promise<number> => {

test/field-error-states/collections/PrevValue/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const PrevValue: CollectionConfig = {
3434

3535
try {
3636
const relatedDocs = await fetch(
37-
`http://localhost:3000/api/${collectionSlugs.prevValueRelation}${query}`,
37+
`http://localhost:${process.env.PORT || 3000}/api/${collectionSlugs.prevValueRelation}${query}`,
3838
{
3939
credentials: 'include',
4040
headers: {

test/lexical-mdx/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default buildConfigWithDefaults({
3232
},
3333
},
3434
editor: lexicalEditor({}),
35-
cors: ['http://localhost:3000', 'http://localhost:3001'],
35+
cors: [`http://localhost:${process.env.PORT || 3000}`, 'http://localhost:3001'],
3636
globals: [],
3737
onInit: async (payload) => {
3838
await payload.create({

test/lexical/collections/Lexical/e2e/blocks/e2e.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ describe('lexicalBlocks', () => {
12741274
test('ensure nested lexical field displays field label and description', async () => {
12751275
// Previously, we had the issue that nested lexical fields did not display the field label and description, as
12761276
// their client field configs were generated incorrectly on the server.
1277-
await page.goto('http://localhost:3000/admin/collections/LexicalInBlock?limit=10')
1277+
await page.goto(`${serverURL}/admin/collections/LexicalInBlock?limit=10`)
12781278

12791279
// Wait for table to be fully loaded
12801280
await expect(page.locator('tbody tr')).not.toHaveCount(0)
@@ -1326,7 +1326,7 @@ describe('lexicalBlocks', () => {
13261326
})
13271327

13281328
test('ensure individual inline blocks in lexical editor within a block have initial state on initial load', async () => {
1329-
await page.goto('http://localhost:3000/admin/collections/LexicalInBlock?limit=10')
1329+
await page.goto(`${serverURL}/admin/collections/LexicalInBlock?limit=10`)
13301330

13311331
// Wait for table to be fully loaded
13321332
await expect(page.locator('tbody tr')).not.toHaveCount(0)
@@ -1488,7 +1488,7 @@ describe('lexicalBlocks', () => {
14881488
})
14891489

14901490
test('ensure inline blocks restore their state after undoing a removal', async () => {
1491-
await page.goto('http://localhost:3000/admin/collections/LexicalInBlock?limit=10')
1491+
await page.goto(`${serverURL}/admin/collections/LexicalInBlock?limit=10`)
14921492

14931493
// Wait for table to be fully loaded
14941494
await expect(page.locator('tbody tr')).not.toHaveCount(0)

0 commit comments

Comments
 (0)