Skip to content

Commit 9932753

Browse files
authored
Merge pull request #2788 from codecrafters-io/grey-out-released
Greyed out released stuff and try adding a test(?)
2 parents 2a2c13c + 77db068 commit 9932753

9 files changed

+46
-6
lines changed

app/components/vote-page/course-extension-idea-card.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div
22
class="relative group bg-white dark:bg-gray-850 p-5 rounded-md shadow-sm flex flex-col justify-between border
3-
{{if this.userHasVoted 'border-gray-300 dark:border-gray-700' 'border-gray-200 dark:border-white/5'}}"
3+
{{if this.userHasVoted 'border-gray-300 dark:border-gray-700' 'border-gray-200 dark:border-white/5'}}
4+
{{if @courseExtensionIdea.developmentStatusIsReleased 'opacity-50'}}"
45
data-test-course-extension-idea-card
56
>
67
{{! Text }}

app/components/vote-page/course-idea-card.gts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ export default class CourseIdeaCardComponent extends Component<Signature> {
7474

7575
<template>
7676
<div
77-
class='group bg-white p-5 rounded-md shadow-sm flex flex-col justify-between border {{if this.userHasVoted "border-gray-300"}} relative'
77+
class='group bg-white p-5 rounded-md shadow-sm flex flex-col justify-between border
78+
{{if this.userHasVoted "border-gray-300"}}
79+
relative
80+
{{if @courseIdea.developmentStatusIsReleased "opacity-50"}}'
7881
data-test-course-idea-card
7982
>
8083
{{! Text }}

mirage/data/course-extension-ideas.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,31 @@ export default [
33
slug: 'redis-persistence',
44
course_slug: 'redis',
55
name: 'Persistence',
6+
development_status: 'released',
67
description_md:
78
"[Regular expressions](https://en.wikipedia.org/wiki/Regular_expression) are patterns used to match character combinations in strings. In this challenge you'll build your own version of `grep`, a CLI tool for searching using Regexes. \n\nAlong the way you'll learn about basic Regex syntax, [character classes](https://www.regular-expressions.info/refcharclass.html), [quantifiers](https://www.regular-expressions.info/refrepeat.html), [metacharacters](https://www.regular-expressions.info/characters.html) and more.",
89
},
910
{
1011
slug: 'redis-geospatial-commands',
1112
course_slug: 'redis',
1213
name: 'Geospatial commands',
14+
development_status: 'not-started',
1315
description_md:
1416
"[HTTP](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol) is the protocol that powers the web. In this challenge, you'll build a HTTP/1.1 server that is capable of serving multiple clients. \n\nAlong the way you'll learn about TCP servers, [HTTP request syntax](https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html), HTTP/1.1's [request pipelining](https://en.wikipedia.org/wiki/HTTP_pipelining) and more.",
1517
},
1618
{
1719
slug: 'sqlite-insert',
1820
course_slug: 'sqlite',
1921
name: 'Insert rows',
22+
development_status: 'not-started',
2023
description_md:
2124
"[Shells](https://en.wikipedia.org/wiki/Unix_shell) are a command-line interface to your operating system. In this challenge, you'll build your own version of `bash` that is capable of executing basic shell commands. \n\nAlong the way, you'll learn about [pipes](https://en.wikipedia.org/wiki/Pipeline_(Unix)), [redirection](https://en.wikipedia.org/wiki/Redirection_(computing)), [fork+exec](https://en.wikipedia.org/wiki/Fork%E2%80%93exec) and more.",
2225
},
2326
{
2427
slug: 'extension-idea-1',
2528
course_slug: 'dummy',
2629
name: 'Extension idea 1',
30+
development_status: 'not-started',
2731
description_md: 'This is the first extension idea for the dummy course',
2832
},
2933
];

