Skip to content

Commit 52a2c8d

Browse files
committed
smoketests
1 parent 4e1e2af commit 52a2c8d

2 files changed

Lines changed: 15 additions & 33 deletions

File tree

cypress/cypress/e2e/smoketest.cy.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,4 @@ describe('Mob.sh Timer', () => {
4242
cy.get('#timer').should('not.contain', '00:00')
4343
cy.get('#timer-type').contains('☕')
4444
})
45-
46-
it('history increases for timer button', () => {
47-
cy.visit('https://timer.mob.sh/' + roomId)
48-
cy.get('[data-bs-toggle="modal"]').click()
49-
cy.get('#timer-input').clear().type("1")
50-
cy.wait(100)
51-
cy.get('.btn-close').click()
52-
let initialHistoryCountChainer = cy.get('#history-container').find('li').its('length')
53-
cy.get('#timer-button').contains(1).click().wait(200)
54-
cy.get('#history-container').find('li').its('length').then(currentCount => {
55-
initialHistoryCountChainer.should('eq', currentCount - 1)
56-
})
57-
})
58-
59-
it('history increases for breaktimer button', () => {
60-
cy.visit('https://timer.mob.sh/' + roomId)
61-
cy.get('[data-bs-toggle="modal"]').click()
62-
cy.get('#breaktimer-input').clear().type("1")
63-
cy.wait(100)
64-
cy.get('.btn-close').click()
65-
let initialHistoryCountChainer = cy.get('#history-container').find('li').its('length')
66-
cy.get('#breaktimer-button').contains(1).click().wait(200)
67-
cy.get('#history-container').find('li').its('length').then(currentCount => {
68-
initialHistoryCountChainer.should('eq', currentCount - 1)
69-
})
70-
})
7145
})

src/main/java/sh/mob/timer/web/RoomApiController.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
@RequestMapping()
2525
public class RoomApiController {
2626

27-
private static final String SMOKETEST_ROOM_NAME_PREFIX = "testroom-";
27+
private static final String SMOKETEST_ROOM_NAME = "testroom-310a9c47-515c-4ad7-a229-ae8efbab7387";
2828
private static final Logger log = LoggerFactory.getLogger(RoomApiController.class);
2929
private final RoomRepository roomRepository;
3030
private final Clock clock;
@@ -83,9 +83,7 @@ public void publishEvent(@PathVariable String roomId, @RequestBody PutTimerReque
8383
timerRequest.timer,
8484
timerRequest.user,
8585
room.name());
86-
if (!room.name().startsWith(SMOKETEST_ROOM_NAME_PREFIX)) {
87-
stats.incrementTimer(timer);
88-
}
86+
incrementTimerStatsExceptForTestRoom(room, timer);
8987
} else if (timerRequest.breaktimer() != null) {
9088
long breaktimer = truncateTooLongTimers(timerRequest.breaktimer());
9189
room.addBreaktimer(breaktimer, timerRequest.user());
@@ -94,14 +92,24 @@ public void publishEvent(@PathVariable String roomId, @RequestBody PutTimerReque
9492
timerRequest.breaktimer(),
9593
timerRequest.user,
9694
room.name());
97-
if (!room.name().startsWith(SMOKETEST_ROOM_NAME_PREFIX)) {
98-
stats.incrementBreaktimer(breaktimer);
99-
}
95+
incrementBreakTimerStatsExceptForTestRoom(room, breaktimer);
10096
} else {
10197
log.warn("Could not understand PUT request for room {}", roomId);
10298
}
10399
}
104100

101+
private void incrementBreakTimerStatsExceptForTestRoom(Room room, long breaktimer) {
102+
if (!Objects.equals(room.name(), SMOKETEST_ROOM_NAME)) {
103+
stats.incrementBreaktimer(breaktimer);
104+
}
105+
}
106+
107+
private void incrementTimerStatsExceptForTestRoom(Room room, long timer) {
108+
if (!Objects.equals(room.name(), SMOKETEST_ROOM_NAME)) {
109+
stats.incrementTimer(timer);
110+
}
111+
}
112+
105113
private static long truncateTooLongTimers(Long timer) {
106114
return Math.min(60 * 24, Math.max(0, timer));
107115
}

0 commit comments

Comments
 (0)