Skip to content

Commit

Permalink
Update http-server.integration.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
AgnesToulet committed Nov 13, 2023
1 parent 9ca3d22 commit b007c61
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/service/http-server.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ const serviceConfig: ServiceConfig = {
const sanitizer = createSanitizer();
const server = new HttpServer(serviceConfig, new ConsoleLogger(serviceConfig.service.logging), sanitizer);

let grafanaEndpoint = 'http://localhost:3000/d-solo';
let domain = 'localhost';
function getGrafanaEndpoint(domain: string) {
return `http://${domain}:3000/d-solo`;
}

beforeAll(() => {
process.env['PUPPETEER_DISABLE_HEADLESS_WARNING'] = 'true';

if (process.env['CI'] === 'true') {
grafanaEndpoint = 'http://grafana:3000/d-solo';
domain = 'grafana';
}

return server.start();
Expand All @@ -108,9 +111,9 @@ describe('Test /render', () => {
});

it('should respond with the graph panel screenshot', async () => {
const url = `${grafanaEndpoint}/${dashboardUid}?panelId=${panelIds.graph}&render=1&from=1699333200000&to=1699344000000`;
const url = `${getGrafanaEndpoint(domain)}/${dashboardUid}?panelId=${panelIds.graph}&render=1&from=1699333200000&to=1699344000000`;
const response = await request(server.app)
.get(`/render?url=${encodeURIComponent(url)}&timeout=5&renderKey=${renderKey}&domain=localhost&width=500&height=300&deviceScaleFactor=1`)
.get(`/render?url=${encodeURIComponent(url)}&timeout=5&renderKey=${renderKey}&domain=${domain}&width=500&height=300&deviceScaleFactor=1`)
.set('X-Auth-Token', '-');

const goldenFilePath = path.join(goldenFilesFolder, 'graph.png');
Expand All @@ -124,9 +127,9 @@ describe('Test /render', () => {
});

it('should respond with the table panel screenshot', async () => {
const url = `${grafanaEndpoint}/${dashboardUid}?panelId=${panelIds.table}&render=1&from=1699333200000&to=1699344000000`;
const url = `${getGrafanaEndpoint(domain)}/${dashboardUid}?panelId=${panelIds.table}&render=1&from=1699333200000&to=1699344000000`;
const response = await request(server.app)
.get(`/render?url=${encodeURIComponent(url)}&timeout=5&renderKey=${renderKey}&domain=localhost&width=500&height=300&deviceScaleFactor=1`)
.get(`/render?url=${encodeURIComponent(url)}&timeout=5&renderKey=${renderKey}&domain=${domain}&width=500&height=300&deviceScaleFactor=1`)
.set('X-Auth-Token', '-');

const goldenFilePath = path.join(goldenFilesFolder, 'table.png');
Expand All @@ -140,9 +143,9 @@ describe('Test /render', () => {
});

it('should respond with a panel error screenshot', async () => {
const url = `${grafanaEndpoint}/${dashboardUid}?panelId=${panelIds.error}&render=1&from=1699333200000&to=1699344000000`;
const url = `${getGrafanaEndpoint(domain)}/${dashboardUid}?panelId=${panelIds.error}&render=1&from=1699333200000&to=1699344000000`;
const response = await request(server.app)
.get(`/render?url=${encodeURIComponent(url)}&timeout=5&renderKey=${renderKey}&domain=localhost&width=500&height=300&deviceScaleFactor=1`)
.get(`/render?url=${encodeURIComponent(url)}&timeout=5&renderKey=${renderKey}&domain=${domain}&width=500&height=300&deviceScaleFactor=1`)
.set('X-Auth-Token', '-');

const goldenFilePath = path.join(goldenFilesFolder, 'error.png');
Expand Down

0 comments on commit b007c61

Please sign in to comment.