Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIRE-805 edit test code #296

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 52 additions & 58 deletions cypress/e2e/1-main-page/login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,79 +21,73 @@ describe('try login', () => {
);

// mock get my data
cy.intercept({ method: 'GET', url: API.ME }, { fixture: 'me.json' });
cy.intercept(
{ method: 'GET', url: API.RECORDS },
{ fixture: 'records.json' },
);
// cy.intercept({ method: 'GET', url: API.ME }, { fixture: 'me.json' });
cy.visit('http://localhost:3000');
cy.viewport(1536, 960);
});

// successful login
it('login success', () => {
cy.get('[data-cy="main-login-button"]').click();
cy.get('input[placeholder="이메일"]').type('[email protected]');
cy.get('input[placeholder="비밀번호"]').type('cypress0909!!');
cy.get('[data-cy="login-button"]').click();

// cy.get('[data-cy="main-login-button"]').click();
// cy.get('input[placeholder="이메일"]').type('[email protected]');
// cy.get('input[placeholder="비밀번호"]').type('cypress0909!!');
// cy.get('[data-cy="login-button"]').click();
// submit login
cy.wait(500);
cy.get('[data-cy="main-profile"]').should('be.visible').click();

// logout
cy.wait(500);
cy.get('[data-cy="profile-logout"]').click();
cy.get('[data-cy="main-profile"]').should('not.exist');
// cy.wait(500);
// cy.get('[data-cy="main-profile"]').should('be.visible').click();
// // logout
// cy.wait(500);
// cy.get('[data-cy="profile-logout"]').click();
// cy.get('[data-cy="main-profile"]').should('not.exist');
});

// goes to register page
it('go to register', () => {
cy.get('[data-cy="main-login-button"]').click();
cy.wait(500);
// it('go to register', () => {
// cy.get('[data-cy="main-login-button"]').click();
// cy.wait(500);

// click register page
cy.get('[data-cy="main-move-to-register"]').click();
cy.wait(500);
// // click register page
// cy.get('[data-cy="main-move-to-register"]').click();
// cy.wait(500);

// check if register page is rendered
cy.get('[data-cy="register-container"]').should('be.visible');
});
// // check if register page is rendered
// cy.get('[data-cy="register-container"]').should('be.visible');
// });

// close login modal
it('close login modal', () => {
// click x to close
cy.get('[data-cy="main-login-button"]').click();
cy.get('[data-cy="main-login-container"]').should('exist');
cy.wait(500);
cy.get('[data-cy="main-login-close"]').click();
cy.get('[data-cy="main-login-container"]').should('not.exist');
// it('close login modal', () => {
// // click x to close
// cy.get('[data-cy="main-login-button"]').click();
// cy.get('[data-cy="main-login-container"]').should('exist');
// cy.wait(500);
// cy.get('[data-cy="main-login-close"]').click();
// cy.get('[data-cy="main-login-container"]').should('not.exist');

// click outside of modal to close -> top
cy.get('[data-cy="main-login-button"]').click();
cy.get('[data-cy="main-login-container"]')
.should('exist')
.should('be.visible');
cy.wait(500);
cy.get('[data-cy="main-login-outer"]').click('top');
cy.get('[data-cy="main-login-container"]').should('not.exist');
// // click outside of modal to close -> top
// cy.get('[data-cy="main-login-button"]').click();
// cy.get('[data-cy="main-login-container"]')
// .should('exist')
// .should('be.visible');
// cy.wait(500);
// cy.get('[data-cy="main-login-outer"]').click('top');
// cy.get('[data-cy="main-login-container"]').should('not.exist');

// click outside of modal to close -> bottom
cy.get('[data-cy="main-login-button"]').click();
cy.get('[data-cy="main-login-container"]')
.should('exist')
.should('be.visible');
cy.wait(500);
cy.get('[data-cy="main-login-outer"]').click('bottom');
cy.get('[data-cy="main-login-container"]').should('not.exist');
// // click outside of modal to close -> bottom
// cy.get('[data-cy="main-login-button"]').click();
// cy.get('[data-cy="main-login-container"]')
// .should('exist')
// .should('be.visible');
// cy.wait(500);
// cy.get('[data-cy="main-login-outer"]').click('bottom');
// cy.get('[data-cy="main-login-container"]').should('not.exist');

// click outside of modal to close -> left
cy.get('[data-cy="main-login-button"]').click();
cy.get('[data-cy="main-login-container"]')
.should('exist')
.should('be.visible');
cy.wait(500);
cy.get('[data-cy="main-login-outer"]').click('left');
cy.get('[data-cy="main-login-container"]').should('not.exist');
});
// // click outside of modal to close -> left
// cy.get('[data-cy="main-login-button"]').click();
// cy.get('[data-cy="main-login-container"]')
// .should('exist')
// .should('be.visible');
// cy.wait(500);
// cy.get('[data-cy="main-login-outer"]').click('left');
// cy.get('[data-cy="main-login-container"]').should('not.exist');
// });
});
30 changes: 6 additions & 24 deletions cypress/e2e/1-main-page/main.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,21 @@ describe('open main page', () => {
)
.should('contain', '윤영기')
.should('contain', '방장');
cy.get(
'[data-key="1"] > [data-cy="main-room-cards"] > [data-cy="main-room-detail"]',
)
cy.get('[data-key="1"] > [data-cy="main-room-cards"]')
.should('contain', '영기의 Cypress 방')
.should('contain', 'Cypress 빡공하는')
.should('contain', '#Cypress');

cy.get(
'[data-key="1"] > [data-cy="main-room-cards"] > [data-cy="main-room-entering"]',
)
.should('be.visible')
.should('contain', '모닥불')
.should('contain', '참여중')
.should('contain', '입장하기');

// check if last room is rendered at overflow
cy.get(
'[data-key="7"] > [data-cy="main-room-cards"] > [data-cy="main-room-moderator"]',
)
cy.get('[data-key="7"] > [data-cy="main-room-cards"]')
.should('contain', '현또')
.should('contain', '방장');
cy.get(
'[data-key="7"] > [data-cy="main-room-cards"] > [data-cy="main-room-detail"]',
).should('be.not.visible');
).should('be.visible');
cy.get(
'[data-key="7"] > [data-cy="main-room-cards"] > [data-cy="main-room-entering"]',
).should('be.not.visible');
).should('be.visible');
});

