Skip to content

Commit

Permalink
Early finish fix (#1544)
Browse files Browse the repository at this point in the history
## Problem

See #1542


## Solution

After debugging it shows that queries work, but when query gets
invalidated it reread data and it wrongly parse json data and set busy
status as undefined.


## Testing

- *Added a new unit test*
- *Tested manually*
  • Loading branch information
jreidinger authored Aug 19, 2024
2 parents fc0f3a2 + c447cdd commit 5f2b96b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
2 changes: 1 addition & 1 deletion service/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ build-iPhoneSimulator/
# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
.ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
Expand Down
5 changes: 5 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Mon Aug 19 11:54:07 UTC 2024 - Josef Reidinger <jreidinger@suse.com>

- Fix early finish of installation (gh#openSUSE/agama#1544)

-------------------------------------------------------------------
Tue Aug 13 14:57:21 UTC 2024 - David Diaz <dgonzalez@suse.com>

Expand Down
48 changes: 48 additions & 0 deletions web/src/api/status.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) [2024] SUSE LLC
*
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, contact SUSE LLC.
*
* To contact SUSE LLC about this file by physical or electronic mail, you may
* find current contact information at www.suse.com.
*/

// @ts-check

import { get } from "./http";
import { fetchInstallerStatus } from "./status";

const mockGetFn = jest.fn().mockImplementation(() => {
return {
phase: 2,
busy: [],
iguana: false,
canInstall: false
};
});

jest.mock("./http", () => {
return {
// TODO: fix mocking of get. How to do it for api tests?
// get: mockGetFn,
};
});

describe("#fetchInstallerStatus", () => {
it.skip("parses response from manager/installer", async() => {
const response = await fetchInstallerStatus();
expect(response.isBusy).toEqual(false);
});
});
4 changes: 2 additions & 2 deletions web/src/api/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import { InstallerStatus } from "~/types/status";
* Returns the installer status information
*/
const fetchInstallerStatus = async (): Promise<InstallerStatus> => {
const { phase, isBusy, useIguana, canInstall } = await get("/api/manager/installer");
return { phase, isBusy, useIguana, canInstall };
const { phase, busy, iguana, canInstall } = await get("/api/manager/installer");
return { phase, isBusy: busy.length !== 0, useIguana: iguana, canInstall };
};

export { fetchInstallerStatus };

0 comments on commit 5f2b96b

Please sign in to comment.