Skip to content

Commit

Permalink
distribution diagramm test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Sep 4, 2023
1 parent e5cf414 commit e1167b3
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion report-viewer/tests/e2e/Cluster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function compareClusterDiagramm(page: Page, submissionId: string) {
// This timeout is so that the screenshot is taken after the animation is finished
await page.waitForTimeout(3000)
const radarChart = await page.locator('canvas').first().screenshot()
expect(radarChart).toMatchSnapshot(`screenshots/Small_Cluster_${submissionId}.png`)
expect(radarChart).toMatchSnapshot(`cluster_${submissionId}.png`)
}

function compareTableRow(
Expand Down
53 changes: 53 additions & 0 deletions report-viewer/tests/e2e/Distribution.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { test, expect, Page } from '@playwright/test'
import { uploadFile } from './TestUtils'

test('Test all distribution combinations', async ({ page }) => {
await page.goto('/')

await uploadFile('result_small_cluster.zip', page)

const options = getAllOptionCombinations()
for (const option of options) {
await compareDistributionDiagramm(page, option)
}
})

/**
* Checks if the distribution diagramm is correct for the given options
* @param page Page currently tested on
* @param options Options to be selected
*/
async function compareDistributionDiagramm(page: Page, options: string[]) {
const distributionDiagrammContainer = page.getByText('Distribution of Comparisons:Options:')
for (const option of options) {
await distributionDiagrammContainer.getByText(option).click()
}
// This timeout is so that the screenshot is taken after the animation is finished
await page.waitForTimeout(3000)
const distributionDiagramm = await page.locator('canvas').first().screenshot()
expect(distributionDiagramm).toMatchSnapshot(`distribution_${options.join('_')}.png`)
}

function getAllOptionCombinations() {
const options = [['Average', 'Maximum']]

function combine(a: string[][], b: string[]) {
const combinations: string[][] = []
for (let i = 0; i < a.length; i++) {
for (let j = 0; j < b.length; j++) {
combinations.push(a[i].concat(b[j]))
}
}
return combinations
}

let combinations: string[][] = []
for (let i = 0; i < options[0].length; i++) {
combinations.push([options[0][i]])
}

for (let i = 1; i < options.length; i++) {
combinations = combine(combinations, options[i])
}
return combinations
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 e1167b3

Please sign in to comment.