Skip to content

Add unit test for quota: 0 reports #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/yellow-memes-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sapcc/limes-ui": patch
---

Add resource bar unit test. Checks the behavior for reported 0 value quota
25 changes: 20 additions & 5 deletions src/components/mainView/Resource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe("Resource bar test", () => {
});
test("resources with quota tracking", async () => {
let scope = new Scope({ projectID: "123", domainID: "456" });
function getProjectData(committed = null, usage = 50) {
function getProjectData(committed = null, usage = 50, quota = 150) {
return {
project: {
id: "123",
Expand All @@ -137,20 +137,20 @@ describe("Resource bar test", () => {
per_az: {
"zone-a": {
usage: usage / 2,
quota: 50,
quota: quota / 3,
committed,
},
"zone-b": {
usage: usage / 2,
quota: 50,
quota: quota / 3,
committed,
},
"zone-c": {
usage: 0,
quota: 50,
quota: quota / 3,
},
},
quota: 150,
quota: quota,
usage: usage,
},
],
Expand Down Expand Up @@ -232,6 +232,21 @@ describe("Resource bar test", () => {
expect(screen.queryAllByText("0/40").length).toEqual(2);
// zone-c
expect(screen.getByText("0/50")).toBeInTheDocument();

// Missing quota (Detect errors in limes capacity assignment at UI level)
res = actions.restructureReport(getProjectData(committed, 10, 0).project).categories.testType.resources[0];
rerender();
act(() => {
result.current.globalStoreActions.setScope(scope);
});
// sumbar values (left and right)
expect(screen.getByText("10/20")).toBeInTheDocument();
expect(screen.getByText("0/-20")).toBeInTheDocument();
// zone-a and zone-b (left and right)
expect(screen.queryAllByText("5/10").length).toEqual(2);
expect(screen.queryAllByText("0/-10").length).toEqual(2);
// zone-c
expect(screen.getByText(/no quota/i)).toBeInTheDocument();
});

test("usage only resources", async () => {
Expand Down
Loading