• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mattonem / PharoJS / 14380852851

10 Apr 2025 12:48PM UTC coverage: 27.097% (+1.1%) from 26.047%
14380852851

push

github

web-flow
Update stable.yml

5702 of 21043 relevant lines covered (27.1%)

0.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.62
/Pharo/PharoJs-TestFramework/PjMultipageExpressClientTest.class.st
1
"
2
Root class for testing express JS clients with multiple pages. 
3
Each page is controlled via an app instance of a subclass of PjWebApplication.
4

5
- Subclasses should define pageAppClasses that answers the list of app classes for all pages to be tested.
6
- A test can directly open a given page using method #openPage: which argument is the app class of the page to open.
7
- A test can assert that a page is displayed using method #assertShowingPage:  which argument is the app class of the expected page
8

9
Implementation
10
Relies on PjPageViewerApp to open pages and eventually upon tearDown close them
11

12
"
13
Class {
14
        #name : 'PjMultipageExpressClientTest',
15
        #superclass : 'PjWebAppTestCase',
16
        #traits : 'PjTAppRunsInJS',
17
        #classTraits : 'PjTAppRunsInJS classTrait',
18
        #instVars : [
19
                'activeBridge',
20
                'pageViewer',
21
                'serverManagerBridge',
22
                'pageBridgesDict',
23
                'serverBridge'
24
        ],
25
        #category : 'PharoJs-TestFramework-Kernel',
26
        #package : 'PharoJs-TestFramework',
27
        #tag : 'Kernel'
28
}
29

