tableのなかのformをPOSTするテストを書きたい
現在、Spring Boot 1.4.2でとあるWebアプリケーションを作成しているところで、業務アプリなどでよく見る(?)「入力可能なテキストボックスやチェックボックスがtableの中にあるform」というUIの作成にとりかかっているところです。
###発生している問題・エラーメッセージ
Viewは定番(?)のThymeleafを使い、Listの要素を th:each
で繰り返し表示しています。
HTML
1<table class="table table-hover table-bordered table-striped"> 2 <thead> 3 <th class="col-lg-1 text-center">所属</th> 4 <th class="col-lg-5 text-center">ユーザー名</th> 5 </thead> 6 <tbody> 7 <tr th:each="refUserItem : *{refUserItemList}"> 8 <td class="text-center"> 9 <input type="checkbox" id="userJoined" th:value="${refUserItem.userJoined}" /> 10 </td> 11 <td> 12 <input type="hidden" id="userId" th:value="${refUserItem.userId}" /> 13 <span th:text="${refUserItem.displayName}">User Hoge</span> 14 </td> 15 </tr> 16 </tbody> 17</table>
これをPOSTするテストを書きたいのですが、上記HTMLに相当するPOSTパラメータはどう書くべきなのかがわかりません。
th:each
の外にある、いわゆる「普通のform」なら、下記のような実装でテストができることは確認済みなのですが。
Java
1ResultActions actions = mMvcMock.perform(post(template) 2 .with(csrf()) 3 .param("updateItemBtn", "更新") 4 .param("ledgerId", String.valueOf(existingLedgerId)) 5 .param("ledgerName", "非公開台帳1−1") 6 .param("publicLedger", "true") 7 .param("openStatus", "1") 8 ).andDo(print()); 9
試したこと
tableにはめている(はずの)inputタグの中身をJSON化してみたり、行ごとにparamを作ってみたりしましたが、状況は変わりませんでした。
###補足情報(言語/FW/ツール等のバージョンなど)
- Spring Boot 1.4.2
- Spring Security
- Spring Test
あなたの回答
tips
プレビュー