Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed await/async in tests #57

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/demo-test/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension XCTestCase {

func waitForLoader(_ app: XCUIApplication) async {
// Wait for the loading indicator to disappear = content is ready
let activityIndicator = app.otherElements["LoaderView"]
let activityIndicator = await app.otherElements["LoaderView"]
expectation(for: NSPredicate(format: "exists == 0"), evaluatedWith: activityIndicator)
await waitForExpectations(timeout: 30)
}
Expand Down
2 changes: 1 addition & 1 deletion demo/demo-test/keepSessionAlive_test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class keepSessionAlive_test: XCTestCase {



let successField = app.staticTexts["test@frontegg.com"]
let successField = await app.staticTexts["test@frontegg.com"]
XCTAssert(successField.waitForExistence(timeout: 10))

DispatchQueue.main.sync { app.terminate() }
Expand Down
12 changes: 6 additions & 6 deletions demo/demo-test/loginWithMagicLink_test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,30 @@ final class loginWithMagicLink_test: XCTestCase {
await waitForLoader(app)


let userNameField = app.getWebInput("Email is required")
let userNameField = await app.getWebInput("Email is required")
sleep(1)
userNameField.safeTypeText("test@frontegg.com")
await userNameField.safeTypeText("test@frontegg.com")


await Mocker.mock(name: .mockPreLoginWithMagicLink, body: [:])

app.getWebButton("Continue").safeTap()
await app.getWebButton("Continue").safeTap()


app.waitWebLabel("Magic link sent!")
await app.waitWebLabel("Magic link sent!")

takeScreenshot(named: "MagicLinkSent")

let magicLinkUrl = await Mocker.mockSuccessMagicLink(code)
let safari = DeepLinkUtils.openFromSafari(with: magicLinkUrl)

safari.getWebButton("Sign In").safeTap()
await safari.getWebButton("Sign In").safeTap()


XCTAssert(app.wait(for: .runningForeground, timeout: 10))


let successField = app.staticTexts["test@frontegg.com"]
let successField = await app.staticTexts["test@frontegg.com"]
XCTAssert(successField.waitForExistence(timeout: 20))

DispatchQueue.main.sync { app.terminate() }
Expand Down
10 changes: 5 additions & 5 deletions demo/demo-test/loginWithOIDC_test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ final class loginWithOIDC_test: XCTestCase {

await waitForLoader(app)

app.getWebInput("Email is required")
await app.getWebInput("Email is required")
.safeTypeText("test@oidc-domain.com")

await Mocker.mock(name: .mockSSOPrelogin, body: ["options": ["success":"true", "idpType": "oidc"],
"partialRequestBody": ["email": "test@oidc-domain.com"]])

app.getWebButton("Continue").safeTap()
await app.getWebButton("Continue").safeTap()

app.waitWebLabel("OKTA OIDC Mock Server")
await app.waitWebLabel("OKTA OIDC Mock Server")


await Mocker.mockSuccessOidcLogin(code)

app.getWebButton("Login With Okta").safeTap()
await app.getWebButton("Login With Okta").safeTap()


let successField = app.staticTexts["test@oidc-domain.com"]
let successField = await app.staticTexts["test@oidc-domain.com"]
XCTAssert(successField.waitForExistence(timeout: 10))

DispatchQueue.main.sync { app.terminate() }
Expand Down
16 changes: 8 additions & 8 deletions demo/demo-test/loginWithPassword_test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,33 @@ final class loginWithPassword_test: XCTestCase {

await waitForLoader(app)

let userNameField = app.getWebInput("Email is required")
let userNameField = await app.getWebInput("Email is required")

takeScreenshot(named: "LoginPage")

userNameField.safeTypeText("test@frontegg.com")
await userNameField.safeTypeText("test@frontegg.com")


await Mocker.mock(name: .mockSSOPrelogin, body: [ "options": ["success": false]])

let continueButton = app.getWebButton("Continue")
let continueButton = await app.getWebButton("Continue")

takeScreenshot(named: "PreLogin")
continueButton.safeTap()
await continueButton.safeTap()


let passwordField = app.getWebPasswordInput("Password is required")
let passwordField = await app.getWebPasswordInput("Password is required")

passwordField.safeTypeText("Testpassword")
await passwordField.safeTypeText("Testpassword")


await Mocker.mockSuccessPasswordLogin(code)


app.getWebButton("Sign in").safeTap()
await app.getWebButton("Sign in").safeTap()


let successField = app.staticTexts["test@frontegg.com"]
let successField = await app.staticTexts["test@frontegg.com"]
XCTAssert(successField.waitForExistence(timeout: 10))

DispatchQueue.main.sync { app.terminate() }
Expand Down
22 changes: 11 additions & 11 deletions demo/demo-test/loginWithSAML_test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class loginWithSAML_test: XCTestCase {

await waitForLoader(app)

let userNameField = app.getWebInput("Email is required")
let userNameField = await app.getWebInput("Email is required")


takeScreenshot(named: "LoginPage")
Expand All @@ -49,11 +49,11 @@ final class loginWithSAML_test: XCTestCase {
await Mocker.mock(name: .mockSSOPrelogin, body: ["options": ["success":"true", "idpType": "saml"],
"partialRequestBody": ["email": "test@saml-domain.com"]])

userNameField.safeTypeText("test@saml-domain.com")
await userNameField.safeTypeText("test@saml-domain.com")

app.getWebButton("Continue").safeTap()
await app.getWebButton("Continue").safeTap()

app.waitWebLabel("OKTA SAML Mock Server")
await app.waitWebLabel("OKTA SAML Mock Server")


await Mocker.mock(name: .mockSSOAuthSamlCallback, body: ["options":[
Expand All @@ -63,25 +63,25 @@ final class loginWithSAML_test: XCTestCase {



app.getWebButton("Login With Okta").safeTap()
await app.getWebButton("Login With Okta").safeTap()


let backToLoginButton = app.getWebLabel("Back to Sign-in")
let backToLoginButton = await app.getWebLabel("Back to Sign-in")
takeScreenshot(named: "Invalid Saml")
backToLoginButton.safeTap()
await backToLoginButton.safeTap()


app.getWebInput("Email is required").safeTypeText("test@saml-domain.com")
await app.getWebInput("Email is required").safeTypeText("test@saml-domain.com")

app.getWebButton("Continue").safeTap()
await app.getWebButton("Continue").safeTap()


await Mocker.mockSuccessSamlLogin(code)

app.getWebButton("Login With Okta").safeTap()
await app.getWebButton("Login With Okta").safeTap()


let successField = app.staticTexts["test@saml-domain.com"]
let successField = await app.staticTexts["test@saml-domain.com"]
XCTAssert(successField.waitForExistence(timeout: 10))

DispatchQueue.main.sync { app.terminate() }
Expand Down
Loading