Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
coenm committed Oct 26, 2024
1 parent 7a7b2c6 commit 45f1cb6
Show file tree
Hide file tree
Showing 14 changed files with 557 additions and 4 deletions.
95 changes: 93 additions & 2 deletions tests/UiTests/Class1.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
namespace UiTests;

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Abstractions;
using System.Threading.Tasks;
using FakeItEasy;
using FlaUI.Core;
using FlaUI.Core.AutomationElements;
using FlaUI.Core.Input;
using FlaUI.Core.WindowsAPI;
using FlaUI.UIA3;
using FluentAssertions;
using global::RepoM.Api.Common;
using global::RepoM.Api.Git;
using global::RepoM.Api.IO;
using global::RepoM.Core.Plugin.Common;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Newtonsoft.Json;
using UiTests.Extensions;
using UiTests.Framework;
using UiTests.RepoM;
Expand All @@ -15,6 +27,9 @@ namespace UiTests;
using Xunit;
using Xunit.Abstractions;

//C:\Projects\RepoM-Git-repos


[SetTestName]
public class NotePadTest
{
Expand All @@ -27,18 +42,74 @@ public NotePadTest(ITestOutputHelper outputHelper)

// make sure no vs code instance is running.


public static void CopyDirectory(string sourceDirPath, string destDirPath)
{
if (!Directory.Exists(destDirPath))
{
Directory.CreateDirectory(destDirPath);
}

foreach (string filePath in Directory.GetFiles(sourceDirPath))
{
string fileName = Path.GetFileName(filePath);
string destFilePath = Path.Combine(destDirPath, fileName);
File.Copy(filePath, destFilePath, true);
}

foreach (string dirPath in Directory.GetDirectories(sourceDirPath))
{
string dirName = Path.GetFileName(dirPath);
string destDirFullPath = Path.Combine(destDirPath, dirName);
CopyDirectory(dirPath, destDirFullPath);
}
}

private void InitRepoM(string path)
{
Directory.CreateDirectory(path);
CopyDirectory("Configs", path);

IAppDataPathProvider appDataPathProvider = A.Fake<IAppDataPathProvider>();
A.CallTo(() => appDataPathProvider.AppDataPath).Returns(path);
var fs = new FileSystem();
var cacheStore = new DefaultRepositoryStore(appDataPathProvider, fs);

var cache = new List<string>()
{
@"C:\Projects\RepoM-Git-repos\RepoM\",
@"C:\Projects\RepoM-Git-repos\scriban\",
@"C:\Projects\RepoM-Git-repos\test\Verify\",
@"C:\Projects\RepoM-Git-repos\test\xunit\",
@"C:\Projects\RepoM-Git-repos\test\TUnit\",
};
cacheStore.Set(cache);

var fileAppSettingsService = new FileAppSettingsService(appDataPathProvider, fs, NullLogger.Instance);

fileAppSettingsService.ReposRootDirectories =
[
"C:\\Projects\\RepoM-Git-repos\\",
];
}

[Fact]
public async Task NotepadLaunchTest()
{
var basePath = Path.GetTempPath();
basePath = Path.Combine("C:", "tmp");
var path = Path.Combine(basePath, "RepoM-UI-testing", DateTime.UtcNow.ToString("yyyyMMdd-HHmmss"));
InitRepoM(path);
using var clearDirectory = ClearDirectoryOnDisposal(path);
using var appVsCode = ApplicationFactory.LaunchVsCode(@"C:\Users\Munckhof CJJ\AppData\Roaming\RepoM\RepositoryActionsV2.yaml");
using var appRepoM = ApplicationFactory.LaunchRepoM();
using var appRepoM = ApplicationFactory.LaunchRepoM(path);

using (var automationRepoM = new UIA3Automation())
// using (var automationVsCode = new UIA3Automation())
{
var automationVsCode = automationRepoM;

await Task.Delay(20_000);
await Task.Delay(10_000);
appRepoM.WaitWhileMainHandleIsMissing(TimeSpan.FromSeconds(5));
appRepoM.WaitWhileBusy(TimeSpan.FromSeconds(5));
appVsCode.WaitWhileMainHandleIsMissing(TimeSpan.FromSeconds(20));
Expand Down Expand Up @@ -114,4 +185,24 @@ public async Task NotepadLaunchTest()
appRepoM.Close();
appVsCode.Close();
}

private IDisposable ClearDirectoryOnDisposal(string path)
{
return new ClearDirectoryOnDisposal(path);
}
}

internal sealed class ClearDirectoryOnDisposal : IDisposable
{
private readonly string _path;

public ClearDirectoryOnDisposal(string path)
{
_path = path;
}

public void Dispose()
{
Directory.Delete(_path, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"Version": 1,
"Settings": {
"PersonalAccessToken": null,
"BaseUrl": null
}
}
8 changes: 8 additions & 0 deletions tests/UiTests/Configs/Module/Heidi.HeidiPackage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Version": 1,
"Settings": {
"ConfigPath": null,
"ConfigFilename": null,
"ExecutableFilename": null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"Version": 1,
"Settings": {
"PersonalAccessToken": null,
"BaseUrl": "https://sonarcloud.io"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"Version": 1,
"Settings": {
"PersistenceBuffer": "00:05:00",
"RetentionDays": 30
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"Version": 1,
"Settings": {
"Browsers": null,
"Profiles": null
}
}
18 changes: 18 additions & 0 deletions tests/UiTests/Configs/RepoM.Filtering.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Work:
name: Work
description: Work filtering
always-visible:
kind: query@1
query: is:pinned
filter:
kind: query@1
query: tag:work
Private:
name: Private
description: Private repositories
always-visible:
kind: query@1
query: RepoM OR is:pinned
filter:
kind: query@1
query: (-tag:work OR tag:private)
93 changes: 93 additions & 0 deletions tests/UiTests/Configs/RepoM.Ordering.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Work:
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
type: is-pinned-scorer@1
weight: 1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Team1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Work
- type: az-comparer@1
property: Name
weight: 1
Work Dynamic:
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
type: is-pinned-scorer@1
weight: 1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Team1
- type: score-comparer@1
score-provider:
type: usage-scorer@1
max-score: 20
windows:
- until: 00:15:00
weight: 4
max-items: 10
- until: 01:00:00
weight: 3
max-items: 5
- until: 24:00:00
weight: 2
max-items: 5
- until: 168:00:00
weight: 1
max-items: 10
- type: last-opened-comparer@1
weight: 1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Work
- type: az-comparer@1
property: Name
weight: 1
Prive:
type: composition-comparer@1
comparers:
- type: score-comparer@1
score-provider:
type: is-pinned-scorer@1
weight: 1
- type: score-comparer@1
score-provider:
type: tag-scorer@1
weight: 1
tag: Prive
- type: score-comparer@1
score-provider:
type: usage-scorer@1
max-score: 20
windows:
- until: 00:15:00
weight: 4
max-items: 10
- until: 01:00:00
weight: 3
max-items: 5
- until: 24:00:00
weight: 2
max-items: 5
- until: 168:00:00
weight: 1
max-items: 10
- type: last-opened-comparer@1
weight: 1
- type: az-comparer@1
property: Name
weight: 1
Loading

0 comments on commit 45f1cb6

Please sign in to comment.