fix: build frontend, update binary path

This commit is contained in:
Lucas Nogueira
2025-04-15 10:23:26 -03:00
parent 2db4fc5f8e
commit 0fffcf2593
4 changed files with 51 additions and 29 deletions

View File

@@ -9,10 +9,10 @@ const application = path.resolve(
__dirname,
"..",
"..",
"..",
"src-tauri",
"target",
"release",
"hello_tauri"
"debug",
"tauri-app"
);
// keep track of the webdriver instance we create
@@ -26,10 +26,15 @@ before(async function() {
this.timeout(120000)
// ensure the program has been built
spawnSync(
"pnpm",
["build"],
{ cwd: path.resolve(__dirname, "../.."), stdio: 'inherit' }
)
spawnSync(
"cargo",
["build", "--features", "tauri/custom-protocol"],
{ cwd: path.resolve(__dirname, "../../src-tauri") }
{ cwd: path.resolve(__dirname, "../../src-tauri"), stdio: 'inherit' }
);
// start tauri-driver

View File

@@ -12,7 +12,7 @@ exports.config = {
{
maxInstances: 1,
"tauri:options": {
application: "../../target/release/hello_tauri",
application: "../../src-tauri/target/debug/tauri-app",
},
},
],
@@ -24,11 +24,18 @@ exports.config = {
},
// ensure the rust project is built since we expect this binary to exist for the webdriver sessions
onPrepare: () => spawnSync(
onPrepare: () => {
spawnSync(
"pnpm",
["build"],
{ cwd: path.resolve(__dirname, "../.."), stdio: 'inherit' }
)
spawnSync(
"cargo",
["build", "--features", "tauri/custom-protocol"],
{ cwd: path.resolve(__dirname, "../../src-tauri") }
),
{ cwd: path.resolve(__dirname, "../../src-tauri"), stdio: 'inherit' }
)
},
// ensure we are running `tauri-driver` before the session starts so that we can proxy the webdriver requests
beforeSession: () =>

View File

@@ -9,10 +9,10 @@ const application = path.resolve(
__dirname,
"..",
"..",
"..",
"src-tauri",
"target",
"release",
"hello_tauri"
"debug",
"tauri-app"
);
// keep track of the webdriver instance we create
@@ -21,16 +21,19 @@ let driver;
// keep track of the tauri-driver process we start
let tauriDriver;
before(async function() {
before(async function () {
// set timeout to 2 minutes to allow the program to build if it needs to
this.timeout(120000)
this.timeout(120000);
// ensure the program has been built
spawnSync(
"cargo",
["build", "--features", "tauri/custom-protocol"],
{ cwd: path.resolve(__dirname, "../../src-tauri") }
);
spawnSync("pnpm", ["build"], {
cwd: path.resolve(__dirname, "../.."),
stdio: "inherit",
});
spawnSync("cargo", ["build", "--features", "tauri/custom-protocol"], {
cwd: path.resolve(__dirname, "../../src-tauri"),
stdio: "inherit",
});
// start tauri-driver
tauriDriver = spawn(
@@ -50,7 +53,7 @@ before(async function() {
.build();
});
after(async function() {
after(async function () {
// stop the webdriver session
await driver.quit();
@@ -71,12 +74,14 @@ describe("Hello Tauri", () => {
it("should be easy on the eyes", async () => {
// selenium returns color css values as rgb(r, g, b)
const text = await driver.findElement(By.css("body")).getCssValue("background-color");
const text = await driver
.findElement(By.css("body"))
.getCssValue("background-color");
const rgb = text.match(/^rgb\((?<r>\d+), (?<g>\d+), (?<b>\d+)\)$/).groups;
expect(rgb).to.have.all.keys('r','g','b');
expect(rgb).to.have.all.keys("r", "g", "b");
const luma = 0.2126 * rgb.r + 0.7152 * rgb.g + 0.0722 * rgb.b ;
expect(luma).to.be.lessThan(100)
const luma = 0.2126 * rgb.r + 0.7152 * rgb.g + 0.0722 * rgb.b;
expect(luma).to.be.lessThan(100);
});
});

View File

@@ -12,7 +12,7 @@ exports.config = {
{
maxInstances: 1,
"tauri:options": {
application: "../../target/release/hello_tauri",
application: "../../src-tauri/target/debug/tauri-app",
},
},
],
@@ -24,11 +24,16 @@ exports.config = {
},
// ensure the rust project is built since we expect this binary to exist for the webdriver sessions
onPrepare: () => spawnSync(
"cargo",
["build", "--features", "tauri/custom-protocol"],
{ cwd: path.resolve(__dirname, "../../src-tauri") }
),
onPrepare: () => {
spawnSync("pnpm", ["build"], {
cwd: path.resolve(__dirname, "../.."),
stdio: "inherit",
});
spawnSync("cargo", ["build", "--features", "tauri/custom-protocol"], {
cwd: path.resolve(__dirname, "../../src-tauri"),
stdio: "inherit",
});
},
// ensure we are running `tauri-driver` before the session starts so that we can proxy the webdriver requests
beforeSession: () =>