-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(test): enable e2e tests (#1120)
* Migrate from Node Test to Vitest * Use nw to allow reuse of cached binary Notes: Port the get tests to [nw](https://github.com/nwjs/npm-installer)
- Loading branch information
1 parent
7f8eb5f
commit f802947
Showing
13 changed files
with
940 additions
and
580 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nwjs_build_type=sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,56 @@ | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import process from "node:process"; | ||
|
||
import { beforeAll, describe, it } from "vitest"; | ||
import * as nw from "nw"; | ||
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; | ||
|
||
import decompress from "./decompress.js"; | ||
import request from "./request.js"; | ||
import util from "../util.js"; | ||
|
||
describe("get/decompress", function () { | ||
import util from '../util.js'; | ||
|
||
let tarUrl = "https://dl.nwjs.io/v0.83.0/nwjs-sdk-v0.83.0-linux-x64.tar.gz"; | ||
let zipUrl = "https://dl.nwjs.io/v0.83.0/nwjs-sdk-v0.83.0-osx-x64.zip"; | ||
describe("get/decompress", async function () { | ||
|
||
let nwFilePath = ''; | ||
let nwDirPath = ''; | ||
let nwOutPath = "./test/fixture/cache"; | ||
|
||
afterAll(async function () { | ||
await fs.promises.rm(nwOutPath, { recursive: true, force: true }); | ||
}); | ||
|
||
beforeAll(async function () { | ||
const cacheExists = await util.fileExists("./test/fixture/cache") | ||
nwDirPath = await nw.findpath('all', { flavor: 'sdk' }); | ||
|
||
const cacheExists = await util.fileExists(nwOutPath) | ||
if (!cacheExists) { | ||
await fs.promises.mkdir("./test/fixture/cache"); | ||
await fs.promises.mkdir(nwOutPath); | ||
} | ||
|
||
await request(tarUrl, "./test/fixture/cache/nw.tar.gz"); | ||
await request(zipUrl, "./test/fixture/cache/nw.zip"); | ||
}, Infinity); | ||
if (process.platform === 'linux') { | ||
nwFilePath = nwDirPath + '.tar.gz'; | ||
} else { | ||
nwFilePath = nwDirPath + '.zip'; | ||
} | ||
}); | ||
|
||
it("decompresses a Linux tarball", async function () { | ||
await decompress("./test/fixture/cache/nw.tar.gz", "./test/fixture/cache"); | ||
it("decompresses a NW.js binary", async function () { | ||
await decompress(nwFilePath, nwOutPath); | ||
}, Infinity); | ||
|
||
it("decompresses a MacOS zip", async function () { | ||
await decompress("./test/fixture/cache/nw.zip", "./test/fixture/cache"); | ||
}, Infinity); | ||
it.runIf(process.platform === 'darwin')("preserves symlinks on macos", async function () { | ||
const frameworksPath = path.resolve(process.cwd(), nwOutPath, nwDirPath, "nwjs.app", "Contents", "Frameworks", "nwjs Framework.framework"); | ||
const symlinks = [ | ||
path.join(frameworksPath, "Helpers"), | ||
path.join(frameworksPath, "Libraries"), | ||
path.join(frameworksPath, "nwjs Framework"), | ||
path.join(frameworksPath, "Resources"), | ||
path.join(frameworksPath, "Versions", "Current"), | ||
]; | ||
|
||
for (const symlink of symlinks) { | ||
const stats = await fs.promises.lstat(symlink); | ||
expect(stats.isSymbolicLink()).toEqual(true); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
import fs from "node:fs"; | ||
|
||
import { afterEach, describe, expect, it } from "vitest"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import util from "../util.js"; | ||
|
||
import request from "./request.js"; | ||
|
||
describe("get/request", function () { | ||
describe.skip("get/request", function () { | ||
|
||
let url = "https://raw.githubusercontent.com/nwutils/nw-builder/main/src/util/osx.arm.versions.json" | ||
const filePath = "./test/fixture/cache/request.test.json"; | ||
|
||
afterEach(async function () { | ||
await fs.promises.rm(filePath, { force: true }); | ||
}); | ||
|
||
it("downloads from specific url", async function () { | ||
await request(url, filePath); | ||
expect(util.fileExists(filePath)).resolves.toBe(true); | ||
}, Infinity); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig | ||
} from 'vitest/config' | ||
|
||
export default defineConfig | ||
({ | ||
test: { | ||
coverage: { | ||
provider: 'v8', | ||
reporter: ['text'], | ||
}, | ||
}, | ||
}) |