Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7e37b0e

Browse files
chore: extract CoderSDK to framework (#19)
Closes#2.
1 parent51bc926 commit7e37b0e

File tree

21 files changed

+787
-325
lines changed

21 files changed

+787
-325
lines changed

‎Coder Desktop/Coder Desktop.xcodeproj/project.pbxproj

Lines changed: 344 additions & 59 deletions
Large diffs are not rendered by default.

‎Coder Desktop/Coder Desktop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Coder Desktop/Coder Desktop.xcodeproj/xcshareddata/xcschemes/Coder Desktop.xcscheme

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@
7979
ReferencedContainer ="container:Coder Desktop.xcodeproj">
8080
</BuildableReference>
8181
</TestableReference>
82+
<TestableReference
83+
skipped ="NO"
84+
parallelizable ="YES">
85+
<BuildableReference
86+
BuildableIdentifier ="primary"
87+
BlueprintIdentifier ="AA3B40972D2FC8560099996A"
88+
BuildableName ="CoderSDKTests.xctest"
89+
BlueprintName ="CoderSDKTests"
90+
ReferencedContainer ="container:Coder Desktop.xcodeproj">
91+
</BuildableReference>
92+
</TestableReference>
8293
</Testables>
8394
</TestAction>
8495
<LaunchAction

‎Coder Desktop/Coder Desktop.xctestplan

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@
1919
{
2020
"target" : {
2121
"containerPath" : "container:Coder Desktop.xcodeproj",
22-
"identifier" : "9616790E2CFF100E00B2B6DF",
23-
"name" : "Coder DesktopTests"
22+
"identifier" : "AA3B40972D2FC8560099996A",
23+
"name" : "CoderSDKTests"
24+
}
25+
},
26+
{
27+
"enabled" : false,
28+
"parallelizable" : true,
29+
"target" : {
30+
"containerPath" : "container:Coder Desktop.xcodeproj",
31+
"identifier" : "961679182CFF100E00B2B6DF",
32+
"name" : "Coder DesktopUITests"
2433
}
2534
},
2635
{
@@ -31,12 +40,10 @@
3140
}
3241
},
3342
{
34-
"enabled" : false,
35-
"parallelizable" : true,
3643
"target" : {
3744
"containerPath" : "container:Coder Desktop.xcodeproj",
38-
"identifier" : "961679182CFF100E00B2B6DF",
39-
"name" : "CoderDesktopUITests"
45+
"identifier" : "9616790E2CFF100E00B2B6DF",
46+
"name" : "CoderDesktopTests"
4047
}
4148
}
4249
],

‎Coder Desktop/Coder Desktop/Coder_DesktopApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct DesktopApp: App {
1111
EmptyView()
1212
}
1313
Window("Sign In", id:Windows.login.rawValue){
14-
LoginForm<PreviewClient,PreviewSession>()
14+
LoginForm<PreviewSession>()
1515
}.environmentObject(appDelegate.session)
1616
.windowResizability(.contentSize)
1717
}

‎Coder Desktop/Coder Desktop/Preview Content/PreviewClient.swift

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎Coder Desktop/Coder Desktop/SDK/Client.swift

Lines changed: 0 additions & 140 deletions
This file was deleted.

‎Coder Desktop/Coder Desktop/SDK/User.swift

Lines changed: 0 additions & 37 deletions
This file was deleted.

‎Coder Desktop/Coder Desktop/Views/LoginForm.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import CoderSDK
12
import SwiftUI
23

3-
structLoginForm<C:Client,S:Session>:View{
4+
structLoginForm<S:Session>:View{
45
@EnvironmentObjectvarsession:S
56
@Environment(\.dismiss)privatevardismiss
67

@@ -69,7 +70,7 @@ struct LoginForm<C: Client, S: Session>: View {
6970
}
7071
loading=true
7172
defer{ loading=false}
72-
letclient=C(url: url, token: sessionToken)
73+
letclient=Client(url: url, token: sessionToken)
7374
do{
7475
_=tryawait client.user("me")
7576
}catch{
@@ -188,6 +189,6 @@ enum LoginField: Hashable {
188189
}
189190

190191
#Preview{
191-
LoginForm<PreviewClient,PreviewSession>()
192+
LoginForm<PreviewSession>()
192193
.environmentObject(PreviewSession())
193194
}

‎Coder Desktop/Coder DesktopTests/LoginFormTests.swift

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
@testableimport Coder_Desktop
2+
@testableimport CoderSDK
3+
import Mocker
24
import SwiftUI
35
import Testing
46
import ViewInspector
@@ -7,12 +9,12 @@ import ViewInspector
79
@Suite(.timeLimit(.minutes(1)))
810
structLoginTests{
911
letsession:MockSession
10-
letsut:LoginForm<MockClient,MockSession>
12+
letsut:LoginForm<MockSession>
1113
letview:anyView
1214

1315
init(){
1416
session=MockSession()
15-
sut=LoginForm<MockClient,MockSession>()
17+
sut=LoginForm<MockSession>()
1618
view= sut.environmentObject(session)
1719
}
1820

@@ -68,14 +70,16 @@ struct LoginTests {
6870

6971
@Test
7072
func testFailedAuthentication()asyncthrows{
71-
letlogin=LoginForm<MockErrorClient,MockSession>()
73+
letlogin=LoginForm<MockSession>()
74+
leturl=URL(string:"https://testFailedAuthentication.com")!
75+
Mock(url: url.appendingPathComponent("/api/v2/users/me"), statusCode:401, data:[.get:Data()]).register()
7276

7377
tryawaitViewHosting.host(login.environmentObject(session)){
7478
tryawait login.inspection.inspect{ viewin
75-
try view.find(ViewType.TextField.self).setInput("https://coder.example.com")
79+
try view.find(ViewType.TextField.self).setInput(url.absoluteString)
7680
try view.find(button:"Next").tap()
7781
#expect(throws:Never.self){try view.find(text:"Session Token")}
78-
try view.find(ViewType.SecureField.self).setInput("valid-token")
82+
try view.find(ViewType.SecureField.self).setInput("invalid-token")
7983
tryawait view.actualView().submit()
8084
#expect(throws:Never.self){try view.find(ViewType.Alert.self)}
8185
}
@@ -84,9 +88,33 @@ struct LoginTests {
8488

8589
@Test
8690
func testSuccessfulLogin()asyncthrows{
91+
leturl=URL(string:"https://testSuccessfulLogin.com")!
92+
93+
letuser=User(
94+
id:UUID(),
95+
username:"admin",
96+
avatar_url:"",
97+
name:"admin",
98+
email:"admin@coder.com",
99+
created_at:Date.now,
100+
updated_at:Date.now,
101+
last_seen_at:Date.now,
102+
status:"active",
103+
login_type:"none",
104+
theme_preference:"dark",
105+
organization_ids:[],
106+
roles:[]
107+
)
108+
109+
tryMock(
110+
url: url.appendingPathComponent("/api/v2/users/me"),
111+
statusCode:200,
112+
data:[.get:Client.encoder.encode(user)]
113+
).register()
114+
87115
tryawaitViewHosting.host(view){
88116
tryawait sut.inspection.inspect{ viewin
89-
try view.find(ViewType.TextField.self).setInput("https://coder.example.com")
117+
try view.find(ViewType.TextField.self).setInput(url.absoluteString)
90118
try view.find(button:"Next").tap()
91119
try view.find(ViewType.SecureField.self).setInput("valid-token")
92120
tryawait view.actualView().submit()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp