// // UserDataTests.swift // PadelClubTests // // Created by Laurent Morvillier on 13/05/2024. // import XCTest import LeStorage @testable import PadelClub final class UserDataTests: XCTestCase { let username: String = "UserDataTests" let password: String = "MyPass1234--" override func setUpWithError() throws { StoreCenter.main.configureURLs(secureScheme: false, domain: "127.0.0.1:8000") } override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. } func testUserCreation() async throws { //<<<<<<< HEAD // let userCreationForm = UserCreationForm(user: CustomUser.placeHolder(), username: self.username, password: self.password, firstName: "jean", lastName: "coco", email: "test@lolomo.com", phone: "0123", country: "France") // let user: CustomUser = try await StoreCenter.main.service().createAccount(user: userCreationForm) //======= let userCreationForm = UserCreationForm(user: CustomUser.placeHolder(), username: self.username, password: self.password, firstName: "jean", lastName: "coco", email: "UserDataTests@lolomo.net", phone: "0123", country: "France") let user: CustomUser = try await StoreCenter.main.service().createAccount(user: userCreationForm) assert(user.username == userCreationForm.username) assert(user.firstName == userCreationForm.firstName) assert(user.lastName == userCreationForm.lastName) assert(user.email == userCreationForm.email) assert(user.phone == userCreationForm.phone) assert(user.country == userCreationForm.country) } func login() async throws -> CustomUser { let user: CustomUser = try await StoreCenter.main.service().login(username: self.username, password: self.password) return user } func testLogin() async throws { let _ = try await self.login() } func testUserUpdate() async throws { let user = try await self.login() user.summonsMessageBody = "hello" user.summonsMessageSignature = "jean coco" user.summonsAvailablePaymentMethods = "cash" user.summonsDisplayFormat = true user.summonsDisplayEntryFee = true user.summonsUseFullCustomMessage = true user.matchFormatsDefaultDuration = [MatchFormat.nineGames : 1] user.bracketMatchFormatPreference = MatchFormat.superTie user.groupStageMatchFormatPreference = MatchFormat.twoSets user.loserBracketMatchFormatPreference = MatchFormat.twoSetsOfFourGames user.loserBracketMode = .manual user.disableRankingFederalRuling = false user.deviceId = "device123" user.agents = ["agent1", "agent2"] user.userRole = 2 user.registrationPaymentMode = .disabled user.umpireCustomMail = "umpire@example.com" user.umpireCustomContact = "John Umpire" user.umpireCustomPhone = "+33612345678" user.hideUmpireMail = false if let uu = try await StoreCenter.main.service().put(user) { assert(uu.summonsMessageBody == user.summonsMessageBody) assert(uu.summonsMessageSignature == user.summonsMessageSignature) assert(uu.summonsAvailablePaymentMethods == user.summonsAvailablePaymentMethods) assert(uu.summonsDisplayFormat == user.summonsDisplayFormat) assert(uu.summonsDisplayEntryFee == user.summonsDisplayEntryFee) assert(uu.summonsUseFullCustomMessage == user.summonsUseFullCustomMessage) assert(uu.matchFormatsDefaultDuration == user.matchFormatsDefaultDuration) assert(uu.bracketMatchFormatPreference == user.bracketMatchFormatPreference) assert(uu.groupStageMatchFormatPreference == user.groupStageMatchFormatPreference) assert(uu.loserBracketMatchFormatPreference == user.loserBracketMatchFormatPreference) assert(uu.loserBracketMode == user.loserBracketMode) assert(uu.disableRankingFederalRuling == user.disableRankingFederalRuling) assert(uu.deviceId == user.deviceId) assert(uu.agents == user.agents) assert(uu.userRole == user.userRole) assert(uu.registrationPaymentMode == user.registrationPaymentMode) assert(uu.umpireCustomMail == user.umpireCustomMail) assert(uu.umpireCustomContact == user.umpireCustomContact) assert(uu.umpireCustomPhone == user.umpireCustomPhone) assert(uu.hideUmpireMail == user.hideUmpireMail) assert(uu.hideUmpirePhone == user.hideUmpirePhone) } else { XCTFail("missing data") } } }