Skip to content

Commit

Permalink
fix: switch to hash location strategy and check for url param
Browse files Browse the repository at this point in the history
closes #522
  • Loading branch information
d-koppenhagen committed Dec 22, 2024
1 parent b1a9eb4 commit 69756e7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
8 changes: 6 additions & 2 deletions e2e/home-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ export class HomePage {
this.fileBtn = page.getByRole("button", { name: "File" })
}

async goto() {
await this.page.goto("http://localhost:8080")
async goto(urlQueryParam?: string) {
let url = "http://localhost:8080/#/"
if (urlQueryParam) {
url += `?url=${urlQueryParam}`
}
await this.page.goto(url)
}

async hasTitle(expectedTitle: string) {
Expand Down
15 changes: 12 additions & 3 deletions e2e/smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const filenameSchemaVersion1 = "test-result-v1.json"
const filenameSchemaVersion2 = "test-result-v2.json"
const filenameTestManyResults = "test-many-results.json"
const cveEntries = ["CVE-2021-3450", "CVE-2021-3449", "CVE-2019-14697"]
const testReportUrl = `https://raw.githubusercontent.com/dbsystel/trivy-vulnerability-explorer/refs/heads/main/public/${filenameSchemaVersion2}`

test("should have the correct title", async ({ page }) => {
const homePage = new HomePage(page)
Expand All @@ -16,9 +17,17 @@ test("should have the correct title", async ({ page }) => {
test("fetches from URL", async ({ page }) => {
const homePage = new HomePage(page)
await homePage.goto()
await homePage.fetchTestFileFromUrl(
`https://raw.githubusercontent.com/dbsystel/trivy-vulnerability-explorer/refs/heads/main/public/${filenameSchemaVersion2}`,
)
await homePage.fetchTestFileFromUrl(testReportUrl)
await homePage.verifyTableResult(5)
await homePage.verifyTrivyignore(cveEntries)
})

test("fetches from URL passed as query param", async ({ page }) => {
const homePage = new HomePage(page)
const responsePromise = homePage.page.waitForResponse(testReportUrl)
await homePage.goto(testReportUrl)
await responsePromise

await homePage.verifyTableResult(5)
await homePage.verifyTrivyignore(cveEntries)
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportUrlFetcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import type { ReportError, Version1OrVersion2 } from "@/types"
const props = defineProps<{
onNewReport: (report: Version1OrVersion2 | { error: ReportError }) => void
presetUrl: String
presetUrl?: string
}>()
const url = ref("")
Expand Down
8 changes: 4 additions & 4 deletions src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ import DataInput from "@/components/DataInput.vue"
import DataTable from "@/components/DataTable.vue"
import type { Vulnerability } from "@/types"
const props = defineProps({
presetUrl: String,
})
const selectedVulnerabilities = ref<Vulnerability[]>([])
const reportLoaded = ref(false)
const query = useRoute().query
const presetUrl = (Array.isArray(query.url) ? query.url[0] : query.url) as
| string
| undefined
function reactivelySetNewVulnerabilities(newVulnerabilities: Vulnerability[]) {
selectedVulnerabilities.value.splice(0)
Expand Down
4 changes: 2 additions & 2 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/

// Composables
import { createRouter, createWebHistory } from "vue-router/auto"
import { createRouter, createWebHashHistory } from "vue-router/auto"
import { setupLayouts } from "virtual:generated-layouts"
import { routes } from "vue-router/auto-routes"

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
history: createWebHashHistory(import.meta.env.BASE_URL),
routes: setupLayouts(routes),
})

Expand Down

0 comments on commit 69756e7

Please sign in to comment.