Skip to content

Commit

Permalink
adapt e2e tests to progpedia dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Feb 29, 2024
1 parent 61bbbcc commit 985a68d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 41 deletions.
1 change: 1 addition & 0 deletions report-viewer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ coverage

test-results/
playwright-report/
tests/e2e/assets
52 changes: 29 additions & 23 deletions report-viewer/tests/e2e/Comparison.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,33 @@ import { uploadFile } from './TestUtils'
test('Test comparison table and comparsion view', async ({ page }) => {
await page.goto('/')

await uploadFile('result_small_cluster.zip', page)
await uploadFile('progpedia.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'
)

// check for elements in average similarity table
const comparisonTableAverageSorted = await page.getByText('Cluster1').textContent()
expect(comparisonTableAverageSorted).toContain('1CA')
expect(comparisonTableAverageSorted).toContain('2DC')
await page.getByPlaceholder('Filter/Unhide Comparisons').fill('Purple')
const comparisonTableAverageSorted = await page.getByText(/Cluster[0-9]/).textContent()
expect(comparisonTableAverageSorted).toContain('100Purple FishBeige Dog')

await comparisonContainer.getByText('Maximum Similarity', { exact: true }).click()
// check for elements in maximum similarity table
const comparisonTableMaxSorted = await page.getByText('Cluster1').textContent()
expect(comparisonTableMaxSorted).toContain('1CA')
expect(comparisonTableMaxSorted).toContain('2BC')
await page.getByPlaceholder('Filter/Unhide Comparisons').fill('Blue')
const comparisonTableMaxSorted = await page.getByText(/Cluster[0-9]/).textContent()
expect(comparisonTableMaxSorted).toContain('100Blue AntelopeLime Lynx')

await page.getByPlaceholder('Filter/Unhide Comparisons').fill('')
await page.getByText('Hide All').click()
// check for elements being hidden
const comparisonTableOverviewHidden = await page.getByText('Cluster1').textContent()
expect(comparisonTableOverviewHidden).toMatch(/1anon[0-9]+anon[0-9]+/)
expect(comparisonTableOverviewHidden).toMatch(/3anon[0-9]+anon[0-9]+/)
expect(comparisonTableOverviewHidden).toMatch(/4anon[0-9]+anon[0-9]+/)

await page.getByPlaceholder('Filter/Unhide Comparisons').fill('A')
// Temporarily disabled due to https://github.com/jplag/JPlag/issues/1629
/*await page.getByPlaceholder('Filter/Unhide Comparisons').fill('A')
// check for elements being unhidden and filtered
const comparisonTableOverviewFilteredA = await page.getByText('Cluster1').textContent()
expect(comparisonTableOverviewFilteredA).toMatch(/1anon[0-9]+A/) //toContain('1HiddenA')
Expand All @@ -40,32 +42,36 @@ test('Test comparison table and comparsion view', async ({ page }) => {
const comparisonTableOverviewFilteredAC = await page.getByText('Cluster1').textContent()
expect(comparisonTableOverviewFilteredAC).toContain('1CA')
expect(comparisonTableOverviewFilteredAC).toMatch(/3anon[0-9]+A/)
expect(comparisonTableOverviewFilteredAC).toMatch(/4anon[0-9]+C/)
expect(comparisonTableOverviewFilteredAC).toMatch(/4anon[0-9]+C/)+/*/

await page.getByText('Show All').click()
await page.getByPlaceholder('Filter/Unhide Comparisons').fill('Blue')
// go to comparison page
await page.getByText('1C').click()
await page.getByText('Blue AntelopeLime Lynx').click()
await page.waitForURL(/\/comparison\/.*/)

// check for elements in comparison page
const bodyComparison = await page.locator('body').textContent()
expect(bodyComparison).toContain('Average Similarity: 99.59%')
expect(bodyComparison).toContain('GSTiling.java - GSTiling.java: 308')
expect(bodyComparison).toContain('Matches.java - Matches.java: 58')
expect(bodyComparison).toContain('A/Match.java')
expect(bodyComparison).toContain('C/Match.java')
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(/sociologia.java - Sociologia.java: [0-9]+/)
expect(bodyComparison).toContain('Blue Antelope/sociologia.java')
expect(bodyComparison).toContain('Lime Lynx/Sociologia.java')

// check for being able to hide and unhide elements
expect(await isCodeVisible(page, 'public class Match {')).toBe(false)
await page.getByText('A/Match.java').click()
expect(await isCodeVisible(page, 'public class Match {')).toBe(true)
await page.getByText('A/Match.java').click()
expect(await isCodeVisible(page, 'public class Match {')).toBe(false)
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)

// unhide elements by clicking match list
expect(await isCodeVisible(page, 'public class GSTiling')).toBe(false)
await page.getByText('GSTiling.java - GSTiling.java: 308').click()
expect(await isCodeVisible(page, 'class Node')).toBe(false)
await page.getByText('sociologia.java - Sociologia.java:').first().click()
await page.waitForTimeout(1000)
expect(await isCodeVisible(page, 'public class GSTiling')).toBe(true)
expect(await isCodeVisible(page, 'class Node')).toBe(true)
})

