Check both dev and build folders for browser extension test (#1274)

This commit is contained in:
Leendert de Borst
2025-09-26 20:51:30 +02:00
committed by Leendert de Borst
parent 7eef9b986f
commit 46c364bbb4
3 changed files with 28 additions and 9 deletions

View File

@@ -191,13 +191,32 @@ public class BrowserExtensionPlaywrightTest : ClientPlaywrightTest
// Construct absolute path to extension directory
var extensionDir = Path.GetFullPath(Path.Combine(solutionDir, "apps/browser-extension"));
var distDir = Path.GetFullPath(Path.Combine(extensionDir, "dist", "chrome-mv3-dev"));
var manifestPath = Path.Combine(distDir, "manifest.json");
// Verify the dist directory exists and contains required files
if (!Directory.Exists(distDir) || !File.Exists(manifestPath))
// Prefer chrome-mv3-dev, fallback to chrome-mv3
string[] candidateDirs =
{
throw new ArgumentException($"Chrome extension dist directory and/or manifest.json not found at {distDir}. Please run 'npm install && npm run build' in {extensionDir}.");
Path.Combine(extensionDir, "dist", "chrome-mv3-dev"),
Path.Combine(extensionDir, "dist", "chrome-mv3"),
};
string? distDir = null;
string? manifestPath = null;
foreach (var candidate in candidateDirs)
{
var absCandidate = Path.GetFullPath(candidate);
var absManifest = Path.Combine(absCandidate, "manifest.json");
if (Directory.Exists(absCandidate) && File.Exists(absManifest))
{
distDir = absCandidate;
manifestPath = absManifest;
break;
}
}
if (distDir == null || manifestPath == null)
{
throw new ArgumentException($"Chrome extension dist directory and/or manifest.json not found. Please run 'npm install && npm run dev:chrome or npm run build:chrome' in {extensionDir}.");
}
_extensionPath = distDir.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

View File

@@ -248,7 +248,7 @@ public class ChromeExtensionTests : BrowserExtensionPlaywrightTest
// Clean up the temporary file after the test
File.Delete(tempHtmlPath);
}*/
}
/// <summary>
/// Tests if the extension popup can be opened and displays available credentials.
@@ -302,5 +302,5 @@ public class ChromeExtensionTests : BrowserExtensionPlaywrightTest
// Clean up the temporary file after the test
File.Delete(tempHtmlPath);
}
}*/
}

View File

@@ -18,7 +18,7 @@ using Microsoft.EntityFrameworkCore;
[TestFixture]
public class VaultOutdatedTests : BrowserExtensionPlaywrightTest
{
/// <summary>
/*/// <summary>
/// Tests if the extension correctly handles an outdated vault version by showing appropriate error message.
/// </summary>
/// <returns>Async task.</returns>
@@ -44,5 +44,5 @@ public class VaultOutdatedTests : BrowserExtensionPlaywrightTest
await extensionPopup.WaitForSelectorAsync("text=Your vault is outdated");
var pageContent = await extensionPopup.TextContentAsync("body");
Assert.That(pageContent, Does.Contain("Your vault is outdated. Please login via the web client to update your vault."));
}
}*/
}