Skip to content

Commit

Permalink
Merge pull request #10 from KyunginNa/ver4.0_master
Browse files Browse the repository at this point in the history
Refactoring code
  • Loading branch information
KyunginNa authored Dec 19, 2020
2 parents 1dd4f65 + d82b0f2 commit f052046
Show file tree
Hide file tree
Showing 30 changed files with 451 additions and 359 deletions.
Binary file added app_design_draft/App design_sprint1-2.pdf
Binary file not shown.
Binary file added app_design_draft/App design_sprint3.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app_design_draft/App design_sprint4.pdf
Binary file not shown.
18 changes: 9 additions & 9 deletions cypress/integration/userCanMakeComputerChoose.feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ describe("Random pick", () => {

describe("Player1 makes computer choose", () => {
it("makes player1's board invisible", () => {
cy.get("button#player1-random").click();
cy.get("#player1-board").should("not.be.visible");
cy.get("[data-cy='player1-random']").click();
cy.get("[data-cy='player1-board']").should("not.be.visible");
});
});

describe("Player2 makes computer choose", () => {
beforeEach(() => {
cy.get("button#player1-rock").click();
cy.get("button#player1-go").click();
cy.get("button#player2-random").click();
cy.get("[data-cy='player1-rock']").click();
cy.get("[data-cy='player1-go']").click();
cy.get("[data-cy='player2-random']").click();
});
it("displays player1's board again", () => {
cy.get("#player1-board").should("be.visible");
cy.get("[data-cy='player1-board']").should("be.visible");
});
it("displays a result message", () => {
cy.get("#result-message").should("not.be.empty");
cy.get("[data-cy='result-message']").should("not.be.empty");
});
it("displays Play Again button", () => {
cy.get("button#play-again").should("be.visible");
cy.get("[data-cy='play-again']").should("be.visible");
});
it("displays Start A New Game button", () => {
cy.get("button#restart").should("be.visible");
cy.get("[data-cy='restart']").should("be.visible");
});
});
});
70 changes: 35 additions & 35 deletions cypress/integration/userCanPlayRPS.feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,89 +8,89 @@ describe("Rock Paper Scissors game", () => {
cy.visit("/");
});
it("Player1 can choose rock", () => {
cy.get("button#player1-rock").click();
cy.get("button#player1-go").click();
cy.get("[data-cy='player1-rock']").click();
cy.get("[data-cy='player1-go']").click();
});

it("Player1 can choose paper", () => {
cy.get("button#player1-paper").click();
cy.get("button#player1-go").click();
cy.get("[data-cy='player1-paper']").click();
cy.get("[data-cy='player1-go']").click();
});

it("Player1 can choose scissors", () => {
cy.get("button#player1-scissors").click();
cy.get("button#player1-go").click();
cy.get("[data-cy='player1-scissors']").click();
cy.get("[data-cy='player1-go']").click();
});

it("Hides player1's board", () => {
cy.get("button#player1-rock").click();
cy.get("button#player1-go").click();
cy.get("#player1-board").should("not.be.visible");
cy.get("[data-cy='player1-rock']").click();
cy.get("[data-cy='player1-go']").click();
cy.get("[data-cy='player1-board']").should("not.be.visible");
});

it("Displays player2's board", () => {
cy.get("button#player1-rock").click();
cy.get("button#player1-go").click();
cy.get("#player2-board").should("be.visible");
cy.get("[data-cy='player1-rock']").click();
cy.get("[data-cy='player1-go']").click();
cy.get("[data-cy='player2-board']").should("be.visible");
});
});

describe("Player2's turn", () => {
beforeEach(() => {
cy.visit("/");
cy.get("button#player1-rock").click();
cy.get("button#player1-go").click();
cy.get("[data-cy='player1-rock']").click();
cy.get("[data-cy='player1-go']").click();
});
it("Player2 can choose rock", () => {
cy.get("button#player2-rock").click();
cy.get("button#player2-go").click();
cy.get("[data-cy='player2-rock']").click();
cy.get("[data-cy='player2-go']").click();
});

it("Player2 can choose paper", () => {
cy.get("button#player2-paper").click();
cy.get("button#player2-go").click();
cy.get("[data-cy='player2-paper']").click();
cy.get("[data-cy='player2-go']").click();
});

it("Player2 can choose scissors", () => {
cy.get("button#player2-scissors").click();
cy.get("button#player2-go").click();
cy.get("[data-cy='player2-scissors']").click();
cy.get("[data-cy='player2-go']").click();
});

it("Redisplays player1's board", () => {
cy.get("button#player2-rock").click();
cy.get("button#player2-go").click();
cy.get("#player1-board").should("be.visible");
cy.get("[data-cy='player2-paper']").click();
cy.get("[data-cy='player2-go']").click();
cy.get("[data-cy='player1-board']").should("be.visible");
});
});

describe("Users can see the result of the game", () => {
beforeEach(() => {
cy.get("button#player1-rock").click();
cy.get("button#player1-go").click();
cy.get("button#player2-paper").click();
cy.get("button#player2-go").click();
cy.get("[data-cy='player1-rock']").click();
cy.get("[data-cy='player1-go']").click();
cy.get("[data-cy='player2-paper']").click();
cy.get("[data-cy='player2-go']").click();
});

it("Displays a result message", () => {
cy.get("#result-message").should("contain", "Player 2 won!");
cy.get("[data-cy='result-message']").should("contain", "Player 2 won!");
});
});

