Skip to content

Commit

Permalink
Merge branch 'dev' into fix/#830
Browse files Browse the repository at this point in the history
  • Loading branch information
inyeong-kang authored Nov 1, 2023
2 parents f746fb2 + 1d3a5e1 commit 09082c5
Show file tree
Hide file tree
Showing 46 changed files with 1,961 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

public record PostAlarmEvent(
Member member,
String commentWriterNickname,
Long targetId,
AlarmType alarmType,
String detail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public record PostAlarmDetailResponse(
String commentWriter
) {

public static PostAlarmDetailResponse of(final Alarm alarm, final String nickname) {
public static PostAlarmDetailResponse of(final Alarm alarm) {
return new PostAlarmDetailResponse(
alarm.getTargetId(),
alarm.getDetail(),
nickname
alarm.getCommentWriterNickname()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public record PostAlarmResponse(
boolean isChecked
) {

public static PostAlarmResponse of(final Alarm alarm, final String nickname) {
public static PostAlarmResponse of(final Alarm alarm) {
return new PostAlarmResponse(
alarm.getId(),
PostAlarmDetailResponse.of(alarm, nickname),
PostAlarmDetailResponse.of(alarm),
alarm.getCreatedAt(),
alarm.isChecked()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class Alarm extends BaseEntity {
@Column(length = 20, nullable = false)
private AlarmType alarmType;

@Column(length = 20, nullable = false)
private String commentWriterNickname;

@Column(nullable = false)
private Long targetId;

Expand All @@ -54,12 +57,14 @@ public class Alarm extends BaseEntity {
private Alarm(
final Member member,
final AlarmType alarmType,
final String commentWriterNickname,
final Long targetId,
final String detail,
final boolean isChecked
) {
this.member = member;
this.alarmType = alarmType;
this.commentWriterNickname = commentWriterNickname;
this.targetId = targetId;
this.detail = detail;
this.isChecked = isChecked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void handlePostAlarmEvent(final PostAlarmEvent postAlarmEvent) {
final Alarm alarm = Alarm.builder()
.member(postAlarmEvent.member())
.alarmType(postAlarmEvent.alarmType())
.commentWriterNickname(postAlarmEvent.commentWriterNickname())
.targetId(postAlarmEvent.targetId())
.detail(postAlarmEvent.detail())
.isChecked(false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.votogether.domain.alarm.service;

import com.votogether.domain.alarm.dto.response.PostAlarmResponse;
import com.votogether.domain.alarm.dto.response.ReportActionAlarmResponse;
import com.votogether.domain.alarm.dto.response.ReportActionResponse;
import com.votogether.domain.alarm.dto.response.PostAlarmResponse;
import com.votogether.domain.alarm.entity.Alarm;
import com.votogether.domain.alarm.entity.ReportActionAlarm;
import com.votogether.domain.alarm.entity.vo.AlarmType;
import com.votogether.domain.alarm.exception.AlarmExceptionType;
import com.votogether.domain.alarm.repository.AlarmRepository;
import com.votogether.domain.alarm.repository.ReportActionAlarmRepository;
Expand All @@ -24,7 +23,6 @@
public class AlarmQueryService {

private static final int BASIC_PAGE_SIZE = 10;
private static final String NICKNAME_WHEN_POST_CLOSING = "";

private final AlarmRepository alarmRepository;
private final ReportActionAlarmRepository reportActionAlarmRepository;
Expand All @@ -33,26 +31,11 @@ public List<PostAlarmResponse> getPostAlarm(final Member member, final int page)
final PageRequest pageRequest = PageRequest.of(page, BASIC_PAGE_SIZE);
final Slice<Alarm> alarms = alarmRepository.findAllByMemberOrderByCreatedAtDesc(member, pageRequest);

return getPostAlarmResponses(alarms);
}

private List<PostAlarmResponse> getPostAlarmResponses(final Slice<Alarm> alarms) {
return alarms.stream()
.map(alarm -> {
final String nickname = makeNicknameBy(alarm);
return PostAlarmResponse.of(alarm, nickname);
})
.map(PostAlarmResponse::of)
.toList();
}

private String makeNicknameBy(final Alarm alarm) {
if (alarm.getAlarmType() == AlarmType.POST_DEADLINE) {
return NICKNAME_WHEN_POST_CLOSING;
}
final Member member = alarm.getMember();
return member.getNickname();
}

public List<ReportActionAlarmResponse> getReportActionAlarms(final Member member, final int page) {
final PageRequest pageRequest = PageRequest.of(page, BASIC_PAGE_SIZE);
final List<ReportActionAlarm> reportActionAlarms = reportActionAlarmRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.votogether.domain.notice.dto.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -24,7 +25,7 @@ public record NoticeRequest(

@Schema(description = "배너 노출 마감기한", example = "2023-12-25 23:59")
@NotNull(message = "배너 노출 마감기한을 입력하지 않았습니다.")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "Asia/Seoul")
LocalDateTime deadline
) {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.votogether.domain.notice.dto.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.votogether.domain.notice.entity.Notice;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
Expand All @@ -22,9 +23,11 @@ public record NoticeResponse(
String content,

@Schema(description = "공지사항 배너 마감기한", example = "2023-12-25 23:59")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
LocalDateTime deadline,

@Schema(description = "공지사항 생성시각", example = "2023-12-25 23:59")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
LocalDateTime createdAt
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
@Service
public class PostCommandService {

private static final String NICKNAME_WHEN_POST_CLOSING = "";

private final ImageUploader imageUploader;
private final PostRepository postRepository;
private final CategoryRepository categoryRepository;
Expand Down Expand Up @@ -313,6 +315,7 @@ public void closePostEarly(final Long postId, final Member loginMember) {
private void publishAlarmEvent(final Long postId, final Member loginMember, final Post post) {
final PostAlarmEvent postAlarmEvent = new PostAlarmEvent(
loginMember,
NICKNAME_WHEN_POST_CLOSING,
postId,
AlarmType.POST_DEADLINE,
post.getTitle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private void publishAlarmEvent(final Member loginMember, final Post post) {
}
final PostAlarmEvent postAlarmEvent = new PostAlarmEvent(
post.getWriter(),
loginMember.getNickname(),
post.getId(),
AlarmType.COMMENT,
post.getTitle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ public class WebMvcConfig implements WebMvcConfigurer {

private static final String LOCALHOST_FRONTEND = "http://localhost:3000";
private static final String HTTPS_LOCALHOST_FRONTEND = "https://localhost:3000";
private static final String HTTPS_JERO = "https://jero-votogether-next.vercel.app/";
private static final String HTTPS_WUS = "https://wus-votogether-next-app.vercel.app/";
private static final String HTTPS_CHSUA = "https://chsua-votogether-next-app.vercel.app/";

private static final String DEV_SERVER = "https://dev.votogether.com";
private static final String PROD_SERVER = "https://votogether.com";

Expand All @@ -45,9 +41,6 @@ public FilterRegistrationBean<CorsFilter> corsFilterRegistrationBean() {
config.addAllowedOrigin(HTTPS_LOCALHOST_FRONTEND);
config.addAllowedOrigin(DEV_SERVER);
config.addAllowedOrigin(PROD_SERVER);
config.addAllowedOrigin(HTTPS_JERO);
config.addAllowedOrigin(HTTPS_WUS);
config.addAllowedOrigin(HTTPS_CHSUA);
config.addAllowedHeader("*");
config.addAllowedMethod("*");
config.addExposedHeader(HttpHeaders.LOCATION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
private static final Map<String, String> MATCH_URI_METHOD = new HashMap<>(
Map.ofEntries(
Map.entry("^/posts/.+/comments$", "GET"),
Map.entry("^/notices/.*$", "GET")
Map.entry("^/notices.*$", "GET")
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void readAlarm() {
Alarm alarm = Alarm.builder()
.member(member)
.alarmType(AlarmType.COMMENT)
.commentWriterNickname("nickname")
.targetId(1L)
.detail("detail")
.isChecked(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AlarmEventListenerTest extends ServiceTest {
void handlePostAlarmEvent() throws Exception {
// given
Member member = memberTestPersister.builder().save();
PostAlarmEvent postAlarmEvent = new PostAlarmEvent(member, 1L, AlarmType.COMMENT, "title");
PostAlarmEvent postAlarmEvent = new PostAlarmEvent(member, "nickname", 1L, AlarmType.COMMENT, "title");

// when
alarmEventListener.handlePostAlarmEvent(postAlarmEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.votogether.test.ControllerTest;
import io.restassured.module.mockmvc.RestAssuredMockMvc;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand Down Expand Up @@ -52,8 +53,8 @@ void getProgressNotice() throws Exception {
"bannerTitle",
"bannerSubtitle",
"content",
LocalDateTime.now().plusDays(1),
LocalDateTime.now()
LocalDateTime.now().plusDays(1).truncatedTo(ChronoUnit.MINUTES),
LocalDateTime.now().truncatedTo(ChronoUnit.MINUTES)
);
given(noticeQueryService.getProgressNotice()).willReturn(expected);

Expand Down Expand Up @@ -86,8 +87,8 @@ void getNotices() throws Exception {
"bannerTitle",
"bannerSubtitle",
"content",
LocalDateTime.now().plusDays(1),
LocalDateTime.now()
LocalDateTime.now().plusDays(1).truncatedTo(ChronoUnit.MINUTES),
LocalDateTime.now().truncatedTo(ChronoUnit.MINUTES)
);
NoticePageResponse expected = new NoticePageResponse(1, 0, List.of(noticeResponse));
given(noticeQueryService.getNotices(anyInt())).willReturn(expected);
Expand Down Expand Up @@ -153,8 +154,8 @@ void getNotice() throws Exception {
"bannerTitle",
"bannerSubtitle",
"content",
LocalDateTime.now().plusDays(1),
LocalDateTime.now()
LocalDateTime.now().plusDays(1).truncatedTo(ChronoUnit.MINUTES),
LocalDateTime.now().truncatedTo(ChronoUnit.MINUTES)
);
given(noticeQueryService.getNotice(anyLong())).willReturn(expected);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public final class AlarmBuilder {

private Member member;
private AlarmType alarmType;
private String commentWriterNickname;
private Long targetId;
private String detail;
private boolean isChecked;
Expand All @@ -35,6 +36,11 @@ public AlarmBuilder alarmType(AlarmType alarmType) {
return this;
}

public AlarmBuilder commentWriterNickname(String commentWriterNickname) {
this.commentWriterNickname = commentWriterNickname;
return this;
}

public AlarmBuilder targetId(Long targetId) {
this.targetId = targetId;
return this;
Expand All @@ -54,6 +60,7 @@ public Alarm save() {
Alarm alarm = Alarm.builder()
.member(member == null ? memberTestPersister.builder().save() : member)
.alarmType(alarmType == null ? AlarmType.COMMENT : alarmType)
.commentWriterNickname(commentWriterNickname == null ? "nickname" : commentWriterNickname)
.targetId(targetId == null ? 1L : targetId)
.detail(detail == null ? "detail" : detail)
.isChecked(false)
Expand Down
3 changes: 2 additions & 1 deletion frontend/__test__/convertTextToUrl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ test.each([
'반갑다 https://github.com/woowacourse-teams/2023-votogether/issues/703 임',
'반갑다 [[https://github.com/woowacourse-teams/2023-votogether/issues/703]] 임',
],
['안녕 wwwww.naver.com', '안녕 wwwww.naver.com'],
['안녕 wwwww.naver.com', '안녕 ww[[www.naver.com]]'],
['하하 [www.naver.com]', '하하 [[[www.naver.com]]]'],
['http://localhost:3000/ 피카츄', '[[http://localhost:3000/]] 피카츄'],
[
'http://localhost:3000/http://localhost:3000/ 피카츄',
Expand Down
11 changes: 11 additions & 0 deletions frontend/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'cypress';

export default defineConfig({
experimentalStudio: true,

e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
13 changes: 13 additions & 0 deletions frontend/cypress.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { mount } from 'cypress/react';

// Augment the Cypress namespace to include type definitions for
// your custom command.
// Alternatively, can be defined in cypress/support/component.d.ts
// with a <reference path="./component" /> at the top of your spec.
declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount;
}
}
}
3 changes: 3 additions & 0 deletions frontend/cypress/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["plugin:cypress/recommended"]
}
64 changes: 64 additions & 0 deletions frontend/cypress/e2e/guestFeatureTest.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const visitUrl = 'http://localhost:3000/';

describe('guestFeatureTest', () => {
it('visitSite', () => {
cy.visit(visitUrl);
});

/* ==== Test Created with Cypress Studio ==== */
it('게시글 목록을 필터링/정렬 조건을 수정한다', function () {
cy.visit('http://localhost:3000/');
cy.get(':nth-child(1) > .sc-gVpkOZ > .sc-fXmShK').click();
cy.get('.sc-gyMiQo > :nth-child(1)').click();
cy.get(':nth-child(2) > .sc-gVpkOZ > .sc-fXmShK').click();
cy.get('.sc-gyMiQo > :nth-child(1)').click();
//list 확인 필요
});

it('랭킹 페이지에 진입해 인기글 상세 페이지로 이동한다', function () {
cy.visit('http://localhost:3000/');
cy.get('.sc-fWKGHs > .gHxHbZ > img').click();
cy.get('.cbweqh').click();
cy.get(':nth-child(1) > :nth-child(3) > a').click();
});

it('공지사항 목록페이지로 진입해 상세 공지사항 페이지로 이동한다', function () {
/* ==== Generated with Cypress Studio ==== */
cy.visit('http://localhost:3000/');
cy.get('.sc-hmrlCG > .sc-iJSKBe > .sc-giQjdv > span').click();
//list 확인 필요
cy.get(':nth-child(1) > .sc-fGwJSW > .sc-hmftdN').click();
});

it('게스트에게 보이는 토스트를 확인한다', function () {
cy.visit('http://localhost:3000/');
cy.get('.sc-fWKGHs > .sc-gSIKdN > .sc-iNyIUv > img').click();
cy.get('.sc-bdDrbm').should('exist').should('contain', '로그인 후 이용');

cy.get(
'.sc-hmrlCG > .sc-iJSKBe > .sc-bYgGll > .sc-dILiZe > .sc-fKwBvW > .sc-dYlqv > .sc-hCcNSO > :nth-child(1) > .sc-fFCYnF > img'
).click();
cy.get('.sc-bdDrbm').should('exist').should('contain', '로그인 후 이용');
});

it('스크롤버튼을 눌러 상단으로 이동한다', function () {
cy.visit('http://localhost:3000/');
cy.scrollTo('bottom');
cy.scrollTo('bottom');
cy.scrollTo('bottom');
cy.get('.sc-eEFsNM').click();
cy.get('html, body').should($el => {
expect($el.scrollTop()).to.equal(0);
});
});

it('a 키워드를 검색한다', function () {
cy.visit('http://localhost:3000/');
cy.get('.sc-jePPIV').click();
cy.get('.sc-eIYifI').clear();
cy.get('.sc-eIYifI').type('a');
cy.get('.sc-otYyL > img').click();
//list
});
/* ==== Test Created with Cypress Studio ==== */
});
Loading

0 comments on commit 09082c5

Please sign in to comment.