Public Access
feat(import): add the import page, multi-select add and the favorite platform
This commit is contained in:
1 parent
aa9e83e0cb
commit
14dd59f9e0
21 files changed
+1436
-48
No files matched your search
@@ -168,3 +168,33 @@ describe('SettingsPage appearance', () => {
|
||||
expect(appearancePuts()[1].showBanner).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('SettingsPage favorite platform', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.setItem('tbp_session', '1');
|
||||
// Radix Select needs these in jsdom.
|
||||
Element.prototype.hasPointerCapture ??= () => false;
|
||||
Element.prototype.scrollIntoView ??= () => {};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
it('shows the saved favorite and saves a new one, or none', async () => {
|
||||
renderPage(profile({settings: {useDarkTheme: true, language: 'de', publicProfile: true, favoritePlatform: 'PS5'}}));
|
||||
|
||||
const trigger = await screen.findByRole('combobox', {name: 'SETTINGS.FAVORITE_PLATFORM'});
|
||||
expect(trigger.textContent).toContain('PlayStation 5');
|
||||
|
||||
fireEvent.pointerDown(trigger, {button: 0, ctrlKey: false, pointerType: 'mouse'});
|
||||
fireEvent.click(await screen.findByRole('option', {name: 'Nintendo Switch 2'}));
|
||||
await waitFor(() => expect(puts()).toEqual([{platform: 'Switch 2'}]));
|
||||
expect(fetch.mock.calls.find(([, init]) => init?.method === 'PUT')[0]).toContain('/api/users/settings/favorite-platform');
|
||||
|
||||
fireEvent.pointerDown(trigger, {button: 0, ctrlKey: false, pointerType: 'mouse'});
|
||||
fireEvent.click(await screen.findByRole('option', {name: 'SETTINGS.FAVORITE_PLATFORM_NONE'}));
|
||||
await waitFor(() => expect(puts()).toEqual([{platform: 'Switch 2'}, {platform: null}]));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user