Skip to content

Commit

Permalink
Fix running RWA on Windows (#421)
Browse files Browse the repository at this point in the history
* install ncp and cross-env; update npm scripts

* downgrade react scripts to 3.40 for windows; move tsnode config to file

facebook/create-react-app#8707 (comment)

* update circle config to run tests on windows

* update windows run to use cypress orb

* update windows executor

* require setup for windows build

* downgrade babel-loader for react-scripts 3.4.0

* setup linux and windows workflows

* update windows workflow to install google chrome and run test in chrome

* update windows to run against electron

* wait for notifications

* update with additional wait for notifications

* add additional wait for notifications

* add additional notifications wait

* add additional assertion to make sure the list has been updated

* update to fix flake

* fix length counts for flake

* update to fix count and waits for flake

* add assertion to retry for correct count

* ensure the like registers

* name jobs

* cypress info on Windows

* disable install of google chrome on windows

* wait on comment to be posted to fix flake

* resolve babel/compat-data to v7.9.0 to fix failed to compile error

#420 (comment)

Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>
  • Loading branch information
Kevin Old and bahmutov committed Jun 15, 2020
1 parent 3e990f6 commit 9a0e152
Show file tree
Hide file tree
Showing 5 changed files with 350 additions and 299 deletions.
261 changes: 156 additions & 105 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: 2.1
orbs:
cypress: cypress-io/cypress@1.24.0
codecov: codecov/codecov@1.1.0
win: circleci/windows@2.2.0

executors:
with-chrome-and-firefox:
Expand All @@ -21,113 +22,163 @@ commands:
file: coverage/coverage-final.json

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Workflows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
workflows:
build:
jobs:
# Setup
# 1. Install Cypress
# 2. Validate types
# 3. Run server unit-tests
- cypress/install:
name: "Setup"
yarn: true
executor: with-chrome-and-firefox
post-steps:
- run:
name: Check Types
command: yarn types
- run:
name: Run Unit Tests
command: yarn test:unit:ci
linux-workflow: &linux-workflow
jobs:
# Setup
# 1. Install Cypress
# 2. Validate types
# 3. Run server unit-tests
- cypress/install:
name: "Setup Linux"
yarn: true
executor: with-chrome-and-firefox
post-steps:
- run:
name: Check Types
command: yarn types
- run:
name: Run Unit Tests
command: yarn test:unit:ci

# Run API tests against backend server
- cypress/run:
name: "API Tests"
browser: chrome
spec: cypress/tests/api/*
executor: with-chrome-and-firefox
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: API
requires:
- Setup Linux
post-steps:
- report-coverage

# Run E2E tests in Chrome
- cypress/run:
name: "UI Tests - Chrome"
browser: chrome
spec: cypress/tests/ui/*
executor: with-chrome-and-firefox
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: "UI - Chrome"
requires:
- Setup Linux
post-steps:
- report-coverage

# Run API tests against backend server
- cypress/run:
name: "API Tests"
browser: chrome
spec: cypress/tests/api/*
executor: with-chrome-and-firefox
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: API
requires:
- Setup
post-steps:
- report-coverage
# Run E2E tests in Chrome with mobile device viewport
- cypress/run:
name: "UI Tests - Chrome - Mobile"
browser: chrome
spec: cypress/tests/ui/*
config: "viewportWidth=375,viewportHeight=667"
executor: with-chrome-and-firefox
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: "UI - Chrome - Mobile"
requires:
- Setup Linux
post-steps:
- report-coverage

# Run E2E tests in Chrome
- cypress/run:
name: "UI Tests - Chrome"
browser: chrome
spec: cypress/tests/ui/*
executor: with-chrome-and-firefox
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: "UI - Chrome"
requires:
- Setup
post-steps:
- report-coverage
# Run E2E tests in Firefox
- cypress/run:
name: "UI Tests - Firefox"
browser: firefox
spec: cypress/tests/ui/*
executor: with-chrome-and-firefox
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: "UI - Firefox"
requires:
- Setup Linux
post-steps:
- report-coverage

# Run E2E tests in Chrome with mobile device viewport
- cypress/run:
name: "UI Tests - Chrome - Mobile"
browser: chrome
spec: cypress/tests/ui/*
config: "viewportWidth=375,viewportHeight=667"
executor: with-chrome-and-firefox
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: "UI - Chrome - Mobile"
requires:
- Setup
post-steps:
- report-coverage
# Run E2E tests in Firefox with mobile device viewport
- cypress/run:
name: "UI Tests - Firefox - Mobile"
browser: firefox
spec: cypress/tests/ui/*
config: "viewportWidth=375,viewportHeight=667"
executor: with-chrome-and-firefox
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: "UI - Firefox - Mobile"
requires:
- Setup Linux
post-steps:
- report-coverage

# Run E2E tests in Firefox
- cypress/run:
name: "UI Tests - Firefox"
browser: firefox
spec: cypress/tests/ui/*
executor: with-chrome-and-firefox
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: "UI - Firefox"
requires:
- Setup
post-steps:
- report-coverage
windows-workflow: &windows-workflow
jobs:
# Setup
# 1. Install Cypress
# 2. Validate types
# 3. Run server unit-tests
- cypress/install:
name: "Setup Windows"
yarn: true
executor:
# executor comes from the "windows" orb
name: win/default
shell: bash.exe
post-steps:
- run:
name: Cypress info
command: yarn cypress info
- run:
name: Check Types
command: yarn types
- run:
name: Run Unit Tests
command: yarn test:unit:ci

# Run E2E tests in Firefox with mobile device viewport
- cypress/run:
name: "UI Tests - Firefox - Mobile"
browser: firefox
spec: cypress/tests/ui/*
config: "viewportWidth=375,viewportHeight=667"
executor: with-chrome-and-firefox
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: "UI - Firefox - Mobile"
requires:
- Setup
post-steps:
- report-coverage
# Run E2E tests in Windows in Electron
- cypress/run:
name: "UI Tests - Electron - Windows"
spec: cypress/tests/ui/*
executor:
# executor comes from the "windows" orb
name: win/default
shell: bash.exe
wait-on: "http://localhost:3000"
yarn: true
start: yarn start:ci
record: true
parallel: true
parallelism: 5
group: "UI - Electron - Windows"
requires:
- Setup Windows
post-steps:
- report-coverage
no-workspace: true

workflows:
linux:
<<: *linux-workflow
windows:
<<: *windows-workflow
28 changes: 28 additions & 0 deletions cypress/tests/ui/notifications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe("Notifications", function () {
cy.route("GET", "/notifications").as("getNotifications");
cy.route("POST", "/transactions").as("createTransaction");
cy.route("PATCH", "/notifications/*").as("updateNotification");
cy.route("POST", "/comments/*").as("postComment");

cy.database("filter", "users").then((users: User[]) => {
ctx.userA = users[0];
Expand All @@ -43,7 +44,13 @@ describe("Notifications", function () {
cy.getBySel("nav-top-notifications-count").should("have.text", `${notificationCount}`);
});

const likesCountSelector = "[data-test*=transaction-like-count]";
cy.contains(likesCountSelector, 0);
cy.getBySelLike("like-button").click();
// a successful "like" should disable the button and increment
// the number of likes
cy.getBySelLike("like-button").should("be.disabled");
cy.contains(likesCountSelector, 1);

cy.switchUser(ctx.userB.username);

Expand All @@ -53,7 +60,10 @@ describe("Notifications", function () {

cy.visit("/notifications");

cy.wait("@getNotifications");

cy.getBySelLike("notification-list-item")
.should("have.length", 9)
.first()
.should("contain", ctx.userA?.firstName)
.and("contain", "liked");
Expand Down Expand Up @@ -81,6 +91,9 @@ describe("Notifications", function () {
cy.switchUser(ctx.userA.username);

cy.getBySelLike("notifications-link").click();

cy.wait("@getNotifications");

cy.location("pathname").should("equal", "/notifications");

cy.getBySelLike("notification-list-item")
Expand All @@ -91,7 +104,11 @@ describe("Notifications", function () {
cy.switchUser(ctx.userB.username);

cy.getBySelLike("notifications-link").click();

cy.wait("@getNotifications");

cy.getBySelLike("notification-list-item")
.should("have.length", 9)
.first()
.should("contain", ctx.userC.firstName)
.and("contain", "liked");
Expand All @@ -111,7 +128,11 @@ describe("Notifications", function () {
cy.switchUser(ctx.userB.username);

cy.getBySelLike("notifications-link").click();

cy.wait("@getNotifications");

cy.getBySelLike("notification-list-item")
.should("have.length", 9)
.first()
.should("contain", ctx.userA?.firstName)
.and("contain", "commented");
Expand All @@ -129,10 +150,16 @@ describe("Notifications", function () {

cy.getBySelLike("comment-input").type("Thank You{enter}");

cy.wait("@postComment");

cy.switchUser(ctx.userA.username);

cy.getBySelLike("notifications-link").click();

cy.wait("@getNotifications");

cy.getBySelLike("notification-list-item")
.should("have.length", 9)
.first()
.should("contain", ctx.userC.firstName)
.and("contain", "commented");
Expand All @@ -141,6 +168,7 @@ describe("Notifications", function () {

cy.getBySelLike("notifications-link").click();
cy.getBySelLike("notification-list-item")
.should("have.length", 9)
.first()
.should("contain", ctx.userC.firstName)
.and("contain", "commented");
Expand Down

0 comments on commit 9a0e152

Please sign in to comment.