Skip to content

Commit e3b1df3

Browse files
authored
Merge pull request #21 from remotemobprogramming/smoketests
Smoketests
2 parents 4e1e2af + 32ba8aa commit e3b1df3

3 files changed

Lines changed: 21 additions & 41 deletions

File tree

.github/workflows/smoketest.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
on:
22
schedule:
33
- cron: '*/5 * * * *'
4-
push:
5-
name: Smoketest
4+
name: Smoketest on PROD
65
jobs:
76
smoketest:
87
runs-on: ubuntu-latest
9-
name: Smoketest
8+
name: Smoketest on PROD
109
steps:
1110
- name: Checkout
1211
uses: actions/checkout@v2
13-
1412
- name: Cypress run
1513
uses: cypress-io/github-action@v4
1614
with:
1715
working-directory: cypress
18-
#spec: cypress/cypress/e2e/smoketest.cy.js
19-
- uses: actions/upload-artifact@v2
16+
- name: Upload screenshots
17+
uses: actions/upload-artifact@v2
2018
if: failure()
2119
with:
2220
name: cypress-screenshots
2321
path: cypress/cypress/screenshots
24-
# Test run video was always captured, so this action uses "always()" condition
25-
- uses: actions/upload-artifact@v2
22+
- name: Upload videos
23+
uses: actions/upload-artifact@v2
2624
if: failure()
2725
with:
2826
name: cypress-videos

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)