e2e-tests: switch to running new e2e tests only for frontend
Co-authored-by: Fredrik Adelöw <freben@gmail.com> Co-authored-by: Johan Haals <johan.haals@gmail.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
"handlebars": "^4.7.3",
|
||||
"mysql2": "^2.2.5",
|
||||
"pgtools": "^1.0.0",
|
||||
"puppeteer": "^17.0.0",
|
||||
"tree-kill": "^1.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -20,13 +20,11 @@ import fetch from 'cross-fetch';
|
||||
import handlebars from 'handlebars';
|
||||
import killTree from 'tree-kill';
|
||||
import { resolve as resolvePath, join as joinPath } from 'path';
|
||||
import puppeteer from 'puppeteer';
|
||||
import path from 'path';
|
||||
|
||||
import {
|
||||
spawnPiped,
|
||||
runPlain,
|
||||
waitForPageWithText,
|
||||
waitFor,
|
||||
waitForExit,
|
||||
print,
|
||||
@@ -42,6 +40,7 @@ const paths = findPaths(__dirname);
|
||||
|
||||
const templatePackagePaths = [
|
||||
'packages/cli/templates/default-plugin/package.json.hbs',
|
||||
'packages/create-app/templates/default-app/package.json.hbs',
|
||||
'packages/create-app/templates/default-app/packages/app/package.json.hbs',
|
||||
'packages/create-app/templates/default-app/packages/backend/package.json.hbs',
|
||||
];
|
||||
@@ -66,8 +65,11 @@ export async function run() {
|
||||
print('Creating a Backstage Backend Plugin');
|
||||
await createPlugin({ appDir, pluginId, select: 'backend-plugin' });
|
||||
|
||||
print('Starting the app');
|
||||
await testAppServe(pluginId, appDir);
|
||||
print(`Running 'yarn test:e2e' in newly created app with new plugin`);
|
||||
await runPlain(['yarn', 'test:e2e'], {
|
||||
cwd: appDir,
|
||||
env: { ...process.env, CI: undefined },
|
||||
});
|
||||
|
||||
if (
|
||||
Boolean(process.env.POSTGRES_USER) ||
|
||||
@@ -297,15 +299,6 @@ async function createApp(
|
||||
await runPlain(['yarn', cmd], { cwd: appDir });
|
||||
}
|
||||
|
||||
print(`Running 'yarn test:e2e:ci' in newly created app`);
|
||||
await runPlain(['yarn', 'test:e2e:ci'], {
|
||||
cwd: resolvePath(appDir, 'packages', 'app'),
|
||||
env: {
|
||||
...process.env,
|
||||
APP_CONFIG_app_baseUrl: '"http://localhost:3001"',
|
||||
},
|
||||
});
|
||||
|
||||
return appDir;
|
||||
} finally {
|
||||
child.kill();
|
||||
@@ -381,63 +374,6 @@ async function createPlugin(options: {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start serving the newly created app and make sure that the create plugin is rendering correctly
|
||||
*/
|
||||
async function testAppServe(pluginId: string, appDir: string) {
|
||||
const startApp = spawnPiped(['yarn', 'start'], {
|
||||
cwd: appDir,
|
||||
env: {
|
||||
...process.env,
|
||||
GITHUB_TOKEN: 'abc',
|
||||
},
|
||||
});
|
||||
|
||||
let successful = false;
|
||||
|
||||
let browser;
|
||||
try {
|
||||
for (let attempts = 1; ; attempts++) {
|
||||
try {
|
||||
browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
|
||||
await page.goto('http://localhost:3000', { waitUntil: 'networkidle0' });
|
||||
|
||||
await waitForPageWithText(page, '/', 'My Company Catalog');
|
||||
await waitForPageWithText(
|
||||
page,
|
||||
`/${pluginId}`,
|
||||
`Welcome to ${pluginId}!`,
|
||||
);
|
||||
|
||||
print('Both App and Plugin loaded correctly');
|
||||
successful = true;
|
||||
break;
|
||||
} catch (error) {
|
||||
if (attempts >= 20) {
|
||||
throw new Error(`App serve test failed, ${error}`);
|
||||
}
|
||||
print(`App serve failed, trying again, ${error}`);
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
// Kill entire process group, otherwise we'll end up with hanging serve processes
|
||||
await new Promise<void>((res, rej) => {
|
||||
killTree(startApp.pid!, err => (err ? rej(err) : res()));
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await waitForExit(startApp);
|
||||
} catch (error) {
|
||||
if (!successful) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Drops PG databases */
|
||||
async function dropDB(database: string, client: string) {
|
||||
try {
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
ChildProcess,
|
||||
} from 'child_process';
|
||||
import { promisify } from 'util';
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
const execFile = promisify(execFileCb);
|
||||
|
||||
@@ -125,50 +124,6 @@ export async function waitForExit(child: ChildProcess) {
|
||||
);
|
||||
}
|
||||
|
||||
export async function waitForPageWithText(
|
||||
page: puppeteer.Page,
|
||||
path: string,
|
||||
text: string,
|
||||
{ intervalMs = 1000, maxFindAttempts = 50 } = {},
|
||||
) {
|
||||
let findAttempts = 0;
|
||||
for (;;) {
|
||||
try {
|
||||
const waitTimeMs = intervalMs * (findAttempts + 1);
|
||||
console.log(`Attempting to load page at ${path}, waiting ${waitTimeMs}`);
|
||||
await new Promise(resolve => setTimeout(resolve, waitTimeMs));
|
||||
|
||||
await page.goto(`http://localhost:3000${path}`, {
|
||||
waitUntil: 'networkidle0',
|
||||
});
|
||||
|
||||
const match = await page.evaluate(
|
||||
textContent =>
|
||||
Array.from(document.querySelectorAll('*')).some(
|
||||
el => el.textContent === textContent,
|
||||
),
|
||||
text,
|
||||
);
|
||||
|
||||
if (!match) {
|
||||
throw new Error(`Expected to find text ${text}`);
|
||||
}
|
||||
|
||||
break;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
assertError(error);
|
||||
|
||||
findAttempts++;
|
||||
if (findAttempts >= maxFindAttempts) {
|
||||
throw new Error(
|
||||
`Failed to load page '${path}', max number of attempts reached`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function print(msg: string) {
|
||||
return process.stdout.write(`${msg}\n`);
|
||||
}
|
||||
|
||||
@@ -4180,7 +4180,7 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@backstage/e2e-test-utils@workspace:packages/e2e-test-utils":
|
||||
"@backstage/e2e-test-utils@workspace:*, @backstage/e2e-test-utils@workspace:packages/e2e-test-utils":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/e2e-test-utils@workspace:packages/e2e-test-utils"
|
||||
dependencies:
|
||||
@@ -18469,7 +18469,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/yauzl@npm:^2.10.0, @types/yauzl@npm:^2.9.1":
|
||||
"@types/yauzl@npm:^2.10.0":
|
||||
version: 2.10.0
|
||||
resolution: "@types/yauzl@npm:2.10.0"
|
||||
dependencies:
|
||||
@@ -20737,7 +20737,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"buffer@npm:^5.2.1, buffer@npm:^5.5.0":
|
||||
"buffer@npm:^5.5.0":
|
||||
version: 5.7.1
|
||||
resolution: "buffer@npm:5.7.1"
|
||||
dependencies:
|
||||
@@ -22377,15 +22377,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"cross-fetch@npm:3.1.5":
|
||||
version: 3.1.5
|
||||
resolution: "cross-fetch@npm:3.1.5"
|
||||
dependencies:
|
||||
node-fetch: 2.6.7
|
||||
checksum: f6b8c6ee3ef993ace6277fd789c71b6acf1b504fd5f5c7128df4ef2f125a429e29cd62dc8c127523f04a5f2fa4771ed80e3f3d9695617f441425045f505cf3bb
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"cross-fetch@npm:^3.1.3, cross-fetch@npm:^3.1.5, cross-fetch@npm:^3.1.8 <4":
|
||||
version: 3.1.8
|
||||
resolution: "cross-fetch@npm:3.1.8"
|
||||
@@ -23356,13 +23347,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"devtools-protocol@npm:0.0.1036444":
|
||||
version: 0.0.1036444
|
||||
resolution: "devtools-protocol@npm:0.0.1036444"
|
||||
checksum: 6975c8def95a5e1a4207d6deb05322e335d6a37bdaa3e589cbd5bde40fbbe3ab0df2cfedb1b3ad2785401f208c150fd489a6a065a4624b56e4c0c4c1bfd89172
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dezalgo@npm:^1.0.0, dezalgo@npm:^1.0.4":
|
||||
version: 1.0.4
|
||||
resolution: "dezalgo@npm:1.0.4"
|
||||
@@ -23722,7 +23706,6 @@ __metadata:
|
||||
mysql2: ^2.2.5
|
||||
nodemon: ^3.0.1
|
||||
pgtools: ^1.0.0
|
||||
puppeteer: ^17.0.0
|
||||
tree-kill: ^1.2.2
|
||||
ts-node: ^10.0.0
|
||||
bin:
|
||||
@@ -25275,6 +25258,7 @@ __metadata:
|
||||
"@material-ui/lab": 4.0.0-alpha.61
|
||||
"@octokit/rest": ^19.0.3
|
||||
"@oriflame/backstage-plugin-score-card": ^0.7.0
|
||||
"@playwright/test": ^1.32.3
|
||||
"@roadiehq/backstage-plugin-buildkite": ^2.0.8
|
||||
"@roadiehq/backstage-plugin-github-insights": ^2.0.5
|
||||
"@roadiehq/backstage-plugin-github-pull-requests": ^2.2.7
|
||||
@@ -25652,23 +25636,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"extract-zip@npm:2.0.1":
|
||||
version: 2.0.1
|
||||
resolution: "extract-zip@npm:2.0.1"
|
||||
dependencies:
|
||||
"@types/yauzl": ^2.9.1
|
||||
debug: ^4.1.1
|
||||
get-stream: ^5.1.0
|
||||
yauzl: ^2.10.0
|
||||
dependenciesMeta:
|
||||
"@types/yauzl":
|
||||
optional: true
|
||||
bin:
|
||||
extract-zip: cli.js
|
||||
checksum: 8cbda9debdd6d6980819cc69734d874ddd71051c9fe5bde1ef307ebcedfe949ba57b004894b585f758b7c9eeeea0e3d87f2dda89b7d25320459c2c9643ebb635
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"extsprintf@npm:1.3.0":
|
||||
version: 1.3.0
|
||||
resolution: "extsprintf@npm:1.3.0"
|
||||
@@ -27755,7 +27722,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"https-proxy-agent@npm:5.0.1, https-proxy-agent@npm:^5.0.0, https-proxy-agent@npm:^5.0.1":
|
||||
"https-proxy-agent@npm:^5.0.0, https-proxy-agent@npm:^5.0.1":
|
||||
version: 5.0.1
|
||||
resolution: "https-proxy-agent@npm:5.0.1"
|
||||
dependencies:
|
||||
@@ -33190,20 +33157,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"node-fetch@npm:2.6.7":
|
||||
version: 2.6.7
|
||||
resolution: "node-fetch@npm:2.6.7"
|
||||
dependencies:
|
||||
whatwg-url: ^5.0.0
|
||||
peerDependencies:
|
||||
encoding: ^0.1.0
|
||||
peerDependenciesMeta:
|
||||
encoding:
|
||||
optional: true
|
||||
checksum: 8d816ffd1ee22cab8301c7756ef04f3437f18dace86a1dae22cf81db8ef29c0bf6655f3215cb0cdb22b420b6fe141e64b26905e7f33f9377a7fa59135ea3e10b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"node-fetch@npm:^1.0.1":
|
||||
version: 1.7.3
|
||||
resolution: "node-fetch@npm:1.7.3"
|
||||
@@ -35712,13 +35665,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"progress@npm:2.0.3":
|
||||
version: 2.0.3
|
||||
resolution: "progress@npm:2.0.3"
|
||||
checksum: f67403fe7b34912148d9252cb7481266a354bd99ce82c835f79070643bb3c6583d10dbcfda4d41e04bbc1d8437e9af0fb1e1f2135727878f5308682a579429b7
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"prom-client@npm:^14.0.1":
|
||||
version: 14.2.0
|
||||
resolution: "prom-client@npm:14.2.0"
|
||||
@@ -35904,7 +35850,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"proxy-from-env@npm:1.1.0, proxy-from-env@npm:^1.1.0":
|
||||
"proxy-from-env@npm:^1.1.0":
|
||||
version: 1.1.0
|
||||
resolution: "proxy-from-env@npm:1.1.0"
|
||||
checksum: ed7fcc2ba0a33404958e34d95d18638249a68c430e30fcb6c478497d72739ba64ce9810a24f53a7d921d0c065e5b78e3822759800698167256b04659366ca4d4
|
||||
@@ -35977,25 +35923,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"puppeteer@npm:^17.0.0":
|
||||
version: 17.1.3
|
||||
resolution: "puppeteer@npm:17.1.3"
|
||||
dependencies:
|
||||
cross-fetch: 3.1.5
|
||||
debug: 4.3.4
|
||||
devtools-protocol: 0.0.1036444
|
||||
extract-zip: 2.0.1
|
||||
https-proxy-agent: 5.0.1
|
||||
progress: 2.0.3
|
||||
proxy-from-env: 1.1.0
|
||||
rimraf: 3.0.2
|
||||
tar-fs: 2.1.1
|
||||
unbzip2-stream: 1.4.3
|
||||
ws: 8.8.1
|
||||
checksum: b4518956c661df4c37690d46b9c6744d42d59d01fe3764938b4b3af8de4c94ef11a9dfa6bc261798f5e5490c6dce4d4f555f05d42c735249683da3017faf4585
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"pure-color@npm:^1.2.0":
|
||||
version: 1.3.0
|
||||
resolution: "pure-color@npm:1.3.0"
|
||||
@@ -37789,17 +37716,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"rimraf@npm:3.0.2, rimraf@npm:^3.0.0, rimraf@npm:^3.0.2":
|
||||
version: 3.0.2
|
||||
resolution: "rimraf@npm:3.0.2"
|
||||
dependencies:
|
||||
glob: ^7.1.3
|
||||
bin:
|
||||
rimraf: bin.js
|
||||
checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"rimraf@npm:^2.6.3":
|
||||
version: 2.7.1
|
||||
resolution: "rimraf@npm:2.7.1"
|
||||
@@ -37811,6 +37727,17 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"rimraf@npm:^3.0.0, rimraf@npm:^3.0.2":
|
||||
version: 3.0.2
|
||||
resolution: "rimraf@npm:3.0.2"
|
||||
dependencies:
|
||||
glob: ^7.1.3
|
||||
bin:
|
||||
rimraf: bin.js
|
||||
checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"rimraf@npm:~2.6.2":
|
||||
version: 2.6.3
|
||||
resolution: "rimraf@npm:2.6.3"
|
||||
@@ -37970,11 +37897,13 @@ __metadata:
|
||||
"@backstage/cli": "workspace:*"
|
||||
"@backstage/codemods": "workspace:*"
|
||||
"@backstage/create-app": "workspace:*"
|
||||
"@backstage/e2e-test-utils": "workspace:*"
|
||||
"@backstage/errors": "workspace:^"
|
||||
"@backstage/repo-tools": "workspace:*"
|
||||
"@changesets/cli": ^2.14.0
|
||||
"@manypkg/get-packages": ^1.1.3
|
||||
"@octokit/rest": ^19.0.3
|
||||
"@playwright/test": ^1.32.3
|
||||
"@spotify/eslint-plugin": ^14.1.3
|
||||
"@spotify/prettier-config": ^14.0.0
|
||||
"@techdocs/cli": "workspace:*"
|
||||
@@ -39964,7 +39893,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tar-fs@npm:2.1.1, tar-fs@npm:^2.0.0, tar-fs@npm:^2.1.1":
|
||||
"tar-fs@npm:^2.0.0, tar-fs@npm:^2.1.1":
|
||||
version: 2.1.1
|
||||
resolution: "tar-fs@npm:2.1.1"
|
||||
dependencies:
|
||||
@@ -41011,16 +40940,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"unbzip2-stream@npm:1.4.3":
|
||||
version: 1.4.3
|
||||
resolution: "unbzip2-stream@npm:1.4.3"
|
||||
dependencies:
|
||||
buffer: ^5.2.1
|
||||
through: ^2.3.8
|
||||
checksum: 0e67c4a91f4fa0fc7b4045f8b914d3498c2fc2e8c39c359977708ec85ac6d6029840e97f508675fdbdf21fcb8d276ca502043406f3682b70f075e69aae626d1d
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"unc-path-regex@npm:^0.1.2":
|
||||
version: 0.1.2
|
||||
resolution: "unc-path-regex@npm:0.1.2"
|
||||
@@ -42399,21 +42318,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ws@npm:8.8.1":
|
||||
version: 8.8.1
|
||||
resolution: "ws@npm:8.8.1"
|
||||
peerDependencies:
|
||||
bufferutil: ^4.0.1
|
||||
utf-8-validate: ^5.0.2
|
||||
peerDependenciesMeta:
|
||||
bufferutil:
|
||||
optional: true
|
||||
utf-8-validate:
|
||||
optional: true
|
||||
checksum: 2152cf862cae0693f3775bc688a6afb2e989d19d626d215e70f5fcd8eb55b1c3b0d3a6a4052905ec320e2d7734e20aeedbf9744496d62f15a26ad79cf4cf7dae
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ws@npm:^5.2.0 || ^6.0.0 || ^7.0.0, ws@npm:^7.4.6":
|
||||
version: 7.5.9
|
||||
resolution: "ws@npm:7.5.9"
|
||||
|
||||
Reference in New Issue
Block a user