mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-02 21:13:32 +00:00
tests: Remove dynamic package.json generation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const TEST_APP_PRODUCT_NAME = "ZulipTest";
|
||||
|
||||
module.exports = {
|
||||
TEST_APP_PRODUCT_NAME,
|
||||
};
|
||||
4
tests/package.json
Normal file
4
tests/package.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"productName": "ZulipTest",
|
||||
"main": "../app/main/index.js"
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
"use strict";
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const rimraf = require("rimraf");
|
||||
const {Application} = require("spectron");
|
||||
|
||||
const config = require("./config.js");
|
||||
const testsPkg = require("./package.json");
|
||||
|
||||
module.exports = {
|
||||
createApp,
|
||||
@@ -19,7 +18,6 @@ module.exports = {
|
||||
// Returns a promise that resolves to a Spectron Application once the app has loaded.
|
||||
// Takes a Tape test. Makes some basic assertions to verify that the app loaded correctly.
|
||||
function createApp() {
|
||||
generateTestAppPackageJson();
|
||||
return new Application({
|
||||
path: path.join(
|
||||
__dirname,
|
||||
@@ -34,22 +32,6 @@ function createApp() {
|
||||
});
|
||||
}
|
||||
|
||||
// Generates package.json for test app
|
||||
// Reads app package.json and updates the productName to config.TEST_APP_PRODUCT_NAME
|
||||
// We do this so that the app integration doesn't doesn't share the same appDataDir as the dev application
|
||||
function generateTestAppPackageJson() {
|
||||
const packageJson = require(path.join(__dirname, "../package.json"));
|
||||
packageJson.productName = config.TEST_APP_PRODUCT_NAME;
|
||||
packageJson.main = "../app/main";
|
||||
|
||||
const testPackageJsonPath = path.join(__dirname, "package.json");
|
||||
fs.writeFileSync(
|
||||
testPackageJsonPath,
|
||||
JSON.stringify(packageJson, null, " "),
|
||||
"utf-8",
|
||||
);
|
||||
}
|
||||
|
||||
// Starts the app, waits for it to load, returns a promise
|
||||
async function waitForLoad(app, t, options) {
|
||||
if (!options) {
|
||||
@@ -101,12 +83,11 @@ function getAppDataDir() {
|
||||
}
|
||||
|
||||
console.log("Detected App Data Dir base:", base);
|
||||
return path.join(base, config.TEST_APP_PRODUCT_NAME);
|
||||
return path.join(base, testsPkg.productName);
|
||||
}
|
||||
|
||||
// Resets the test directory, containing domain.json, window-state.json, etc
|
||||
function resetTestDataDir() {
|
||||
const appDataDir = getAppDataDir();
|
||||
rimraf.sync(appDataDir);
|
||||
rimraf.sync(path.join(__dirname, "package.json"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user