test: remove several outdated E2E tests

Two tests related to the protractor builder have been removed (e2e-host & http-headers).
Two tests with existing integration tests have been removed (http-headers & proxy-config).
This commit is contained in:
Charles Lyding 2024-12-23 09:41:59 -05:00 committed by Alan Agius
parent a5618693a1
commit e648be602d
4 changed files with 0 additions and 144 deletions

View File

@ -1,24 +0,0 @@
import * as os from 'os';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
export default async function () {
const interfaces = Object.values(os.networkInterfaces()).flat() as os.NetworkInterfaceInfo[];
let host = '';
for (const { family, address, internal } of interfaces) {
if (family === 'IPv4' && !internal) {
host = address;
break;
}
}
await updateJsonFile('angular.json', (workspaceJson) => {
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.serve.options = appArchitect.serve.options || {};
appArchitect.serve.options.port = 8888;
appArchitect.serve.options.host = host;
});
await ng('e2e');
await ng('e2e', '--host', host);
}

View File

@ -1,35 +0,0 @@
import * as assert from 'assert';
import { killAllProcesses } from '../../utils/process';
import { ngServe } from '../../utils/project';
import { updateJsonFile } from '../../utils/project';
import { moveFile } from '../../utils/fs';
export default function () {
// TODO(architect): Delete this test. It is now in devkit/build-angular.
// should fallback to config.app[0].index (index.html by default)
return (
Promise.resolve()
.then(() => ngServe())
.then((port) => fetch(`http://localhost:${port}/`, { headers: { 'Accept': 'text/html' } }))
.then(async (response) => {
assert.strictEqual(response.status, 200);
assert.match(await response.text(), /<app-root><\/app-root>/);
})
.finally(() => killAllProcesses())
// should correctly fallback to a changed index
.then(() => moveFile('src/index.html', 'src/not-index.html'))
.then(() =>
updateJsonFile('angular.json', (workspaceJson) => {
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.index = 'src/not-index.html';
}),
)
.then(() => ngServe())
.then((port) => fetch(`http://localhost:${port}/`, { headers: { 'Accept': 'text/html' } }))
.then(async (response) => {
assert.strictEqual(response.status, 200);
assert.match(await response.text(), /<app-root><\/app-root>/);
})
);
}

View File

@ -1,42 +0,0 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
export default async function () {
// This test ensures that ng e2e serves the HTTP headers that are configured
// in the 'headers' field of the serve options. We do this by serving the
// strictest possible CSP headers (default-src 'none') which blocks loading of
// any resources (including scripts, styles and images) and should cause ng
// e2e to fail with a CSP-related error, which is asserted below.
await updateJsonFile('angular.json', (json) => {
const serve = json['projects']['test-project']['architect']['serve'];
if (!serve['options']) serve['options'] = {};
serve['options']['headers'] = {
'Content-Security-Policy': "default-src 'none'",
};
});
let errorMessage: string | null = null;
try {
await ng('e2e');
} catch (error) {
errorMessage = error instanceof Error ? error.message : null;
}
if (!errorMessage) {
throw new Error(
'Application loaded successfully, indicating that the CSP headers were not served.',
);
}
if (!errorMessage.match(/Refused to load/)) {
throw new Error('Expected to see CSP loading failure in error logs.');
}
}

View File

@ -1,43 +0,0 @@
import express from 'express';
import * as http from 'http';
import { writeFile } from '../../utils/fs';
import { ngServe } from '../../utils/project';
import { AddressInfo } from 'net';
import * as assert from 'assert';
export default function () {
// TODO(architect): Delete this test. It is now in devkit/build-angular.
// Create an express app that serves as a proxy.
const app = express();
const server = http.createServer(app);
server.listen(0);
app.set('port', (server.address() as AddressInfo).port);
app.get('/api/test', function (req, res) {
res.send('TEST_API_RETURN');
});
const backendHost = 'localhost';
const backendPort = (server.address() as AddressInfo).port;
const proxyServerUrl = `http://${backendHost}:${backendPort}`;
const proxyConfigFile = 'proxy.config.json';
const proxyConfig = {
'/api/*': {
target: proxyServerUrl,
},
};
return Promise.resolve()
.then(() => writeFile(proxyConfigFile, JSON.stringify(proxyConfig, null, 2)))
.then(() => ngServe('--proxy-config', proxyConfigFile))
.then((port) => fetch(`http://localhost:${port}/api/test`))
.then(async (response) => {
assert.strictEqual(response.status, 200);
assert.match(await response.text(), /TEST_API_RETURN/);
})
.finally(() => {
server.close();
});
}