Skip to content

Commit ae63ee5

Browse files
authored
Merge branch 'main' into consolidate-donation-modal-code
2 parents 34ab461 + 175ad65 commit ae63ee5

File tree

8 files changed

+114
-59
lines changed

8 files changed

+114
-59
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@
243243
"contributions": [
244244
"code"
245245
]
246+
},
247+
{
248+
"login": "yontank",
249+
"name": "Yehonatan Avrahimi",
250+
"avatar_url": "https://avatars.githubusercontent.com/u/48332126?v=4",
251+
"profile": "https://github.com/yontank",
252+
"contributions": [
253+
"code"
254+
]
246255
}
247256
]
248257
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ https://github.com/hasadna/open-bus-map-search/blob/main/src/model/busStop.ts#L4
9494
<td align="center" valign="top" width="14.28%"><a href="https://github.com/griseduardo"><img src="https://avatars.githubusercontent.com/u/34499486?v=4?s=100" width="100px;" alt="Eduardo Henrique Gris"/><br /><sub><b>Eduardo Henrique Gris</b></sub></a><br /><a href="#code-griseduardo" title="Code">💻</a></td>
9595
<td align="center" valign="top" width="14.28%"><a href="https://github.com/YaelChen"><img src="https://avatars.githubusercontent.com/u/51058584?v=4?s=100" width="100px;" alt="Yael Chen"/><br /><sub><b>Yael Chen</b></sub></a><br /><a href="#code-YaelChen" title="Code">💻</a> <a href="#test-YaelChen" title="Tests">⚠️</a></td>
9696
<td align="center" valign="top" width="14.28%"><a href="https://github.com/LeoBonjo"><img src="https://avatars.githubusercontent.com/u/139697327?v=4?s=100" width="100px;" alt="Leo Green"/><br /><sub><b>Leo Green</b></sub></a><br /><a href="#code-LeoBonjo" title="Code">💻</a></td>
97+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/yontank"><img src="https://avatars.githubusercontent.com/u/48332126?v=4?s=100" width="100px;" alt="Yehonatan Avrahimi"/><br /><sub><b>Yehonatan Avrahimi</b></sub></a><br /><a href="#code-yontank" title="Code">💻</a></td>
9798
</tr>
9899
</tbody>
99100
</table>

package-lock.json

Lines changed: 68 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "commonjs",
66
"dependencies": {
77
"@applitools/eyes-playwright": "^1.32.0",
8-
"@emotion/react": "^11.11.4",
8+
"@emotion/react": "^11.13.5",
99
"@emotion/styled": "^11.11.5",
1010
"@mui/icons-material": "^5.15.14",
1111
"@mui/lab": "^5.0.0-alpha.169",
@@ -107,7 +107,7 @@
107107
"@testing-library/react": "^16.0.1",
108108
"@testing-library/user-event": "^14.5.2",
109109
"@types/jest": "^29.5.12",
110-
"@types/leaflet": "^1.9.12",
110+
"@types/leaflet": "^1.9.14",
111111
"@types/lodash.debounce": "^4.0.7",
112112
"@types/node": "^20.12.8",
113113
"@types/react": "^18.2.58",

src/api/useVehicleLocations.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,22 @@ class LocationObservable {
114114
}
115115

116116
const pool = new Array(10).fill(0).map(() => Promise.resolve<void | Response>(void 0))
117-
async function fetchWithQueue(url: string, retries = 10) {
118-
let queue = pool.shift()!
119-
queue = queue
120-
.then(() => fetch(url))
121-
.catch(async () => {
122-
await new Promise((resolve) => setTimeout(resolve, 10000 * Math.random() + 100))
123-
return fetchWithQueue(url, retries - 1)
124-
})
125-
pool.push(queue)
126-
return queue
117+
async function fetchWithQueue(url: string) {
118+
const task = async () => {
119+
for (let attempt = 0; attempt < 3; attempt++) {
120+
try {
121+
return await fetch(url)
122+
} catch {
123+
if (attempt === 2) throw new Error(`Failed after 3 attempts`)
124+
await new Promise((resolve) => setTimeout(resolve, 1000 * 2 ** attempt))
125+
}
126+
}
127+
}
128+
129+
const queue = pool.shift()!
130+
const result = queue.then(task).finally(() => pool.push(Promise.resolve()))
131+
pool.push(result)
132+
return result
127133
}
128134

129135
// this function checks the cache for the data, and if it's not there, it loads it

src/layout/header/DonationButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { useState } from 'react'
22
import { useTranslation } from 'react-i18next'
33
import { DollarOutlined } from '@ant-design/icons'
4-
import DonateModal from '../../pages/DonateModal/DonateModal'
4+
import DonateModal from 'src/pages/DonateModal/DonateModal'
5+
56

67
export const DonationButton = () => {
78
const { t } = useTranslation()

src/pages/DonateModal/DonateModal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ const style = {
1919
p: 4,
2020
} as const
2121

22-
const DonateModal: React.FC<DonateModalProps> = ({ isVisible, onClose }) => {
22+
export const DonateModal: React.FC<DonateModalProps> = ({ isVisible, onClose }) => {
2323
return (
2424
<Modal
2525
open={isVisible}
2626
onClose={onClose}
27+
aria-modal="true"
28+
role="dialog"
2729
aria-labelledby="modal-modal-title"
2830
aria-describedby="modal-modal-description"
2931
sx={{

tests/visual.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,19 @@ test.describe('Visual Tests', () => {
106106
),
107107
)
108108
})
109+
test('donation modal should look good', async ({ page }) => {
110+
await page.goto('/')
111+
await page.getByLabel('לתרומות').click()
112+
await page.locator('.MuiTypography-root').first().waitFor()
113+
await eyes.check('donation modal', Target.region(page.getByRole('dialog')))
114+
})
115+
test('donation modal should look good in dark mode', async ({ page }) => {
116+
await page.goto('/')
117+
await page.getByLabel('עבור למצב כהה').click()
118+
await page.getByLabel('לתרומות').click()
119+
await page.locator('.MuiTypography-root').first().waitFor()
120+
await eyes.check('donation modal dark mode', Target.region(page.getByRole('dialog')))
121+
})
109122
})
110123

111124
function setBatchName(eyes: Eyes) {

0 commit comments

Comments
 (0)