-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_e2e.ps1
43 lines (34 loc) · 1.19 KB
/
run_e2e.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Pre run
Write-Output "Pre run..."
$configFile = 'Onibi_Pro/appsettings.Development.json'
$jsonContent = Get-Content $configFile | ConvertFrom-Json
$connectionString = $jsonContent.ConnectionStrings.SqlServerConnection_McDowel
$connection = New-Object System.Data.SqlClient.SqlConnection($connectionString)
$connection.Open()
$query = @"
SELECT MAX(OrderTime) AS LatestOrderTime
FROM Orders
"@
$command = $connection.CreateCommand()
$command.CommandText = $query
$latestOrderTime = $command.ExecuteScalar()
# Test
Write-Output "Running tests..."
$env:PWTEST_SKIP_TEST_OUTPUT = 1
Push-Location -Path "Onibi_Pro/ClientApp"
npx playwright test --workers=1 --project=chromium
Pop-Location
# Cleanup
Write-Output "Cleaning up..."
$deleteOrdersQuery = @"
DELETE FROM Orders
WHERE OrderTime > '$latestOrderTime'
"@
$deleteOrdersCommand = $connection.CreateCommand()
$deleteOrdersCommand.CommandText = $deleteOrdersQuery
$deleteOrdersCommand.ExecuteNonQuery()
$deleteEmployeesCommand = $connection.CreateCommand()
$deleteEmployeesCommand.CommandText = "DELETE dbo.Employees WHERE Email LIKE '%@e2e.com'"
$deleteEmployeesCommand.ExecuteNonQuery()
$connection.Close()
Write-Output "Script execution completed successfully."