Skip to content

Commit

Permalink
fix(server_id): correct file path for pheno/geno downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
juliendiot42 committed Sep 2, 2024
1 parent 5608e26 commit 84d6340
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
20 changes: 10 additions & 10 deletions src/server/server_id.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ output$dwnlPheno <- downloadHandler(
if (input$phenoFile %in% initFiles) {
folder <- DATA_INITIAL_DATA
} else {
folder <- paste0(DATA_SHARED, breeder())
folder <- file.path(DATA_SHARED, breeder())
}
filePath <- paste0(folder, "/", input$phenoFile)
filePath <- file.path(folder, input$phenoFile)
file.copy(filePath, file)
}
)
Expand All @@ -251,9 +251,9 @@ output$dwnlGeno <- downloadHandler(
if (gFile %in% initFiles) {
folder <- DATA_INITIAL_DATA
} else {
folder <- paste0(DATA_SHARED, breeder())
folder <- file.path(DATA_SHARED, breeder())
}
filePath <- paste0(folder, "/", gFile)
filePath <- file.path(folder, gFile)
file.copy(filePath, file)
}
)
Expand All @@ -266,9 +266,9 @@ output$dwnlGeno_vcf <- downloadHandler(
if (gFile_txt %in% initFiles) {
folder <- DATA_INITIAL_DATA
} else {
folder <- paste0(DATA_SHARED, breeder())
folder <- file.path(DATA_SHARED, breeder())
}
gFile_txt <- paste0(folder, "/", gFile_txt)
gFile_txt <- file.path(folder, gFile_txt)
progressVcf <- shiny::Progress$new(session, min = 0, max = 5)
progressVcf$set(
value = 0,
Expand All @@ -290,9 +290,9 @@ output$dwnlPltMat <- downloadHandler(
if (input$pltMatFile %in% initFiles) {
folder <- DATA_INITIAL_DATA
} else {
folder <- paste0(DATA_SHARED, breeder())
folder <- file.path(DATA_SHARED, breeder())
}
filePath <- paste0(folder, "/", input$pltMatFile)
filePath <- file.path(folder, input$pltMatFile)
file.copy(filePath, file)
}
)
Expand All @@ -305,9 +305,9 @@ output$dwnlRequest <- downloadHandler(
if (input$requestFile %in% initFiles) {
folder <- DATA_INITIAL_DATA
} else {
folder <- paste0(DATA_SHARED, breeder())
folder <- file.path(DATA_SHARED, breeder())
}
filePath <- paste0(folder, "/", input$requestFile)
filePath <- file.path(folder, input$requestFile)
file.copy(filePath, file)
}
)
Expand Down
19 changes: 11 additions & 8 deletions tests_UI/test-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,17 @@ async function checkResultsFile(page: Page, reqFile: string, type: string) {
await page.getByRole("option").getByText(resultFilePatern).first().click();

// download request results file
const [download] = await Promise.all([
page.waitForEvent("download"),
await page.locator(buttonID).click(),
]);
const tempFilePath = join(tmpdir(), `${Date.now()}_${tmpFileSuff}.txt`);
const downloadPath = await download.path();
gunzip(downloadPath, tempFilePath, function () {
const fileContent = readFileSync(tempFilePath, { encoding: "utf8" });
const downloadPromise = page.waitForEvent("download");
await page.locator(buttonID).click();
const download = await downloadPromise;

const tempDirPath = tmpdir() + "/";
const tempDownlFile = tempDirPath + download.suggestedFilename();
await download.saveAs(tempDownlFile);

const extractedFilePath = join(tempDirPath, `${Date.now()}_${tmpFileSuff}`);
gunzip(tempDownlFile, extractedFilePath, function () {
const fileContent = readFileSync(extractedFilePath, { encoding: "utf8" });
expect(fileContent).toContain(expectedText);
});
}
Expand Down

0 comments on commit 84d6340

Please sign in to comment.