Skip to content

Commit

Permalink
Merge pull request #251 from JHWelch/programming-by
Browse files Browse the repository at this point in the history
Programming by
  • Loading branch information
JHWelch authored Dec 12, 2024
2 parents a109047 + df8f3cd commit 519cf14
Show file tree
Hide file tree
Showing 19 changed files with 223 additions and 26 deletions.
Binary file added client/public/fonts/PlaywriteCO.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions client/src/__tests__/utils/factories/weekFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class WeekFactory extends Factory<WeekDto> {
slug: null,
styledTheme: [],
movies: [],
submittedBy: null,
}

public withMovies = (movies: MovieDto[]): WeekFactory => {
Expand Down
8 changes: 8 additions & 0 deletions client/src/components/WeekItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ defineProps<{
/>

<Theme :week="week" />

<span
v-if="week.submittedBy"
class="mt-2 text-lg text-purp-dark font-playwrite font-extralight"
>
Programming By
<span class="font-normal">{{ week.submittedBy }}</span>
</span>
</h3>

<button
Expand Down
73 changes: 72 additions & 1 deletion client/src/components/__tests__/WeekItem.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/** @vitest-environment jsdom */

import { expect, it } from 'vitest'
import { describe, expect, it } from 'vitest'
import { mount } from '@vue/test-utils'
import WeekItem from '@components/WeekItem.vue'
import WeekFactory from '@tests/utils/factories/weekFactory'
import SkippedBanner from '@components/SkippedBanner.vue'

it('has id of the week\'s slug', () => {
const week = new WeekFactory().build({ slug: 'week-slug' })
Expand All @@ -16,3 +17,73 @@ it('has id of the week\'s slug', () => {

expect(wrapper.find('#week-slug').exists()).toBe(true)
})

it('has all week details', () => {
const week = new WeekFactory().build()
const wrapper = mount(WeekItem, {
props: {
week: week,
showEventDetails: true,
},
})

expect(wrapper.text()).toContain(week.theme)
expect(wrapper.text()).toContain(week.date)
})

describe('is not skipped', () => {
it('does not show skipped banner', () => {
const week = new WeekFactory().build()
const wrapper = mount(WeekItem, {
props: {
week: week,
showEventDetails: true,
},
})

expect(wrapper.findComponent(SkippedBanner).exists()).toBe(false)
})
})

describe('is skipped', () => {
it('shows skipped banner', () => {
const week = new WeekFactory().build({ isSkipped: true })
const wrapper = mount(WeekItem, {
props: {
week: week,
showEventDetails: true,
},
})

expect(wrapper.findComponent(SkippedBanner).exists()).toBe(true)
})
})

describe('does not has submitted by', () => {
it('does not show Programming By', () => {
const week = new WeekFactory().build({ submittedBy: null })
const wrapper = mount(WeekItem, {
props: {
week: week,
showEventDetails: true,
},
})

expect(wrapper.text()).not.toContain('Programming By')
})
})

describe('has submitted by', () => {
it('shows Programming By', () => {
const week = new WeekFactory().build({ submittedBy: 'John Doe' })
const wrapper = mount(WeekItem, {
props: {
week: week,
showEventDetails: true,
},
})

expect(wrapper.text()).toContain('Programming By')
expect(wrapper.text()).toContain('John Doe')
})
})
1 change: 1 addition & 0 deletions client/src/pages/PageNotFound.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const week = {
date: '1939-12-15',
isSkipped: false,
slug: null,
submittedBy: null,
styledTheme: [],
movies: [],
}
Expand Down
7 changes: 7 additions & 0 deletions client/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
font-family: Inter, sans-serif;
font-feature-settings: 'liga' 1, 'calt' 1; /* fix for Chrome */
}
@layer base {
@font-face {
font-family: 'Playwrite';
font-weight: 100 400;
src: url(/fonts/PlaywriteCO.ttf) format('truetype');
}
}
@supports (font-variation-settings: normal) {
:root { font-family: InterVariable, sans-serif; }
}
Expand Down
3 changes: 3 additions & 0 deletions client/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export default {
'./src/**/*.ts',
],
theme: {
fontFamily: {
playwrite: ['Playwrite', 'sans-serif'],
},
extend: {
colors: {
brat: {
Expand Down
2 changes: 2 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ node_modules/

# dataconnect generated files
.dataconnect

emulator-cache/*
76 changes: 75 additions & 1 deletion server/__tests__/controllers/cacheWeeksController.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ describe('store', () => {
date: '2021-01-01',
theme: 'theme1',
lastEditedTime: '2022-08-12T15:45:00.000Z',
submittedBy: 'submittedBy',
}),
NotionMock.mockWeek({
id: 'id2',
Expand Down Expand Up @@ -181,6 +182,7 @@ describe('store', () => {
theme: 'theme1',
date: '2021-01-01',
lastEditedTime: '2022-08-12T15:45:00.000Z',
submittedBy: 'submittedBy',
}),
)
expect(transaction.set)
Expand Down Expand Up @@ -371,7 +373,7 @@ describe('store', () => {
})
})

describe('when no movies are returned', () => {
describe('when no weeks are returned', () => {
beforeEach(() => {
notionMock.mockIsFullPageOrDatabase(true)
FirebaseMock.mockGetGlobal('lastUpdated',{
Expand Down Expand Up @@ -411,6 +413,78 @@ describe('store', () => {
})
})

describe('movies with all details', () => {
let expected: Movie

const movieDetails = {
title: 'movieTitle',
director: 'movieDirector',
year: 2021,
length: 90,
time: '6:00 PM',
url: 'https://www.themoviedb.org/movie/1234',
posterPath: '/poster.jpg',
theaterName: 'movieTheaterName',
showingUrl: 'movieShowingUrl',
}

beforeEach(() => {
expected = new Movie({
notionId: 'notionId',
...movieDetails,
})
const notionResponse = new NotionMovie({
id: 'notionId',
...movieDetails,
})
notionMock.mockIsFullPageOrDatabase(true)
notionMock.mockQuery([
NotionMock.mockWeek({
id: 'id1',
date: '2021-01-01',
theme: 'theme1',
movies: [notionResponse],
lastEditedTime: DateTime.now().toISO(),
}),
])
notionMock.mockRetrieve(notionResponse)
req = getMockReq()
})

it('returns the updated data', async () => {
await newCacheController().store(req, res)

expect(res.status).toHaveBeenCalledWith(200)
expect(res.json).toHaveBeenCalledWith({
updatedWeeks: 1,
previousLastUpdated: '2021-01-01T00:00:00.000Z',
newLastUpdated: '2021-01-01T00:00:00.000Z',
tmdbMoviesSynced: [],
})
})

it('stores data from tmdb in firestore', async () => {
await newCacheController().store(req, res)

expect(transaction.set).toHaveBeenCalledTimes(1)
expect(transaction.set).toHaveBeenCalledWith(
FirebaseMock.mockDoc('weeks', '2021-01-01'),
new Week({
id: 'id1',
theme: 'theme1',
date: DateTime.fromISO('2021-01-01', TZ),
movies: [expected],
}).toFirebaseDTO(),
)
})

it('does not update the movie in notion', async () => {
await newCacheController().store(req, res)

expect(notionMock.update).not.toHaveBeenCalled()
})
})

describe('movies without directors', () => {
let expected: Movie

Expand Down
49 changes: 28 additions & 21 deletions server/__tests__/controllers/weekController.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('index', () => {
movies: [],
theme: 'theme1',
styledTheme: [],
submittedBy: null,
}, {
id: 'id2',
weekId: '2021-01-08',
Expand All @@ -83,6 +84,7 @@ describe('index', () => {
movies: [],
theme: 'theme2',
styledTheme: [],
submittedBy: null,
}, {
id: 'id3',
weekId: '2021-01-15',
Expand All @@ -92,6 +94,7 @@ describe('index', () => {
movies: [],
theme: 'theme3',
styledTheme: [],
submittedBy: null,
},
])
})
Expand Down Expand Up @@ -132,6 +135,7 @@ describe('index', () => {
isSkipped: true,
theme: 'theme3',
slug: 'slug3',
submittedBy: 'Jordan',
},
])
req = getMockReq()
Expand All @@ -151,6 +155,7 @@ describe('index', () => {
theme: 'theme1',
styledTheme: [],
slug: 'slug1',
submittedBy: null,
}, {
id: 'id2',
weekId: '2021-01-08',
Expand All @@ -160,6 +165,7 @@ describe('index', () => {
theme: 'theme2',
styledTheme: [],
slug: null,
submittedBy: null,
}, {
id: 'id3',
weekId: '2021-01-15',
Expand All @@ -169,6 +175,7 @@ describe('index', () => {
theme: 'theme3',
styledTheme: [],
slug: 'slug3',
submittedBy: 'Jordan',
},
])
})
Expand All @@ -180,15 +187,14 @@ describe('index', () => {

beforeEach(() => {
firestore = new FirestoreAdapter(mockConfig())
FirebaseMock.mockWeeks([
{
date: DateTime.fromISO('2021-01-01', TZ),
id: 'id1',
isSkipped: false,
slug: null,
theme: 'theme1',
},
])
FirebaseMock.mockWeeks([{
date: DateTime.fromISO('2021-01-01', TZ),
id: 'id1',
isSkipped: false,
slug: null,
theme: 'theme1',
submittedBy: 'Jordan',
}])
req = getMockReq()
})

Expand All @@ -197,18 +203,17 @@ describe('index', () => {

await new WeekController(firestore).index(req, res)

expect(res.json).toHaveBeenCalledWith([
{
id: 'id1',
weekId: '2021-01-01',
date: 'Friday, January 1',
isSkipped: false,
slug: null,
movies: [],
theme: 'theme1',
styledTheme: [],
},
])
expect(res.json).toHaveBeenCalledWith([{
id: 'id1',
weekId: '2021-01-01',
date: 'Friday, January 1',
isSkipped: false,
slug: null,
movies: [],
theme: 'theme1',
styledTheme: [],
submittedBy: 'Jordan',
}])
})

it('should query firebase with limit', async () => {
Expand Down Expand Up @@ -239,6 +244,7 @@ describe('index', () => {
id: 'id1',
isSkipped: false,
theme: 'theme1',
submittedBy: 'Jordan',
movies: [
movie.asFirebaseMovie(),
],
Expand All @@ -263,6 +269,7 @@ describe('index', () => {
],
theme: 'theme1',
styledTheme: [],
submittedBy: 'Jordan',
}])
})
})
Expand Down
Loading

0 comments on commit 519cf14

Please sign in to comment.