Skip to content

Commit

Permalink
display styles to compare CI vs local
Browse files Browse the repository at this point in the history
  • Loading branch information
AgnesToulet committed Nov 14, 2023
1 parent 9bb9343 commit 92bff43
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ export class Browser {
page.on('dialog', acceptBeforeUnload);
}

async getStyles(page: puppeteer.Page) {
const pageTitleSelector = "[class$='panel-title']";
await page.waitForSelector(pageTitleSelector);
const styles = await page.$eval("[class$='panel-title']", (el) => {
const stylesObject = getComputedStyle(el);
const styles = {};
for (const prop in stylesObject) {
styles[prop] = stylesObject[prop];
}
return stylesObject;
});

this.log.info('getstyles', 'styles', styles);
}

async scrollToLoadAllPanels(page: puppeteer.Page, options: ImageRenderOptions): Promise<DashboardScrollingResult> {
const scrollDivSelector = '[class="scrollbar-view"]';
const scrollDelay = options.scrollDelay ?? 500;
Expand Down Expand Up @@ -360,6 +375,8 @@ export class Browser {
options.fullPageImage || false
);
}, 'panelsRendered');

await this.getStyles(page);
} catch (err) {
this.log.error('Error while waiting for the panels to load', 'url', options.url, 'err', err.stack);
}
Expand Down
4 changes: 2 additions & 2 deletions src/service/http-server.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('Test /render', () => {
it('should respond with the graph panel screenshot', async () => {
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=${domain}&width=500&height=300&deviceScaleFactor=2`)
.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 @@ -123,7 +123,7 @@ describe('Test /render', () => {

expect(response.statusCode).toEqual(200);
expect(response.headers['content-type']).toEqual('image/png');
console.log(response.body.toString('hex'));
// console.log(response.body.toString('hex'));
expect(response.body).toEqual(fs.readFileSync(goldenFilePath));
});

Expand Down
Binary file modified src/testdata/graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 92bff43

Please sign in to comment.