mirage/data/course-ideas.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,43 @@ export default [
22
{
33
slug: 'regex',
44
name: 'Build your own Regex Parser',
5+
development_status: 'released',
56
description_md:
67
"[Regular expressions](https://en.wikipedia.org/wiki/Regular_expression) are patterns used to match character combinations in strings. In this challenge you'll build your own version of `grep`, a CLI tool for searching using Regexes. \n\nAlong the way you'll learn about basic Regex syntax, [character classes](https://www.regular-expressions.info/refcharclass.html), [quantifiers](https://www.regular-expressions.info/refrepeat.html), [metacharacters](https://www.regular-expressions.info/characters.html) and more.",
78
},
89
{
910
slug: 'http',
1011
name: 'Build your own HTTP Server',
12+
development_status: 'in-progress',
1113
description_md:
1214
"[HTTP](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol) is the protocol that powers the web. In this challenge, you'll build a HTTP/1.1 server that is capable of serving multiple clients. \n\nAlong the way you'll learn about TCP servers, [HTTP request syntax](https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html), HTTP/1.1's [request pipelining](https://en.wikipedia.org/wiki/HTTP_pipelining) and more.",
1315
},
1416
{
1517
slug: 'shell',
1618
name: 'Build your own Shell',
19+
development_status: 'not-started',
1720
description_md:
1821
"[Shells](https://en.wikipedia.org/wiki/Unix_shell) are a command-line interface to your operating system. In this challenge, you'll build your own version of `bash` that is capable of executing basic shell commands. \n\nAlong the way, you'll learn about [pipes](https://en.wikipedia.org/wiki/Pipeline_(Unix)), [redirection](https://en.wikipedia.org/wiki/Redirection_(computing)), [fork+exec](https://en.wikipedia.org/wiki/Fork%E2%80%93exec) and more.",
1922
},
2023
{
2124
slug: 'sqlite',
2225
name: 'Build your own SQLite',
2326
is_archived: true,
27+
development_status: 'released',
2428
description_md:
2529
"[SQLite](https://www.sqlite.org/index.html) is the most used database engine in the world. In this challenge, you'll build your own version of SQLite that is capable of reading a SQLite database file and answering basic SQL queries like `SELECT` and `INSERT`. \n\nAlong the way, you'll learn about the [SQLite file format](https://www.sqlite.org/appfileformat.html), [SQL syntax](https://www.sqlite.org/lang.html) and more.",
2630
},
2731
{
2832
slug: 'bittorrent',
2933
name: 'Build your own BitTorrent client',
34+
development_status: 'not-started',
3035
description_md:
3136
"[BitTorrent](https://en.wikipedia.org/wiki/BitTorrent) is a communication protocol for P2P file sharing. In this challenge, you'll build a BitTorrent client that is capable of downloading a publicly available file using the BitTorrent protocol. \n\nAlong the way you'll learn about the [BitTorrent protocol](https://www.bittorrent.org/beps/bep_0003.html), [trackers](https://www.bittorrent.org/beps/bep_0003.html#trackers), seeds & peers, file segments and more.",
3237
},
3338
{
3439
slug: 'react',
3540
name: 'Build your own React',
41+
development_status: 'not-started',
3642
description_md:
3743
"[React](https://reactjs.org/) is a Javascript framework for building user interfaces. In this challenge, you'll build a React implementation that supports [function components](https://reactjs.org/docs/components-and-props.html#function-and-class-components) and [hooks](https://reactjs.org/docs/hooks-intro.html). \n\nAlong the way, you'll learn about React's [API](https://reactjs.org/docs/react-api.html), [DOM-diffing algorithm](https://reactjs.org/docs/reconciliation.html#the-diffing-algorithm), [hooks](https://reactjs.org/docs/hooks-intro.html) and more!",
3844
},

mirage/utils/create-course-extension-ideas.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import courseExtensionIdeasData from '../data/course-extension-ideas';
33
export default function createCourseExtensionIdeas(server) {
44
for (const courseExtensionIdeaData of courseExtensionIdeasData) {
55
server.create('course-extension-idea', {
6-
createdAt: new Date(),
76
course: server.schema.courses.findBy({ slug: courseExtensionIdeaData.course_slug }),
7+
createdAt: new Date(),
8+
descriptionMarkdown: courseExtensionIdeaData.description_md,
9+
developmentStatus: courseExtensionIdeaData.development_status,
10+
developmentStatusLabelText: courseExtensionIdeaData.development_status,
811
name: courseExtensionIdeaData.name,
912
slug: courseExtensionIdeaData.slug,
10-
descriptionMarkdown: courseExtensionIdeaData.description_md,
1113
votesCount: 0,
1214
});
1315
}

mirage/utils/create-course-ideas.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ export default function createCourseIdeas(server) {
44
for (const courseIdeaData of courseIdeasData) {
55
server.create('course-idea', {
66
createdAt: new Date(),
7-
name: courseIdeaData.name,
87
descriptionMarkdown: courseIdeaData.description_md,
8+
developmentStatus: courseIdeaData.development_status,
9+
developmentStatusLabelText: courseIdeaData.development_status,
10+
name: courseIdeaData.name,
911
votesCount: 0,
1012
});
1113
}

tests/acceptance/vote-page/course-extension-ideas-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ module('Acceptance | vote-page | course-extension-ideas', function (hooks) {
2626
assert.strictEqual(votePage.courseExtensionIdeaCards.length, 2);
2727
assert.strictEqual(votePage.findCourseExtensionIdeaCard(courseExtensionIdea.name).voteButtonText, '1 vote');
2828

29+
const releasedIdeaCard = votePage.findCourseExtensionIdeaCard('Persistence');
30+
const notStartedIdeaCard = votePage.findCourseExtensionIdeaCard('Geospatial commands');
31+
32+
assert.strictEqual(releasedIdeaCard.developmentStatusLabelText, 'released', 'released idea has label');
33+
assert.true(releasedIdeaCard.isGreyedOut, 'released idea is greyed out');
34+
35+
assert.notEqual(notStartedIdeaCard.developmentStatusLabelText, 'released', 'not started idea has no label');
36+
assert.false(notStartedIdeaCard.isGreyedOut, 'not started idea is not greyed out');
37+
2938
// TODO: Test that hovering on vote shows tooltip
3039
// TODO: Test that clicking on vote will redirect to login
3140
});

tests/acceptance/vote-page/course-ideas-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ module('Acceptance | vote-page | course-ideas', function (hooks) {
2323

2424
assert.strictEqual(votePage.findCourseIdeaCard(courseIdea.name).voteButtonText, '1 vote');
2525

26+
const releasedIdeaCard = votePage.findCourseIdeaCard('Build your own Regex Parser');
27+
const notStartedIdeaCard = votePage.findCourseIdeaCard('Build your own Shell');
28+
29+
assert.strictEqual(releasedIdeaCard.developmentStatusLabelText, 'released', 'released idea has label');
30+
assert.true(releasedIdeaCard.isGreyedOut, 'released idea is greyed out');
31+
32+
assert.notEqual(notStartedIdeaCard.developmentStatusLabelText, 'released', 'not started idea has no label');
33+
assert.false(notStartedIdeaCard.isGreyedOut, 'not started idea is not greyed out');
34+
2635
// TODO: Test that hovering on vote shows tooltip
2736
// TODO: Test that clicking on vote will redirect to login
2837
// TODO: Can navigate directly to course extension ideas

tests/pages/vote-page.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
import { clickable, collection, text, triggerable, visitable } from 'ember-cli-page-object';
1+
import { clickable, collection, text, triggerable, visitable, hasClass } from 'ember-cli-page-object';
22
import createPage from 'codecrafters-frontend/tests/support/create-page';
33

44
export default createPage({
55
courseExtensionIdeaCards: collection('[data-test-course-extension-idea-card]', {
66
clickOnVoteButton: clickable('[data-test-vote-button]'),
7+
developmentStatusLabelText: text('[data-test-development-status-label]'),
78
hoverOnDevelopmentStatusLabel: triggerable('mouseenter', '[data-test-development-status-label]'),
9+
isGreyedOut: hasClass('opacity-50'),
810
name: text('[data-test-course-extension-idea-name]'),
911
voteButtonText: text('[data-test-vote-button]'),
1012
}),
1113

1214
courseIdeaCards: collection('[data-test-course-idea-card]', {
1315
clickOnVoteButton: clickable('[data-test-vote-button]'),
16+
developmentStatusLabelText: text('[data-test-development-status-label]'),
1417
hoverOnDevelopmentStatusLabel: triggerable('mouseenter', '[data-test-development-status-label]'),
18+
isGreyedOut: hasClass('opacity-50'),
1519
name: text('[data-test-course-idea-name]'),
1620
voteButtonText: text('[data-test-vote-button]'),
1721
}),

0 commit comments

Comments
 (0)