Skip to content

Commit

Permalink
Merge pull request #52 from alercebroker/fix/csv-loading-with-filters
Browse files Browse the repository at this point in the history
Fix: Parse filters form CSV file when creating a watchlist
  • Loading branch information
HectorxH authored Apr 29, 2024
2 parents db87532 + b1fa9c7 commit f83fb18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/ui/components/watchlist/CreateWatchlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ import { MutationTypes } from "@/ui/store/watchlist/mutations";
import { ITargetData } from "@/app/target/domain/Target.types";
import CsvError from "./CsvError.vue";
import GenericError from "../shared/GenericError.vue";
import { IWatchlistFilter } from "@/app/filter/domain/Filter.types";
const watchlistHelper = createNamespacedHelpers("watchlists");
type CsvTarget = {
name?: string;
ra: number;
dec: number;
radius: number;
filter: string;
};
export default Vue.extend({
Expand Down Expand Up @@ -102,6 +104,9 @@ export default Vue.extend({
ra: value.ra,
dec: value.dec,
radius: value.radius,
filter: JSON.parse(
value.filter.replace(/'/g, '"')
) as IWatchlistFilter,
} as ITargetData)
),
};
Expand Down
14 changes: 9 additions & 5 deletions src/ui/components/watchlist/__tests__/CreateWatchlist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe("CreateWatchlist Component", () => {
await wrapper.setData({
title: "title",
selectedFile: new File(
["name,radius,ra,dec\nTarget 0,1.0,1.0,1.0"],
["name,radius,ra,dec,filter\nTarget 0,1.0,1.0,1.0,{}"],
"test.csv",
{ type: "text/csv" }
),
Expand Down Expand Up @@ -93,9 +93,13 @@ describe("CreateWatchlist Component", () => {
});
await wrapper.setData({
title: "title",
selectedFile: new File(["name,radius,ra,dec\na,b,c,d"], "test.csv", {
type: "text/csv",
}),
selectedFile: new File(
["name,radius,ra,dec,filter\na,b,c,d,{}"],
"test.csv",
{
type: "text/csv",
}
),
});
const send = wrapper.find("#send");
await send.trigger("click");
Expand All @@ -113,7 +117,7 @@ describe("CreateWatchlist Component", () => {
});
await wrapper.setData({
title: "title",
selectedFile: new File(["name,radius,ra,dec\n"], "test.csv", {
selectedFile: new File(["name,radius,ra,dec,filter\n"], "test.csv", {
type: "text/csv",
}),
});
Expand Down

0 comments on commit f83fb18

Please sign in to comment.