/*
* Copyright (c) 2026 Proton AG
*
* This file is part of ProtonVPN.
*
* ProtonVPN is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ProtonVPN is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProtonVPN. If not, see .
*/
using System.Threading;
using System.Collections.Generic;
using NUnit.Framework;
using ProtonVPN.UI.Tests.UiTools;
using ProtonVPN.UI.Tests.TestsHelper;
namespace ProtonVPN.UI.Tests.Robots;
public class ConfirmationRobot
{
protected Element OverlayMessage => Element.ByAutomationId("OverlayMessage");
protected Element PrimaryActionButton => Element.ByAutomationId("PrimaryButton");
protected Element SecondaryActionButton => Element.ByAutomationId("SecondaryButton");
protected Element CancelActionButton => Element.ByAutomationId("CloseButton");
public ConfirmationRobot PrimaryAction()
{
PrimaryActionButton.Click();
return this;
}
public ConfirmationRobot SecondaryAction()
{
SecondaryActionButton.Click();
return this;
}
public ConfirmationRobot CancelAction()
{
CancelActionButton.Click();
return this;
}
public class Verifications : ConfirmationRobot
{
public Verifications IsOverlayDisplayed()
{
OverlayMessage.WaitUntilDisplayed();
return this;
}
public Verifications IsOverlayClosed()
{
Thread.Sleep(TestConstants.AnimationDelay);
OverlayMessage.DoesNotExist();
return this;
}
public Verifications OverlayTextContains(string text)
{
List allChildren = OverlayMessage.GetAllChildrenNames();
Assert.That(allChildren, Does.Contain(text));
return this;
}
public Verifications OverlayButtonsEquals(string? primary = null, string? secondary = null, string? cancel = null)
{
if (!string.IsNullOrEmpty(primary))
{
PrimaryActionButton.WaitUntilDisplayed();
PrimaryActionButton.TextEquals(primary);
}
if (!string.IsNullOrEmpty(secondary))
{
SecondaryActionButton.WaitUntilDisplayed();
SecondaryActionButton.TextEquals(secondary);
}
if (!string.IsNullOrEmpty(cancel))
{
CancelActionButton.WaitUntilDisplayed();
CancelActionButton.TextEquals(cancel);
}
return this;
}
}
public Verifications Verify => new();
}