Skip to content

Commit

Permalink
fix comparison test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Mar 1, 2024
1 parent 257ab61 commit e2e0346
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions report-viewer/tests/e2e/Comparison.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { uploadFile } from './TestUtils'
test('Test comparison table and comparsion view', async ({ page }) => {
await page.goto('/')

await uploadFile('progpedia.zip', page)
await uploadFile('progpedia-report.zip', page)

const comparisonContainer = page.getByText(
'Top Comparisons: Type in the name of a submission to only show comparisons that contain this submission. Fully written out names get unhidden.Hide AllSort By'
Expand Down Expand Up @@ -45,33 +45,40 @@ test('Test comparison table and comparsion view', async ({ page }) => {
expect(comparisonTableOverviewFilteredAC).toMatch(/4anon[0-9]+C/)+/*/

await page.getByText('Show All').click()
await page.getByPlaceholder('Filter/Unhide Comparisons').fill('Blue')
await page.getByPlaceholder('Filter/Unhide Comparisons').fill('Lazy')
// go to comparison page
await page.getByText('Blue AntelopeLime Lynx').click()
await page.getByText('102Gray WolfLazy Bobcat').click()
await page.waitForURL(/\/comparison\/.*/)

// check for elements in comparison page
const submissionName1 = 'Gray Wolf'
const submissionName2 = 'Lazy Bobcat'
const fileName1 = 'Sociologia.java'
const fileName2 = 'Daa_sociologia.java'
const content1 = 'class Aluno'
const content2 = 'class Node'

const bodyComparison = await page.locator('body').textContent()
expect(bodyComparison).toMatch(/Average Similarity: [0-9]{2}.[0-9]{2}%/)
expect(bodyComparison).toMatch(/Similarity Blue Antelope: [0-9]{2}.[0-9]{2}%/)
expect(bodyComparison).toMatch(/Similarity Lime Lynx: [0-9]{2}.[0-9]{2}%/)
expect(bodyComparison).toMatch(new RegExp(`Similarity ${submissionName1}: [0-9]{2}.[0-9]{2}%`))
expect(bodyComparison).toMatch(new RegExp(`Similarity ${submissionName2}: [0-9]{2}.[0-9]{2}%`))

expect(bodyComparison).toMatch(/sociologia.java - Sociologia.java: [0-9]+/)
expect(bodyComparison).toContain('Blue Antelope/sociologia.java')
expect(bodyComparison).toContain('Lime Lynx/Sociologia.java')
expect(bodyComparison).toMatch(new RegExp(`${fileName1} - ${fileName2}: [0-9]+`))
expect(bodyComparison).toContain(`${submissionName1}/${fileName1}`)
expect(bodyComparison).toContain(`${submissionName2}/${fileName2}`)

// check for being able to hide and unhide elements
expect(await isCodeVisible(page, 'class No')).toBe(false)
await page.getByText('Blue Antelope/sociologia.java').click()
expect(await isCodeVisible(page, 'class No')).toBe(true)
await page.getByText('Blue Antelope/sociologia.java').click()
expect(await isCodeVisible(page, 'class No')).toBe(false)
expect(await isCodeVisible(page, content1)).toBe(false)
await page.getByText(`${submissionName1}/${fileName1}`).click()
expect(await isCodeVisible(page, content1)).toBe(true)
await page.getByText(`${submissionName1}/${fileName1}`).click()
expect(await isCodeVisible(page, content1)).toBe(false)

// unhide elements by clicking match list
expect(await isCodeVisible(page, 'class Node')).toBe(false)
await page.getByText('sociologia.java - Sociologia.java:').first().click()
expect(await isCodeVisible(page, content2)).toBe(false)
await page.getByText(`${fileName1} - ${fileName2}:`).first().click()
await page.waitForTimeout(1000)
expect(await isCodeVisible(page, 'class Node')).toBe(true)
expect(await isCodeVisible(page, content2)).toBe(true)
})

async function isCodeVisible(page: Page, codePart: string) {
Expand Down

0 comments on commit e2e0346

Please sign in to comment.