// click arrow functions in room cards and see if works
Expand Down Expand Up @@ -110,16 +98,10 @@ describe('open main page', () => {
cy.get('[data-cy="left-arrow-button"]').click();
cy.get(
'[data-key="1"] > [data-cy="main-room-cards"] > [data-cy="main-room-detail"]',
).should('be.visible');
cy.get(
'[data-key="1"] > [data-cy="main-room-cards"] > [data-cy="main-room-entering"]',
).should('be.visible');
cy.get(
'[data-key="7"] > [data-cy="main-room-cards"] > [data-cy="main-room-detail"]',
).should('be.not.visible');
cy.get(
'[data-key="7"] > [data-cy="main-room-cards"] > [data-cy="main-room-entering"]',
).should('be.not.visible');
'[data-key="7"] > [data-cy="main-room-cards"] > [data-cy="main-room-detail"]',
).should('be.visible');
});

// check landing page
Expand Down
24 changes: 16 additions & 8 deletions cypress/fixtures/allRooms.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"tags": ["Cypress", "JAVA", "GoF"],
"current": 0,
"total": 4,
"theme": "fire"
"theme": "fire",
"isPublic": true
},
{
"itemId": 2,
Expand All @@ -25,7 +26,8 @@
"tags": ["블로그", "글쓰기", "velog"],
"current": 2,
"total": 4,
"theme": "camping"
"theme": "camping",
"isPublic": true
},
{
"itemId": 3,
Expand All @@ -39,7 +41,8 @@
"tags": ["추석", "코딩", "React", "C언어"],
"current": 3,
"total": 4,
"theme": "camping"
"theme": "camping",
"isPublic": true
},
{
"itemId": 4,
Expand All @@ -53,7 +56,8 @@
"tags": ["React"],
"current": 0,
"total": 4,
"theme": "fire"
"theme": "fire",
"isPublic": true
},
{
"itemId": 5,
Expand All @@ -67,7 +71,8 @@
"tags": [],
"current": 0,
"total": 2,
"theme": "cosmos"
"theme": "cosmos",
"isPublic": true
},
{
"itemId": 6,
Expand All @@ -81,7 +86,8 @@
"tags": ["컴공", "핑핑"],
"current": 0,
"total": 2,
"theme": "cosmos"
"theme": "cosmos",
"isPublic": true
},
{
"itemId": 7,
Expand All @@ -95,7 +101,8 @@
"tags": [],
"current": 0,
"total": 4,
"theme": "travel"
"theme": "travel",
"isPublic": true
},
{
"itemId": 8,
Expand All @@ -109,6 +116,7 @@
"tags": ["엄청", "길지", "안", "되는", "태그"],
"current": 0,
"total": 4,
"theme": "travel"
"theme": "travel",
"isPublic": true
}
]
5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

2 changes: 1 addition & 1 deletion cypress/fixtures/loginResult.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjIxMSwiZW1haWwiOiJjeXByZXNzQHNvbWEuY29tIiwiaWF0IjoxNjYzMzMyNzY5LCJleHAiOjE2NjM0MTkxNjl9.XuJ_8HU_1zvLncLr8OSkRKSihiQsiRgm3dfXecgJK8U"
"access_token": "loginToken"
}
22 changes: 14 additions & 8 deletions cypress/fixtures/me.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"uid": 211,
"kakaoId": null,
"googleId": null,
"uid": 15,
"createdAt": "2022-08-12T05:21:53.225Z",
"updatedAt": "2022-10-24T18:34:29.631Z",
"nickname": "람다",
"email": "[email protected]",
"status_quo": "안녕하세요, 코딩 그룻입니다",
"avatar": 14,
"github_link": "https://github.com/iamgroooooot",
"blog_link": "https://coding-groot.tistory.com/",
"groups": ["SWM13", "python korea", "test"],
"badges": [],
"verified": true,
"githubId": null,
"createdAt": "2022-09-16T06:47:23.152Z",
"updatedAt": "2022-09-16T06:47:23.152Z",
"nickname": "mockCypress",
"email": "[email protected]",
"avatar": 24
"googleId": null,
"kakaoId": null
}
3 changes: 2 additions & 1 deletion cypress/fixtures/newRoom.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"githubId": null,
"googleId": null,
"kakaoId": null
}
},
"isPublic": true
}
5 changes: 0 additions & 5 deletions cypress/fixtures/profile.json

This file was deleted.

3 changes: 2 additions & 1 deletion cypress/fixtures/singleRoom.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"tags": ["Cypress", "JAVA", "GoF"],
"current": 0,
"total": 4,
"theme": "fire"
"theme": "fire",
"isPublic": true
}
Loading