Public Access
feat(questions): list and restore removed games
Add a "Removed games" section on the questions page and an Undo toast after removing a manual game (#39).
This commit is contained in:
1 parent
c126592887
commit
84b16a2ca8
14 files changed
+280
-9
No files matched your search
@@ -5,6 +5,7 @@ import {toast} from 'sonner';
|
||||
|
||||
import PageContainer from '../components/PageContainer.jsx';
|
||||
import QuestionCard from '../components/QuestionCard.jsx';
|
||||
import RemovedGamesSection from '../components/RemovedGamesSection.jsx';
|
||||
import usePointsCheck from '../hooks/usePointsCheck.js';
|
||||
import {answerQuestion, fetchQuestions} from '../utils/questions.js';
|
||||
import {loadExpected} from '../utils/rewards.js';
|
||||
@@ -84,6 +85,7 @@ export default function QuestionsPage() {
|
||||
<QuestionCard key={item.appid} item={item} busy={busyAppid !== null} expectedPoints={expected[item.appid]}
|
||||
onAnswer={(choice) => answer(item, choice)}/>
|
||||
))}
|
||||
<RemovedGamesSection/>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -17,6 +17,7 @@ const booked = (appid) => ({balance: 30, missing: {}, paid: [{kind: 'FINISHED',
|
||||
const WALLET = {
|
||||
'GET /api/rewards/wallet': json(200, {balance: 30, catalog: [], owned: [], equipped: {}, history: []}),
|
||||
'GET /api/rewards/expected': json(200, {}),
|
||||
'GET /api/library/removed-games': json(200, {results: []}),
|
||||
};
|
||||
const expectedCalls = () => globalThis.fetch.mock.calls.filter(([url]) => url.includes('/api/rewards/expected'));
|
||||
const pointsCalls = () => globalThis.fetch.mock.calls.filter(([url]) => url.includes('/api/rewards/games/'));
|
||||
@@ -40,6 +41,16 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe('QuestionsPage', () => {
|
||||
it('showsTheRemovedGamesSectionAlsoWithoutQuestions', async () => {
|
||||
renderPage({
|
||||
'GET /api/library/questions': json(200, {results: []}),
|
||||
'GET /api/library/removed-games': json(200, {results: [{appid: -1, name: 'Zelda', imageUrl: null, source: 'MANUAL', platform: 'Switch'}]}),
|
||||
});
|
||||
|
||||
expect(await screen.findByText('QUESTIONS.EMPTY')).toBeTruthy();
|
||||
expect(await screen.findByText('REMOVED_GAMES.TITLE_COUNT:1')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('showsOneCardPerGameWithTheCountInTheTitle', async () => {
|
||||
renderPage({'GET /api/library/questions': json(200, {results: [card(1, 'START'), card(2, 'FINISHED')]})});
|
||||
|
||||
|
||||
Reference in new issue
Block a user