30
{ #category : 'suite parameters' }
31
PjMultipageExpressClientTest class >> appClass [
×
32

×
33
        ^ PjPageViewerApp 
×
34
]
×
35

36
{ #category : 'testing' }
37
PjMultipageExpressClientTest class >> isAbstract [ 
1✔
38
        ^self == PjMultipageExpressClientTest 
1✔
39
]
1✔
40

41
{ #category : 'accessing' }
42
PjMultipageExpressClientTest >> appClass [ 
1✔
43
        self bridge ifNil: [ ^super appClass  ].
1✔
44
        ^self bridge appClass
1✔
45
]
1✔
46

47
{ #category : 'running' }
48
PjMultipageExpressClientTest >> assertShowingPage: anAppClass [
×
49
        "Refereshing bridge and app is done here, since it can often be called after some action that make the browser open another page"
×
50

×
51
        | otherBridges pageBridge |
×
52
        pageBridge := pageBridgesDict at: anAppClass.
×
53
        self resetTranspilerOf: anAppClass.
×
54
        self waitUntil: [ pageBridge isConnected ].
×
55
        self waitWhile: [ pageBridge app isNil ].
×
56
        self bridge: pageBridge.
×
57
        self resetInstanceVariables.
×
58
        self deny: app isNil.
×
59
        self assert: app identicalTo: pageBridge app.
×
60
        otherBridges := self pageBridges copyWithout: pageBridge.
×
61
        otherBridges do: [ :each | self deny: each isConnected ]
×
62
]
×
63

64
{ #category : 'accessing' }
65
PjMultipageExpressClientTest >> bridge [
1✔
66
        ^activeBridge ifNil: [ super bridge ]
1✔
67
]
1✔
68

69
{ #category : 'accessing' }
70
PjMultipageExpressClientTest >> bridge: aBridge [
×
71

×
72
        activeBridge := aBridge.
×
73
        PjBridge soleBridge: activeBridge
×
74
]
×
75

76
{ #category : 'running' }
77
PjMultipageExpressClientTest >> createPageBridges [
×
78

×
79
        pageBridgesDict := IdentityDictionary new.
×
80
        self pageAppClasses do: [ : class | 
×
81
                pageBridgesDict at: class put: class bridge
×
82
                ]
×
83
]
×
84

85
{ #category : 'running' }
86
PjMultipageExpressClientTest >> openPage: anAppClass [
×
87

×
88
        self openPage: anAppClass assertShowingPage: anAppClass 
×
89
]
×
90

91
{ #category : 'running' }
92
PjMultipageExpressClientTest >> openPage: providedAppClass assertShowingPage: landingAppClass [
×
93

×
94
        | pageBridge |
×
95
        "Use the bridge client since it knows which port to use. Otherwise only url path is provided and we attempt to get the page from the viewer's server. See PjPageViewerApp"
×
96
        pageBridge := pageBridgesDict at: providedAppClass.
×
97
        pageViewer open: pageBridge client urlString.
×
98
        "Refereshing bridge and app is done in the assertion, since it can often be called after some action that make the browser open another page"
×
99
        self assertShowingPage: landingAppClass
×
100
]
×
101

102
{ #category : 'running' }
103
PjMultipageExpressClientTest >> pageAppClasses [
×
104

×
105
        ^ self serverAppClass clientAppClasses
×
106
]
×
107

108
{ #category : 'accessing' }
109
PjMultipageExpressClientTest >> pageBridges [
×
110

×
111
        ^pageBridgesDict values
×
112
]
×
113

114
{ #category : 'running' }
115
PjMultipageExpressClientTest >> resetTranspilerOf: pageAppClass [
×
116
        "Dependent transpiler stores classes loaded dynamically by tests and DNU support methods installed in Object. This is an optimization to avoid sending several times the same code. But, the browser loses them each time it loads a new page. So, we need to reset the transpiler to ensure it sends them again if needed."
×
117

×
118
        | pageBridge |
×
119
        pageBridge := pageBridgesDict at: pageAppClass.
×
120
        pageBridge exporter resetTranspiler 
×
121
]
×
122

123
{ #category : 'accessing' }
124
PjMultipageExpressClientTest >> serverApp [
×
125

×
126
        ^ serverBridge app
×
127
]
×
128

129
{ #category : 'running' }
130
PjMultipageExpressClientTest >> serverAppClass [
131

132
        self subclassResponsibility
133
]
134

135
{ #category : 'accessing' }
136
PjMultipageExpressClientTest >> serverBridge [
×
137
        ^serverBridge 
×
138
]
×
139

140
{ #category : 'running' }
141
PjMultipageExpressClientTest >> setUp [
×
142

×
143
        super setUp.
×
144
        pageViewer := app.
×
145
        self setUpPageBridges
×
146
]
×
147

148
{ #category : 'running' }
149
PjMultipageExpressClientTest >> setUpOtherPageBridges [
×
150

×
151
        | otherPageBridges |
×
152
        otherPageBridges := self pageBridges copyWithout: serverManagerBridge.
×
153
        otherPageBridges do: [ :eachBridge |
×
154
                eachBridge client serverBridge: serverBridge.
×
155
                eachBridge shouldStartJsInterpreter: false.
×
156
                eachBridge startWithoutWaitingForClient ]
×
157
]
×
158

159
{ #category : 'running' }
160
PjMultipageExpressClientTest >> setUpPageBridges [
×
161

×
162
        self createPageBridges.
×
163
        self setUpServerManagerBridge.
×
164
        self setUpOtherPageBridges
×
165
]
×
166

167
{ #category : 'running' }
168
PjMultipageExpressClientTest >> setUpServerManagerBridge [
×
169

×
170
        serverManagerBridge := self pageBridges anyOne.
×
171
        serverManagerBridge
×
172
                shouldStartJsInterpreter: false;
×
173
                startWithoutWaitingForClient.
×
174
        serverBridge := serverManagerBridge client serverBridge.
×
175

×
176
]
×
177

178
{ #category : 'running' }
179
PjMultipageExpressClientTest >> tearDown [
×
180

×
181
        self tearDownPageBridges.
×
182
        super tearDown
×
183
]
×
184

185
{ #category : 'running' }
186
PjMultipageExpressClientTest >> tearDownPageBridges [
×
187

×
188
        self pageBridges do: [ :each |
×
189
                each stop. ]
×
190
]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc