Skip to content

Commit 6e08da4

Browse files
committed
Use (inbuilt) junit to pull apart page into events with message, user_id and (possibly) e2e status.
1 parent 71c24b4 commit 6e08da4

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

cypress/e2e/trafficlight/trafficlight.spec.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ function recurse() {
104104
const respondUrl = `${Cypress.env('TRAFFICLIGHT_URL') }/client/${ Cypress.env('TRAFFICLIGHT_UUID') }/respond`;
105105

106106
function sendResponse(responseStatus) {
107-
cy.request('POST', respondUrl, { response: responseStatus }).then((response) => {
107+
let data;
108+
if (typeof responseStatus == "string") {
109+
data = { response: responseStatus };
110+
} else {
111+
data = responseStatus;
112+
}
113+
cy.request('POST', respondUrl, data).then((response) => {
108114
expect(response.status).to.eq(200);
109115
});
110116
}
@@ -130,7 +136,7 @@ function recurse() {
130136
});
131137
}
132138

133-
function runAction(action: string, data: JSONValue): string | undefined {
139+
function runAction(action: string, data: JSONValue): string | JSONValue | undefined {
134140
switch (action) {
135141
// Auth
136142
case 'register':
@@ -246,6 +252,22 @@ function runAction(action: string, data: JSONValue): string | undefined {
246252
}
247253
return advanceClock(milliseconds);
248254
}
255+
case "get_timeline": {
256+
cy.log("Searching for information");
257+
const rsp = [];
258+
// TODO: assert we're in a specific room at this time.
259+
Cypress.$('.mx_EventTile').each(
260+
function(index, obj) {
261+
tile = {};
262+
tile['user'] = Cypress.$(obj).find(".mx_BaseAvatar_image").attr("title");
263+
const e2eicon = Cypress.$(obj).find(".mx_EventTile_e2eIcon").attr("class");
264+
tile['e2e_issues'] = e2eicon;
265+
tile['message'] = Cypress.$(obj).find(".mx_EventTile_content").text();
266+
rsp.push(tile);
267+
},
268+
);
269+
return { "response": "got_timeline", "timeline": { "timeline": rsp } };
270+
}
249271
case "clear_idb_storage":
250272
return clearIDBStorage();
251273
case "reload":

src/trafficlight.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async function uploadFile(trafficlightUrl: string, uuid: string, filename: strin
8686
return promise;
8787
}
8888

89-
async function runCypress(trafficlightUrl: string, uuid: string): Promise<boolean> {
89+
async function runCypress(trafficlightUrl: string, uuid: string, openMode: boolean): Promise<boolean> {
9090
const cypressOptions = {
9191
headed: true,
9292
// @ts-ignore-next-line
@@ -101,7 +101,7 @@ async function runCypress(trafficlightUrl: string, uuid: string): Promise<boolea
101101
},
102102
config: {
103103
retries: { // Override cypress.json - we want to run exactly once.
104-
'openMode': 0,
104+
'openMode': openMode ? 1 : 0,
105105
'runMode': 0,
106106
},
107107
e2e: {
@@ -132,17 +132,25 @@ async function runCypress(trafficlightUrl: string, uuid: string): Promise<boolea
132132
}
133133
}
134134

135-
async function runRepeatedly(trafficlightUrl: string) {
135+
async function runRepeatedly(trafficlightUrl: string, openMode: boolean) {
136136
// need to find an exit condition here
137137
let shouldContinue = true;
138138
while (shouldContinue) {
139139
const uuid = crypto.randomUUID();
140140
await registerClient(trafficlightUrl, uuid);
141-
shouldContinue = await runCypress(trafficlightUrl, uuid);
141+
shouldContinue = await runCypress(trafficlightUrl, uuid, openMode);
142142
}
143143
}
144144

145145
const trafficlightUrl = process.env.TRAFFICLIGHT_URL || 'http://127.0.0.1:5000';
146-
runRepeatedly(trafficlightUrl).then((result) => {
146+
147+
let openMode = false;
148+
for (let i = 0; i < process.argv.length; i++) {
149+
if (process.argv[i] == "open") {
150+
openMode = true;
151+
}
152+
}
153+
154+
runRepeatedly(trafficlightUrl, openMode).then((result) => {
147155
console.log(`Finished looping forever(?), got ${result}`);
148156
});

0 commit comments

Comments
 (0)