describe("Users can reset the game", () => {
beforeEach(() => {
cy.get("button#player1-rock").click();
cy.get("button#player1-go").click();
cy.get("button#player2-paper").click();
cy.get("button#player2-go").click();
cy.get("[data-cy='player1-rock']").click();
cy.get("[data-cy='player1-go']").click();
cy.get("[data-cy='player2-paper']").click();
cy.get("[data-cy='player2-go']").click();
});

it("Displays Play Again button", () => {
cy.get("#play-again").should("be.visible");
cy.get("[data-cy='play-again']").should("be.visible");
});

it("Resets the game board", () => {
cy.get("button#play-again").click();
cy.get("#result-message").should("be.empty");
cy.get("[data-cy='play-again']").click();
cy.get("[data-cy='result-message']").should("be.empty");
});
});
});
10 changes: 5 additions & 5 deletions cypress/integration/userCanSeeRPSStructure.feature.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
describe("RPS interface", () => {
it("successfully renders", () => {
cy.visit("http://localhost:3000");
cy.get("#header").should("contain", "Rock Paper Scissors");
cy.get("#footer").should("contain", "Version 3.0");
cy.get("#player-header").should("contain", "Player 1");
cy.get("#player2-header").should("contain", "Player 2");
cy.visit("/");
cy.get("[data-cy='header']").should("contain", "Rock Paper Scissors");
cy.get("[data-cy='footer']").should("contain", "Version 3.0");
cy.get("[data-cy='player-header']").should("contain", "Player 1");
cy.get("[data-cy='player2-header']").should("contain", "Player 2");
});
});
44 changes: 22 additions & 22 deletions cypress/integration/userCanSeeTheCurrentScore.feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,55 @@ describe("The current score", () => {
});

it("displays 0:0 at default", () => {
cy.get("#current-score").should("contain", "0:0");
cy.get("[data-cy='current-score']").should("contain", "0:0");
});

describe("When player1 wins", () => {
beforeEach(() => {
cy.get("button#player1-paper").click();
cy.get("button#player1-go").click();
cy.get("button#player2-rock").click();
cy.get("button#player2-go").click();
cy.get("[data-cy='player1-paper']").click();
cy.get("[data-cy='player1-go']").click();
cy.get("[data-cy='player2-rock']").click();
cy.get("[data-cy='player2-go']").click();
});
it("adds up player 1's score", () => {
cy.get("#current-score").should("contain", "1:0");
cy.get("[data-cy='current-score']").should("contain", "1:0");
});
});

describe("When player2 wins", () => {
beforeEach(() => {
cy.get("button#player1-rock").click();
cy.get("button#player1-go").click();
cy.get("button#player2-paper").click();
cy.get("button#player2-go").click();
cy.get("[data-cy='player1-rock']").click();
cy.get("[data-cy='player1-go']").click();
cy.get("[data-cy='player2-paper']").click();
cy.get("[data-cy='player2-go']").click();
});
it("adds up player 2's score", () => {
cy.get("#current-score").should("contain", "0:1");
cy.get("[data-cy='current-score']").should("contain", "0:1");
});
});

describe("When players draw", () => {
beforeEach(() => {
cy.get("button#player1-paper").click();
cy.get("button#player1-go").click();
cy.get("button#player2-paper").click();
cy.get("button#player2-go").click();
cy.get("[data-cy='player1-paper']").click();
cy.get("[data-cy='player1-go']").click();
cy.get("[data-cy='player2-paper']").click();
cy.get("[data-cy='player2-go']").click();
});
it("should not add up the score", () => {
cy.get("#current-score").should("contain", "0:0");
cy.get("[data-cy='current-score']").should("contain", "0:0");
});
});

describe("When players start a new game", () => {
beforeEach(() => {
cy.get("button#player1-rock").click();
cy.get("button#player1-go").click();
cy.get("button#player2-paper").click();
cy.get("button#player2-go").click();
cy.get("button#restart").click();
cy.get("[data-cy='player1-rock']").click();
cy.get("[data-cy='player1-go']").click();
cy.get("[data-cy='player2-paper']").click();
cy.get("[data-cy='player2-go']").click();
cy.get("[data-cy='restart']").click();
});
it("should reset the score", () => {
cy.get("#current-score").should("contain", "0:0");
cy.get("[data-cy='current-score']").should("contain", "0:0");
});
});
});
2 changes: 1 addition & 1 deletion cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
import "./commands";

// Alternatively you can use CommonJS syntax:
// require('./commands')
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"@testing-library/user-event": "^12.1.10",
"react": "^17.0.0",
"react-dom": "^17.0.1",
"react-redux": "^7.2.2",
"react-scripts": "4.0.0",
"redux": "^4.0.5",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^2.0.1",
"web-vitals": "^0.2.4"
Expand Down Expand Up @@ -39,6 +41,6 @@
]
},
"devDependencies": {
"cypress": "^5.6.0"
"cypress": "5.6.0"
}
}
Loading

0 comments on commit f052046

Please sign in to comment.