Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ci: Fix Feast UI tests
Signed-off-by: Danny Chiao <danny@tecton.ai>
  • Loading branch information
adchia committed Oct 6, 2022
commit 03c35effd3b17abf80d9dfd57bf4dd76c94c4850
32 changes: 15 additions & 17 deletions ui/src/FeastUISansProviders.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ import {
creditHistoryRegistry,
} from "./mocks/handlers";

import registry from "../public/registry.json";
import { readFileSync } from "fs";
import { feast } from "./protos";
import path from "path";

// declare which API requests to mock
const server = setupServer(
projectsListWithDefaultProject,
creditHistoryRegistry
);
const registry = readFileSync(path.resolve(__dirname, "../public/registry.db"));
const parsedRegistry = feast.core.Registry.decode(registry);

// establish API mocking before all tests
beforeAll(() => server.listen());
Expand Down Expand Up @@ -50,7 +54,10 @@ test("full app rendering", async () => {
// Explore Panel Should Appear
expect(screen.getByText(/Explore this Project/i)).toBeInTheDocument();

const projectNameRegExp = new RegExp(registry.project, "i");
const projectNameRegExp = new RegExp(
parsedRegistry.projectMetadata[0].project!,
"i"
);

// It should load the default project, which is credit_scoring_aws
await waitFor(() => {
Expand Down Expand Up @@ -95,9 +102,9 @@ test("routes are reachable", async () => {
}
});


const featureViewName = registry.featureViews[0].spec.name;
const featureName = registry.featureViews[0].spec.features[0].name;
const spec = parsedRegistry.featureViews[0].spec!;
const featureViewName = spec.name!;
const featureName = spec.features![0]!.name!;

test("features are reachable", async () => {
render(<FeastUISansProviders />);
Expand All @@ -106,10 +113,7 @@ test("features are reachable", async () => {
await screen.findByText(/Explore this Project/i);
const routeRegExp = new RegExp("Feature Views", "i");

userEvent.click(
screen.getByRole("button", { name: routeRegExp }),
leftClick
);
userEvent.click(screen.getByRole("button", { name: routeRegExp }), leftClick);

screen.getByRole("heading", {
name: "Feature Views",
Expand All @@ -118,18 +122,12 @@ test("features are reachable", async () => {
await screen.findAllByText(/Feature Views/i);
const fvRegExp = new RegExp(featureViewName, "i");

userEvent.click(
screen.getByRole("link", { name: fvRegExp }),
leftClick
)
userEvent.click(screen.getByRole("link", { name: fvRegExp }), leftClick);

await screen.findByText(featureName);
const fRegExp = new RegExp(featureName, "i");

userEvent.click(
screen.getByRole("link", { name: fRegExp }),
leftClick
)
userEvent.click(screen.getByRole("link", { name: fRegExp }), leftClick);
// Should land on a page with the heading
// await screen.findByText("Feature: " + featureName);
screen.getByRole("heading", {
Expand Down
14 changes: 10 additions & 4 deletions ui/src/mocks/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { rest } from "msw";
import registry from "../../public/registry.json";
import {readFileSync} from 'fs';
import path from "path";

const registry = readFileSync(path.resolve(__dirname, "../../public/registry.db"));

const projectsListWithDefaultProject = rest.get(
"/projects-list.json",
Expand All @@ -14,16 +17,19 @@ const projectsListWithDefaultProject = rest.get(
description:
"Project for credit scoring team and associated models.",
id: "credit_score_project",
registryPath: "/registry.json",
registryPath: "/registry.pb",
},
],
})
);
}
);

const creditHistoryRegistry = rest.get("/registry.json", (req, res, ctx) => {
return res(ctx.status(200), ctx.json(registry));
const creditHistoryRegistry = rest.get("/registry.pb", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.set('Content-Type', 'application/octet-stream'),
ctx.body(registry));
});

export { projectsListWithDefaultProject, creditHistoryRegistry };
11 changes: 0 additions & 11 deletions ui/src/parsers/jsonType.ts

This file was deleted.