Skip to content

Commit ae6f8af

Browse files
adchiakevjumba
authored andcommitted
ci: Fix Feast UI tests (#3273)
* ci: Fix Feast UI tests Signed-off-by: Danny Chiao <[email protected]> * add test to workflow Signed-off-by: Danny Chiao <[email protected]> * add test to workflow Signed-off-by: Danny Chiao <[email protected]> * fix test suite in workflow Signed-off-by: Danny Chiao <[email protected]> * fix README Signed-off-by: Danny Chiao <[email protected]> * fix build Signed-off-by: Danny Chiao <[email protected]> * fix test name Signed-off-by: Danny Chiao <[email protected]> * upgrade caniuse Signed-off-by: Danny Chiao <[email protected]> Signed-off-by: Danny Chiao <[email protected]>
1 parent 4ce366a commit ae6f8af

File tree

7 files changed

+67
-39
lines changed

7 files changed

+67
-39
lines changed

.github/workflows/unit_tests.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,23 @@ jobs:
108108
sudo apt install -y -V libarrow-dev
109109
- name: Test
110110
run: make test-go
111+
112+
unit-test-ui:
113+
runs-on: ubuntu-latest
114+
env:
115+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
116+
steps:
117+
- uses: actions/checkout@v2
118+
- uses: actions/setup-node@v2
119+
with:
120+
node-version: '17.x'
121+
registry-url: 'https://registry.npmjs.org'
122+
- name: Install yarn dependencies
123+
working-directory: ./ui
124+
run: yarn install
125+
- name: Build yarn rollup
126+
working-directory: ./ui
127+
run: yarn build:lib
128+
- name: Run yarn tests
129+
working-directory: ./ui
130+
run: yarn test --watchAll=false

sdk/python/feast/ui/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,17 @@ The `feast ui` command will generate the necessary `projects-list.json` file and
2525
**Note**: `yarn start` will not work on this because of the above dependency.
2626

2727
## Dev
28-
To test, do `yarn link` in ui/ and then come here to do `yarn link @feast-dev/feast`
28+
To test with a locally built Feast UI package, do:
29+
1. `yarn link` in ui/
30+
2. `yarn install` in ui/
31+
3. `yarn link` in ui/node_modules/react
32+
4. `yarn link` in ui/node_modules/react-dom
33+
5. and then come here to do:
34+
```bash
35+
yarn link "@feast-dev/feast"
36+
yarn link react
37+
yarn link react-dom
38+
yarn start
39+
```
40+
41+
See also https://github.com/facebook/react/issues/14257.

ui/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"react-router-dom": "6",
2626
"react-scripts": "^5.0.0",
2727
"typescript": "^4.4.2",
28-
"use-query-params": "^1.2.3"
28+
"use-query-params": "^1.2.3",
29+
"zod": "^3.11.6"
2930
},
3031
"dependencies": {
3132
"@elastic/datemath": "^5.0.3",
@@ -45,7 +46,8 @@
4546
"react-query": "^3.34.12",
4647
"react-router-dom": "6",
4748
"react-scripts": "^5.0.0",
48-
"use-query-params": "^1.2.3"
49+
"use-query-params": "^1.2.3",
50+
"zod": "^3.11.6"
4951
},
5052
"scripts": {
5153
"start": "npm run generate-protos && react-scripts start",

ui/src/FeastUISansProviders.test.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ import {
1515
creditHistoryRegistry,
1616
} from "./mocks/handlers";
1717

18-
import registry from "../public/registry.json";
18+
import { readFileSync } from "fs";
19+
import { feast } from "./protos";
20+
import path from "path";
1921

2022
// declare which API requests to mock
2123
const server = setupServer(
2224
projectsListWithDefaultProject,
2325
creditHistoryRegistry
2426
);
27+
const registry = readFileSync(path.resolve(__dirname, "../public/registry.db"));
28+
const parsedRegistry = feast.core.Registry.decode(registry);
2529

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

53-
const projectNameRegExp = new RegExp(registry.project, "i");
57+
const projectNameRegExp = new RegExp(
58+
parsedRegistry.projectMetadata[0].project!,
59+
"i"
60+
);
5461

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

98-
99-
const featureViewName = registry.featureViews[0].spec.name;
100-
const featureName = registry.featureViews[0].spec.features[0].name;
105+
const spec = parsedRegistry.featureViews[0].spec!;
106+
const featureViewName = spec.name!;
107+
const featureName = spec.features![0]!.name!;
101108

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

109-
userEvent.click(
110-
screen.getByRole("button", { name: routeRegExp }),
111-
leftClick
112-
);
116+
userEvent.click(screen.getByRole("button", { name: routeRegExp }), leftClick);
113117

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

121-
userEvent.click(
122-
screen.getByRole("link", { name: fvRegExp }),
123-
leftClick
124-
)
125+
userEvent.click(screen.getByRole("link", { name: fvRegExp }), leftClick);
125126

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

129-
userEvent.click(
130-
screen.getByRole("link", { name: fRegExp }),
131-
leftClick
132-
)
130+
userEvent.click(screen.getByRole("link", { name: fRegExp }), leftClick);
133131
// Should land on a page with the heading
134132
// await screen.findByText("Feature: " + featureName);
135133
screen.getByRole("heading", {

ui/src/mocks/handlers.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { rest } from "msw";
2-
import registry from "../../public/registry.json";
2+
import {readFileSync} from 'fs';
3+
import path from "path";
4+
5+
const registry = readFileSync(path.resolve(__dirname, "../../public/registry.db"));
36

47
const projectsListWithDefaultProject = rest.get(
58
"/projects-list.json",
@@ -14,16 +17,19 @@ const projectsListWithDefaultProject = rest.get(
1417
description:
1518
"Project for credit scoring team and associated models.",
1619
id: "credit_score_project",
17-
registryPath: "/registry.json",
20+
registryPath: "/registry.pb",
1821
},
1922
],
2023
})
2124
);
2225
}
2326
);
2427

25-
const creditHistoryRegistry = rest.get("/registry.json", (req, res, ctx) => {
26-
return res(ctx.status(200), ctx.json(registry));
28+
const creditHistoryRegistry = rest.get("/registry.pb", (req, res, ctx) => {
29+
return res(
30+
ctx.status(200),
31+
ctx.set('Content-Type', 'application/octet-stream'),
32+
ctx.body(registry));
2733
});
2834

2935
export { projectsListWithDefaultProject, creditHistoryRegistry };

ui/src/parsers/jsonType.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

ui/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3559,9 +3559,9 @@ caniuse-api@^3.0.0:
35593559
lodash.uniq "^4.5.0"
35603560

35613561
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001286, caniuse-lite@^1.0.30001297, caniuse-lite@^1.0.30001299:
3562-
version "1.0.30001303"
3563-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001303.tgz#9b168e4f43ccfc372b86f4bc5a551d9b909c95c9"
3564-
integrity sha512-/Mqc1oESndUNszJP0kx0UaQU9kEv9nNtJ7Kn8AdA0mNnH8eR1cj0kG+NbNuC1Wq/b21eA8prhKRA3bbkjONegQ==
3562+
version "1.0.30001416"
3563+
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001416.tgz"
3564+
integrity sha512-06wzzdAkCPZO+Qm4e/eNghZBDfVNDsCgw33T27OwBH9unE9S478OYw//Q2L7Npf/zBzs7rjZOszIFQkwQKAEqA==
35653565

35663566
case-sensitive-paths-webpack-plugin@^2.4.0:
35673567
version "2.4.0"
@@ -11342,7 +11342,7 @@ yocto-queue@^0.1.0:
1134211342
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
1134311343
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
1134411344

11345-
zod@^3.19.1:
11345+
zod@^3.11.6:
1134611346
version "3.19.1"
1134711347
resolved "https://registry.yarnpkg.com/zod/-/zod-3.19.1.tgz#112f074a97b50bfc4772d4ad1576814bd8ac4473"
1134811348
integrity sha512-LYjZsEDhCdYET9ikFu6dVPGp2YH9DegXjdJToSzD9rO6fy4qiRYFoyEYwps88OseJlPyl2NOe2iJuhEhL7IpEA==

0 commit comments

Comments
 (0)