csp.test.js — astro Source File
Architecture documentation for csp.test.js, a javascript file in the astro codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 05610fae_d9b5_fddf_5146_3380c60eaa09["csp.test.js"] be670a78_841c_46e5_0af5_c5c328869ecb["test-adapter.js"] 05610fae_d9b5_fddf_5146_3380c60eaa09 --> be670a78_841c_46e5_0af5_c5c328869ecb 0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"] 05610fae_d9b5_fddf_5146_3380c60eaa09 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15 dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"] 05610fae_d9b5_fddf_5146_3380c60eaa09 --> dd4f09ce_3fd7_8295_f616_8876cda4555c e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] 05610fae_d9b5_fddf_5146_3380c60eaa09 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 05610fae_d9b5_fddf_5146_3380c60eaa09 --> 6b0635f9_51ea_77aa_767b_7857878e98a6 deb87372_5629_35f8_9a54_e755a08f776a["cheerio"] 05610fae_d9b5_fddf_5146_3380c60eaa09 --> deb87372_5629_35f8_9a54_e755a08f776a style 05610fae_d9b5_fddf_5146_3380c60eaa09 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import * as cheerio from 'cheerio';
import testAdapter from './test-adapter.js';
import { loadFixture } from './test-utils.js';
describe('CSP', () => {
let app;
/**
* @type {import('../dist/core/build/types.js').SSGManifest}
*/
let manifest;
/** @type {import('./test-utils.js').Fixture} */
let fixture;
it('should contain the meta style hashes when CSS is imported from Astro component', async () => {
fixture = await loadFixture({
root: './fixtures/csp/',
outDir: './dist/csp-style-hashes',
adapter: testAdapter({
setManifest(_manifest) {
manifest = _manifest;
},
}),
});
await fixture.build();
app = await fixture.loadTestAdapterApp();
if (manifest) {
const request = new Request('http://example.com/index.html');
const response = await app.render(request);
const $ = cheerio.load(await response.text());
const meta = $('meta[http-equiv="Content-Security-Policy"]');
for (const hash of manifest.csp.styleHashes) {
assert.ok(meta.attr('content').includes(hash), `Should have a CSP meta tag for ${hash}`);
}
} else {
assert.fail('Should have the manifest');
}
});
it('should contain the meta script hashes when using client island', async () => {
fixture = await loadFixture({
root: './fixtures/csp/',
outDir: './dist/csp-script-hashes',
adapter: testAdapter({
setManifest(_manifest) {
manifest = _manifest;
},
}),
});
await fixture.build();
app = await fixture.loadTestAdapterApp();
if (manifest) {
const request = new Request('http://example.com/index.html');
const response = await app.render(request);
const html = await response.text();
const $ = cheerio.load(html);
const meta = $('meta[http-equiv="Content-Security-Policy"]');
// ... (369 more lines)
Domain
Dependencies
- cheerio
- loadFixture
- node:test
- strict
- test-adapter.js
- test-utils.js
Source
Frequently Asked Questions
What does csp.test.js do?
csp.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does csp.test.js depend on?
csp.test.js imports 6 module(s): cheerio, loadFixture, node:test, strict, test-adapter.js, test-utils.js.
Where is csp.test.js in the architecture?
csp.test.js is located at packages/astro/test/csp.test.js (domain: IntegrationAdapters, directory: packages/astro/test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free