Skip to content

Commit 7612c2b

Browse files
committed
Minor tidy up
- rename article to feFixture in load-page - undo playwright.config changes used for testing - set local workers to 2 to improve stability
1 parent 197ef49 commit 7612c2b

File tree

4 files changed

+31
-33
lines changed

4 files changed

+31
-33
lines changed

dotcom-rendering/playwright.config.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ import { defineConfig, devices } from '@playwright/test';
33
const isDev = process.env.NODE_ENV !== 'production';
44

55
/**
6-
* Server port
7-
* local development: 3030
8-
* CI: 9000
6+
* The server port for local development or CI
97
*/
108
export const PORT = isDev ? 3030 : 9000;
11-
export const ORIGIN = `http://localhost:9000`;
9+
export const ORIGIN = `http://localhost:${PORT}`;
1210

1311
/**
1412
* See https://playwright.dev/docs/test-configuration.
@@ -23,7 +21,7 @@ export default defineConfig({
2321
// Retry on CI only
2422
retries: process.env.CI ? 3 : 1,
2523
// Workers run tests files in parallel
26-
workers: process.env.CI ? 4 : undefined,
24+
workers: process.env.CI ? 4 : 2,
2725
// Reporter to use. See https://playwright.dev/docs/test-reporters
2826
reporter: [['line'], ['html', { open: 'never' }]],
2927
// Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions
@@ -42,12 +40,12 @@ export default defineConfig({
4240
use: { ...devices['Desktop Chrome'] },
4341
},
4442
],
45-
// webServer: {
46-
// // On CI the server is already started so a no-op
47-
// command: ':',
48-
// url: ORIGIN,
49-
// reuseExistingServer: true,
50-
// stdout: 'pipe',
51-
// stderr: 'pipe',
52-
// },
43+
webServer: {
44+
// On CI the server is already started so a no-op
45+
command: isDev ? 'make dev' : ':',
46+
url: ORIGIN,
47+
reuseExistingServer: true,
48+
stdout: 'pipe',
49+
stderr: 'pipe',
50+
},
5351
});

dotcom-rendering/playwright/lib/load-page.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type LoadPageOptions = {
1717
overrides?: {
1818
configOverrides?: Record<string, unknown>;
1919
switchOverrides?: Record<string, unknown>;
20-
article?: FEArticle;
20+
feFixture?: FEArticle | FEFront;
2121
};
2222
};
2323

@@ -91,7 +91,7 @@ const validateJson = (path: string, json: unknown): FEArticle | FEFront => {
9191
} else if (path.startsWith('/Front')) {
9292
return validateAsFEFront(json);
9393
}
94-
throw new Error(`Unsupported URL for validating article: ${path}`);
94+
throw new Error(`Unsupported URL for validating payload for: ${path}`);
9595
};
9696

9797
/**
@@ -164,22 +164,22 @@ const loadPage = async ({
164164

165165
const cookies = await page.context().cookies();
166166

167-
// If overrides exist, but no article fixture we fetch it from Frontend
168-
const frontendPage = await (overrides.article
169-
? Promise.resolve(overrides.article)
167+
// If overrides exist, but no fixture is provided we fetch it from Frontend
168+
const frontendModel = await (overrides.feFixture
169+
? Promise.resolve(overrides.feFixture)
170170
: validateJson(
171171
path,
172172
await getFrontendJson(path, cookies, queryParams),
173173
));
174174

175-
// Apply the overrides to the article config and switches
175+
// Apply the config and switch overrides
176176
const postData = {
177-
...frontendPage,
177+
...frontendModel,
178178
config: {
179-
...frontendPage.config,
179+
...frontendModel.config,
180180
...overrides.configOverrides,
181181
switches: {
182-
...frontendPage.config.switches,
182+
...frontendModel.config.switches,
183183
...overrides.switchOverrides,
184184
},
185185
},

dotcom-rendering/playwright/tests/lightbox.e2e.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ test.describe('Lightbox', () => {
7777
await loadPage({
7878
page,
7979
path: '/Article',
80-
overrides: { article: photoEssayArticle },
80+
overrides: { feFixture: photoEssayArticle },
8181
});
8282

8383
await expectToNotBeVisible(page, '#gu-lightbox');
@@ -102,7 +102,7 @@ test.describe('Lightbox', () => {
102102
await loadPage({
103103
page,
104104
path: '/Article',
105-
overrides: { article: photoEssayArticle },
105+
overrides: { feFixture: photoEssayArticle },
106106
});
107107

108108
await expectToNotBeVisible(page, '#gu-lightbox');
@@ -124,7 +124,7 @@ test.describe('Lightbox', () => {
124124
await loadPage({
125125
page,
126126
path: '/Article',
127-
overrides: { article: photoEssayArticle },
127+
overrides: { feFixture: photoEssayArticle },
128128
});
129129

130130
await page.locator('article img').first().click({ force: true });
@@ -173,7 +173,7 @@ test.describe('Lightbox', () => {
173173
await loadPage({
174174
page,
175175
path: '/Article',
176-
overrides: { article: photoEssayArticle },
176+
overrides: { feFixture: photoEssayArticle },
177177
});
178178

179179
await expectToNotBeVisible(page, '#gu-lightbox');
@@ -265,7 +265,7 @@ test.describe('Lightbox', () => {
265265
await loadPage({
266266
page,
267267
path: '/Article',
268-
overrides: { article: photoEssayArticle },
268+
overrides: { feFixture: photoEssayArticle },
269269
});
270270

271271
// eq(6) here means the 7th button is clicked (base zero)
@@ -308,7 +308,7 @@ test.describe('Lightbox', () => {
308308
await loadPage({
309309
page,
310310
path: '/Article',
311-
overrides: { article: photoEssayArticle },
311+
overrides: { feFixture: photoEssayArticle },
312312
});
313313

314314
await page.locator('button.open-lightbox').nth(1).click();
@@ -359,7 +359,7 @@ test.describe('Lightbox', () => {
359359
await loadPage({
360360
page,
361361
path: '/Article',
362-
overrides: { article: photoEssayArticle },
362+
overrides: { feFixture: photoEssayArticle },
363363
});
364364

365365
await page.locator('button.open-lightbox').nth(1).click();
@@ -405,7 +405,7 @@ test.describe('Lightbox', () => {
405405
await loadPage({
406406
page,
407407
path: '/Article',
408-
overrides: { article: LiveBlog },
408+
overrides: { feFixture: LiveBlog },
409409
});
410410

411411
await page.locator('button.open-lightbox').nth(1).click();
@@ -436,7 +436,7 @@ test.describe('Lightbox', () => {
436436
await loadPage({
437437
page,
438438
path: '/Article',
439-
overrides: { article: photoEssayArticle },
439+
overrides: { feFixture: photoEssayArticle },
440440
});
441441

442442
await page.locator('button.open-lightbox').nth(1).click();
@@ -470,7 +470,7 @@ test.describe('Lightbox', () => {
470470
await loadPage({
471471
page,
472472
path: '/Article',
473-
overrides: { article: photoEssayArticle },
473+
overrides: { feFixture: photoEssayArticle },
474474
});
475475

476476
await expectToNotBeVisible(page, '#gu-lightbox');

dotcom-rendering/playwright/tests/signed-out.e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test.describe('Signed out readers', () => {
1313
await loadPage({
1414
page,
1515
path: '/Article',
16-
overrides: { article: standardArticle },
16+
overrides: { feFixture: standardArticle },
1717
});
1818

1919
await waitForIsland(page, 'DiscussionWeb');

0 commit comments

Comments
 (0)