Skip to content

Commit

Permalink
#126 and #127, extracts ExpressApp, AddDevice UI fixes
Browse files Browse the repository at this point in the history
Add a few API tests to Server (they work, but the request/responses are not always closed nicely).

Unit testing is setup correctly now.

Remove /docs/ (not needed).

Remove .gitmodules (not used)

Fix UI updates not running on UI thread for AddDevice activity (occurred when trying to run a second connection attempt).
  • Loading branch information
C0Newb committed Apr 11, 2023
1 parent 592133d commit 7b3ccd0
Show file tree
Hide file tree
Showing 18 changed files with 1,732 additions and 1,053 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
with:
source_dir: ./Server/src
recurse: true
template: better-docs
template: minami
output_dir: ./Documents/Dev/Server
front_page: ./Server/Readme.md
- name: Build with Jekyll
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,21 @@ public void addServerToList(MDNSResolver.NeptuneService server) {
dialog.dismiss();
new Thread(() -> {
// Add server
hideOrShowImageButtonProgressBar(serverSyncButton, serverSyncProgress, false);
serverSyncIssueButton.setVisibility(View.GONE);
runOnUiThread(() -> {
hideOrShowImageButtonProgressBar(serverSyncButton, serverSyncProgress, false);
serverSyncIssueButton.setVisibility(View.GONE);
});
Log.i("AddDeviceActivity", "Adding " + server.friendlyName);
boolean added = addServer(server);

if (added) {
runOnUiThread(() -> showErrorMessage("Server added", server.friendlyName + " has successfully been paired."));
removeServer(server.serverId); // We added it, remove it!
} else {
hideOrShowImageButtonProgressBar(serverSyncIssueButton, serverSyncProgress, true);
serverSyncButton.setVisibility(View.GONE);
runOnUiThread(() -> {
hideOrShowImageButtonProgressBar(serverSyncIssueButton, serverSyncProgress, true);
serverSyncButton.setVisibility(View.GONE);
});
}
}).start();
};
Expand All @@ -262,8 +266,10 @@ public void addServerToList(MDNSResolver.NeptuneService server) {
});

} catch (Exception e) {
hideOrShowImageButtonProgressBar(serverSyncIssueButton, serverSyncProgress, true);
runOnUiThread(() -> serverSyncButton.setVisibility(View.GONE));
runOnUiThread(() -> {
hideOrShowImageButtonProgressBar(serverSyncIssueButton, serverSyncProgress, true);
serverSyncButton.setVisibility(View.GONE);
});
e.printStackTrace();
}
}).start();
Expand Down
2 changes: 2 additions & 0 deletions Server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
/dist/
/deploy/
/tests/coverage/
/tests/logs/
/tests/data/

/data/
/logs/
Expand Down
11 changes: 7 additions & 4 deletions Server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/

module.exports = {
testTimeout: 30000, // API (HTTP) can take up to 30 seconds!

// All imported modules in your tests should be mocked automatically
// automock: false,

Expand Down Expand Up @@ -65,7 +67,8 @@ module.exports = {
globalTeardown: "./tests/JestTeardown.js",

// A set of global variables that need to be available in all test environments
// globals: {},
globals: {
},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",
Expand Down Expand Up @@ -106,7 +109,7 @@ module.exports = {
// projects: undefined,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,
// reporters: ["default", "./tests/JestTestReporter.js"],

// Automatically reset mock state before every test
// resetMocks: false,
Expand Down Expand Up @@ -135,7 +138,7 @@ module.exports = {
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
setupFilesAfterEnv: ["./tests/JestSetupEachTest.js"],

// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
Expand Down

0 comments on commit 7b3ccd0

Please sign in to comment.