async function isCodeVisible(page: Page, codePart: string) {
Expand Down
2 changes: 1 addition & 1 deletion report-viewer/tests/e2e/Distribution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { uploadFile } from './TestUtils'
test('Test distribution diagram', async ({ page }) => {
await page.goto('/')

await uploadFile('result_small_cluster.zip', page)
await uploadFile('progpedia.zip', page)

const options = getTestCombinations()
selectOptions(page, options[0])
Expand Down
34 changes: 17 additions & 17 deletions report-viewer/tests/e2e/Information.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ import { uploadFile } from './TestUtils'

test('Test information page', async ({ page }) => {
await page.goto('/')
await uploadFile('result_small_cluster.zip', page)
await uploadFile('progpedia.zip', page)

// check displayed information on overview page
const bodyOverview = await page.locator('body').textContent()
expect(bodyOverview).toContain('Directory: files')
expect(bodyOverview).toContain('Total Submissions: 4')
expect(bodyOverview).toContain('Total Comparisons: 6')
expect(bodyOverview).toContain('Min Token Match: 9')
expect(bodyOverview).toContain('Directory: ')
expect(bodyOverview).toMatch(/Total Submissions: [0-9]+/)
expect(bodyOverview).toMatch(/Total Comparisons: [0-9]+/)
expect(bodyOverview).toMatch(/Min Token Match: [0-9]+/)

// go to information page
await page.getByText('More', { exact: true }).click()
await page.waitForURL('/info')

// check displayed run options on information page
const runOptions = await page.getByText('Run Options:Submission Directory:').textContent()
expect(runOptions).toContain('Submission Directory: files')
expect(runOptions).toContain('Basecode Directory:')
expect(runOptions).toContain('Language: Javac based AST plugin')
expect(runOptions).toContain('File Extensions: .java, .JAVA')
expect(runOptions).toContain('Min Token Match: 9')
const runOptions = await page.getByText('Run Options:Language:').textContent()
expect(runOptions).toContain('Submission Directories: ')
expect(runOptions).toContain('Base Directory: ')
expect(runOptions).toContain('Language: ')
expect(runOptions).toContain('File Suffixes: ')
expect(runOptions).toMatch(/Min Token Match: [0-9]+/)

const runData = await page.getByText('Run Data:Date of Execution:').textContent()
expect(runData).toContain('Date of Execution: 02/09/23')
expect(runData).toContain('Execution Duration: 12 ms')
expect(runData).toContain('Total Submissions: 4')
expect(runData).toContain('Total Comparisons: 6')
expect(runData).toContain('Shown Comparisons: 6')
expect(runData).toContain('Missing Comparisons: 0')
expect(runData).toMatch(/Date of Execution: [0-9]{2}\/[0-9]{2}\/[0-9]{2}/)
expect(runData).toMatch(/Execution Duration: [0-9]+ ms/)
expect(runData).toMatch(/Total Submissions: [0-9]+/)
expect(runData).toMatch(/Total Comparisons: [0-9]+/)
expect(runData).toMatch(/Shown Comparisons: [0-9]+/)
expect(runData).toMatch(/Missing Comparisons: [0-9]+/)
})

0 comments on commit 985a68d

Please sign in to comment.