add favorites/boost test
This commit is contained in:
		
							parent
							
								
									5c53199434
								
							
						
					
					
						commit
						ab366d6c2c
					
				
					 4 changed files with 49 additions and 5 deletions
				
			
		|  | @ -2,7 +2,7 @@ | |||
|   <div class="search-result-account"> | ||||
|     <Avatar :account size="small" className="search-result-account-avatar"/> | ||||
|     <div class="search-result-account-name"> | ||||
|       {{account.display_name}} | ||||
|       {{account.display_name || account.acct}} | ||||
|     </div> | ||||
|     <div class="search-result-account-username"> | ||||
|       {{'@' + account.acct}} | ||||
|  |  | |||
|  | @ -2,13 +2,13 @@ | |||
|   <ExternalLink class="status-absolute-date" href="{{status.url}}" showIcon="true"> | ||||
|     <time datetime={{createdAtDate}} title="{{formattedDate}}">{{formattedDate}}</time> | ||||
|   </ExternalLink> | ||||
|   <a class="status-favs-reblogs" href="/statuses/{{statusId}}/reblogs"> | ||||
|   <a class="status-favs-reblogs" href="/statuses/{{statusId}}/reblogs" aria-label="{{favoritesLabel}}"> | ||||
|     <svg> | ||||
|       <use xlink:href="#fa-retweet"/> | ||||
|     </svg> | ||||
|     <span>{{numReblogs}}</span> | ||||
|   </a> | ||||
|   <a class="status-favs-reblogs" href="/statuses/{{statusId}}/favorites"> | ||||
|   <a class="status-favs-reblogs" href="/statuses/{{statusId}}/favorites" aria-label="{{reblogsLabel}}"> | ||||
|     <svg> | ||||
|       <use xlink:href="#fa-star" /> | ||||
|     </svg> | ||||
|  | @ -95,7 +95,19 @@ | |||
|       createdAtDate: (status) => status.created_at, | ||||
|       numReblogs: (status) => status.reblogs_count || 0, | ||||
|       numFavs: (status) => status.favourites_count || 0, | ||||
|       formattedDate: (createdAtDate) => formatter.format(new Date(createdAtDate)) | ||||
|       formattedDate: (createdAtDate) => formatter.format(new Date(createdAtDate)), | ||||
|       reblogsLabel: (numReblogs) => { | ||||
|         // TODO: intl | ||||
|         return numReblogs === 1 | ||||
|           ? `Boosted ${numReblogs} time` | ||||
|           : `Boosted ${numReblogs} times` | ||||
|       }, | ||||
|       favoritesLabel: (numFavs) => { | ||||
|         // TODO: intl | ||||
|         return numFavs === 1 | ||||
|           ? `Favorited ${numFavs} time` | ||||
|           : `Favorited ${numFavs} times` | ||||
|       } | ||||
|     }, | ||||
|     components: { | ||||
|       ExternalLink | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import { | |||
| } from '../utils' | ||||
| import { foobarRole } from '../roles' | ||||
| 
 | ||||
| fixture`09-threads.js` | ||||
| fixture`10-focus.js` | ||||
|   .page`http://localhost:4002` | ||||
| 
 | ||||
| test('modal preserves focus', async t => { | ||||
|  |  | |||
							
								
								
									
										32
									
								
								tests/spec/11-reblog-favorites-count.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								tests/spec/11-reblog-favorites-count.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| import { Selector as $ } from 'testcafe' | ||||
| import { getNthStatus, getUrl } from '../utils' | ||||
| import { foobarRole } from '../roles' | ||||
| 
 | ||||
| fixture`11-reblog-favorites-count.js` | ||||
|   .page`http://localhost:4002` | ||||
| 
 | ||||
| test('shows favorites', async t => { | ||||
|   await t.useRole(foobarRole) | ||||
|     .click(getNthStatus(0)) | ||||
|     .expect(getUrl()).contains('/statuses/99549266679020981') | ||||
|     .expect($('.status-favs-reblogs').nth(0).getAttribute('aria-label')).eql('Favorited 2 times') | ||||
|     .expect($('.icon-button[aria-label="Favorite"]').getAttribute('aria-pressed')).eql('true') | ||||
|     .click($('.status-favs-reblogs').nth(1)) | ||||
|     .expect(getUrl()).contains('/statuses/99549266679020981/favorites') | ||||
|     .expect($('.search-result-account-name').nth(0).innerText).eql('foobar') | ||||
|     .expect($('.search-result-account-username').nth(0).innerText).eql('@foobar') | ||||
|     .expect($('.search-result-account-name').nth(1).innerText).eql('admin') | ||||
|     .expect($('.search-result-account-username').nth(1).innerText).eql('@admin') | ||||
| }) | ||||
| 
 | ||||
| test('shows boosts', async t => { | ||||
|   await t.useRole(foobarRole) | ||||
|     .click(getNthStatus(0)) | ||||
|     .expect(getUrl()).contains('/statuses/99549266679020981') | ||||
|     .expect($('.status-favs-reblogs').nth(1).getAttribute('aria-label')).eql('Boosted 1 time') | ||||
|     .expect($('.icon-button[aria-label="Boost"]').getAttribute('aria-pressed')).eql('false') | ||||
|     .click($('.status-favs-reblogs').nth(0)) | ||||
|     .expect(getUrl()).contains('/statuses/99549266679020981/reblogs') | ||||
|     .expect($('.search-result-account-name').nth(0).innerText).eql('admin') | ||||
|     .expect($('.search-result-account-username').nth(0).innerText).eql('@admin') | ||||
| }) | ||||
		Loading…
	
	Add table
		
		Reference in a new issue