Skip to content

Commit

Permalink
fix: Merge pull request #465 from CedricProfessionnel/3UpToDate
Browse files Browse the repository at this point in the history
Refactor Cognito Test
  • Loading branch information
seveibar committed Feb 24, 2021
2 parents b692b2e + aa108de commit b52280a
Show file tree
Hide file tree
Showing 21 changed files with 2,676 additions and 4,648 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
cypress/integration/*
cypress/utils/*
cypress/utils/*
logs/*
cypress/screenshots/*
17 changes: 16 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
node-version: 12
- name: Run Prettier Test
run: npx prettier --check "src/**/*.js"
run: npx prettier --check .
- name: Run Lint Test
run: |
# TODO this takes 1-2 mins to install, run eslint w/o installing
Expand All @@ -38,3 +38,18 @@ jobs:
record: true
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_AWS_IDENTITY_POOL_ID: ${{ secrets.CYPRESS_AWS_IDENTITY_POOL_ID }}
CYPRESS_AWS_AUTH_REGION: ${{ secrets.CYPRESS_AWS_AUTH_REGION }}
CYPRESS_AWS_USER_POOL_ID: ${{ secrets.CYPRESS_AWS_USER_POOL_ID }}
CYPRESS_AWS_USER_POOL_WEB_CLIENT_ID: ${{ secrets.CYPRESS_AWS_USER_POOL_WEB_CLIENT_ID }}
CYPRESS_AWS_MANDATORY_SIGN_IN: ${{ secrets.CYPRESS_AWS_MANDATORY_SIGN_IN }}
CYPRESS_AWS_AUTHENTICATION_FLOW_TYPE: ${{ secrets.CYPRESS_AWS_AUTHENTICATION_FLOW_TYPE }}
CYPRESS_AWS_STORAGE_BUCKET: ${{ secrets.CYPRESS_AWS_STORAGE_BUCKET }}
CYPRESS_AWS_STORAGE_REGION: ${{ secrets.CYPRESS_AWS_STORAGE_REGION }}
CYPRESS_COGNITO_USER_NAME: ${{ secrets.CYPRESS_COGNITO_USER_NAME }}
CYPRESS_COGNITO_USER_PASS: ${{ secrets.CYPRESS_COGNITO_USER_PASS }}
CYPRESS_COGNITO_USER_PASS_LENGTH: ${{ secrets.CYPRESS_COGNITO_USER_PASS_LENGTH }}
CYPRESS_COGNITO_USER_PASS_REQUIRE_LOWERCASE: ${{ secrets.CYPRESS_COGNITO_USER_PASS_REQUIRE_LOWERCASE }}
CYPRESS_COGNITO_USER_PASS_REQUIRE_UPPERCASE: ${{ secrets.CYPRESS_COGNITO_USER_PASS_REQUIRE_UPPERCASE }}
CYPRESS_COGNITO_USER_PASS_REQUIRE_NUMBER: ${{ secrets.CYPRESS_COGNITO_USER_PASS_REQUIRE_NUMBER }}
CYPRESS_COGNITO_USER_PASS_REQUIRE_SYMBOL: ${{ secrets.CYPRESS_COGNITO_USER_PASS_REQUIRE_SYMBOL }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ dist
desktop/node_modules

/lib

src/components/WebApp/myAWSconfig.js
package-lock.json
src/components/WebApp/myAWSconfig.js
.env
.cache

logs
# eventually we'll commit these
cypress/snapshots
cypress/screenshots

.idea
*.db
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
build/*
dist/*
lib/*
logs/*
node_modules/*
.env
.env.example
yarn-error.log
cypress/snapshots/*
cypress/videos/*
Expand Down
2 changes: 1 addition & 1 deletion cypress/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
videos
videos
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import enterCredentialsCognitoS3 from "./utils/credentials-test/enter-credentials-cognito-s3"
import enterCredentialsUser from "./utils/credentials-test/enter-credentials-user"
import setLanguage from "./utils/set-language"
import goToImportPage from "./utils/go-to-import-page"
import removeAWSFile from "./utils/remove-cypress-file-in-aws"
import "regenerator-runtime/runtime"
import enterCredentialsCognitoS3 from "../utils/credentials-test/enter-credentials-cognito-s3"
import enterCredentialsUser from "../utils/credentials-test/enter-credentials-user"
import setLanguage from "../utils/set-language"
import goToImportPage from "../utils/go-to-import-page"
import removeAWSFile from "../utils/remove-cypress-file-in-aws"

if (Cypress.env().AWS_IDENTITY_POOL_ID)
describe("aws test", () => {
it("Try to export a natif project to aws", () => {
before("Prepare tests", () => {
cy.log("should be able to join the web site")
cy.visit(`http://localhost:6001`)

cy.wait(400)
setLanguage()
enterCredentialsCognitoS3()
enterCredentialsUser()
goToImportPage()
})

it("Try to export a natif project to aws", () => {
cy.log("should be able to use export project")
cy.wait(200)
cy.contains("Export to S3 (Cognito)").click()
Expand All @@ -31,13 +32,16 @@ if (Cypress.env().AWS_IDENTITY_POOL_ID)
cy.wait(200)
cy.contains("CypressTest1")
cy.contains("Close").click()
})

afterEach("Clean AWS", () => {
removeAWSFile("CypressTest1")

cy.log("should not be able to see the new project")
cy.wait(2000)
cy.wait(200)
cy.contains("Export to S3 (Cognito)").click()
cy.wait(200)
cy.contains("CypressTest1").should("not.exist")
cy.contains("Close").click()
})
})
2 changes: 1 addition & 1 deletion cypress/integration/collaborative-session.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("Create and Visit Collaborative Session", () => {
.focus()
.type("English")
.type("{enter}")
cy.contains("New File").click()
cy.contains("New File", { timeout: 50000 }).click()
})
createAndVisitCollaborativeSession()
clickOn100SamplesInACollaborativeSession()
Expand Down
2 changes: 0 additions & 2 deletions cypress/integration/udt-test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import createNewFile from "./utils/interface-test/create-new-file"
import imageClassification from "./utils/interface-test/image-classification"
import imageSegmentation from "./utils/interface-test/image-segmentation"
import keyboardShortcuts from "./utils/interface-test/keyboard-shortcuts"
import labelHelp from "./utils/interface-test/label-help"
import namedEntityRecognition from "./utils/interface-test/named-entity-recognition"
import pasteImageUrlsWithCSV from "./utils/interface-test/paste-image-urls-with-csv"
import pasteImageUrls from "./utils/interface-test/paste-image-urls"
Expand All @@ -21,7 +20,6 @@ describe("Udt test", () => {
imageClassification()
imageSegmentation()
keyboardShortcuts()
labelHelp()
namedEntityRecognition()
pasteImageUrlsWithCSV()
pasteImageUrls()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ const enterCredentialsCognitoS3 = () => {
.focus()
.type(credentials.COGNITO_USER_PASS_LENGTH)
if (credentials.COGNITO_USER_PASS_REQUIRE_LOWERCASE == "TRUE") {
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(0).click()
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(0).click()
} else {
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(1).click()
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(1).click()
}
if (credentials.COGNITO_USER_PASS_REQUIRE_UPPERCASE == "TRUE") {
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(2).click()
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(2).click()
} else {
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(3).click()
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(3).click()
}
if (credentials.COGNITO_USER_PASS_REQUIRE_NUMBER == "TRUE") {
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(4).click()
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(4).click()
} else {
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(5).click()
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(5).click()
}
if (credentials.COGNITO_USER_PASS_REQUIRE_SYMBOL == "TRUE") {
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(6).click()
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(6).click()
} else {
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(7).click()
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(7).click()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const test = () => {
cy.contains("Cognito").click()
enterCredentialsUser()
cy.get(
'button[class="MuiButtonBase-root MuiButton-root MuiButton-contained makeStyles-submit-68 MuiButton-containedPrimary MuiButton-fullWidth"]'
'button[class="MuiButtonBase-root MuiButton-root MuiButton-contained makeStyles-submit-70 MuiButton-containedPrimary MuiButton-fullWidth"]'
).click()
cy.wait(2000)
}
export default test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import getDataUrlType from "../../../src/utils/get-data-url-type"
import getDataUrlType from "../../../dist/utils/get-data-url-type"
const getDataUrlTypeTest = () => {
it("Check getDataUrlType", () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/utils/go-to-import-page.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = (typeProject) => {
cy.log("should be able to go to the import page")
cy.contains("New File").click()
cy.contains("New File", { timeout: 50000 }).click()
if (typeProject) cy.contains(typeProject).click()
cy.get('button[id="tab-samples"]').click()
cy.contains("Samples").click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const createNewFile = () => {
it("Should be able to select all the interfaces", () => {
it.skip("Should be able to select all the interfaces", () => {
cy.contains("New File").click()
cy.contains("Image Segmentation").click()
cy.wait(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const imageClassification = () => {
.type("not ai generated")

cy.log("should be able to see samples")
cy.get("#tab-samples").click()
cy.get("#tab-samples", { timeout: 5000 }).click()

cy.log("should be able to open 21st sample")
cy.contains("21").click()
Expand Down
21 changes: 0 additions & 21 deletions cypress/integration/utils/interface-test/label-help.js

This file was deleted.

9 changes: 9 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@
const { addMatchImageSnapshotPlugin } = require("cypress-image-snapshot/plugin")

module.exports = (on, config) => {
const options = {
outputRoot: config.projectRoot + "/logs/",
outputTarget: {
"out.txt": "txt",
"out.json": "json",
},
printLogsToConsole: "never",
}
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
addMatchImageSnapshotPlugin(on, config),
require("@cypress/react/plugins/react-scripts")(on, config)
require("cypress-terminal-report/src/installLogsPrinter")(on, options)
return config
}
1 change: 0 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
import { addMatchImageSnapshotCommand } from "cypress-image-snapshot/command"

// https://github.com/abramenal/cypress-file-upload
import "cypress-file-upload"

Expand Down
1 change: 1 addition & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// Import commands.js using ES2015 syntax:
import "./commands"
require("cypress-terminal-report/src/installLogsCollector")()

// Alternatively you can use CommonJS syntax:
// require('./commands')
31 changes: 18 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"proxy": "http://localhost:3000",
"scripts": {
"start": "cross-env PORT=6001 react-scripts start",
"start:desktop": "cross-env BROWSER=none USE_DEV_SERVER=yes concurrently 'npm run start' 'electron ./desktop'",
"start:desktop": "cross-env BROWSER=none USE_DEV_SERVER=yes concurrently 'start' 'electron ./desktop'",
"start:desktop:static": "electron ./desktop",
"start:web:static": "concurrently 'node ./add-preloaded-app-config.js && serve -s build -p 3000' 'udt-collaboration-server --port 3001'",
"build": "npm run build:web",
Expand All @@ -29,9 +29,8 @@
"prettier": "prettier --write .",
"test:prettier": "prettier --check \"src/**/*.js\"",
"test:lint": "eslint src --max-warnings=0",
"test:integration:dev": "./node_modules/cypress/bin/cypress open",
"test:integration": "./node_modules/cypress/bin/cypress run --env failOnSnapshotDiff=false",
"test:devBrowser": "dotenv yarn run cypress open"
"test:integration:dev": "dotenv cypress open",
"test:integration": "dotenv cypress run failOnSnapshotDiff=false"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -46,11 +45,16 @@
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
],
"test": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/cli": "^7.5.0",
"@babel/core": "^7.5.4",
"@babel/cli": "^7.12.13",
"@babel/core": "^7.12.13",
"@cypress/react": "^4.16.4",
"@material-ui/core": "^4.9.5",
"@material-ui/icons": "^4.9.1",
Expand All @@ -61,18 +65,18 @@
"@testing-library/react-hooks": "^3.2.1",
"ava": "^3.7.0",
"chroma-js": "^2.0.4",
"concurrently": "^5.2.0",
"cross-env": "^7.0.0",
"concurrently": "^5.3.0",
"cypress": "^6.4.0",
"cypress-file-upload": "^4.0.6",
"cypress-image-snapshot": "^3.1.1",
"electron": "^8.0.0",
"cypress-terminal-report": "^2.4.0",
"electron": "^11.2.3",
"electron-builder": "^22.8.0",
"electron-builder-notarize": "^1.2.0",
"gh-pages": "^2.1.1",
"material-survey": "^1.0.40",
"parcel": "^1.12.4",
"prettier": "^2.0.2",
"prettier": "^2.2.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-markdown": "^4.1.0",
Expand All @@ -85,12 +89,13 @@
"@semantic-release/git": "^9.0.0",
"@sentry/browser": "^5.15.4",
"any-shell-escape": "^0.1.1",
"aws-amplify": "^3.0.6",
"aws-amplify": "^3.3.18",
"aws-sign": "^1.0.0",
"aws4fetch": "^1.0.12",
"axios": "^0.19.2",
"axios": "^0.21.1",
"bent": "^7.1.0",
"brace": "^0.11.1",
"cross-env": "^7.0.3",
"detect-browser": "^5.0.0",
"dotenv-cli": "^4.0.0",
"download-file": "^0.1.5",
Expand Down Expand Up @@ -129,7 +134,7 @@
"seedrandom": "^3.0.5",
"serve": "^11.3.2",
"styled-components": "^5.0.0",
"udt-collaboration-server": "^1.0.7",
"udt-collaboration-server": "^1.0.8",
"udt-dataset-managers": "^1.0.15",
"udt-format": "0.0.1",
"use-async-effect": "^2.2.2",
Expand Down
12 changes: 6 additions & 6 deletions public/legal.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
<body>
<div
id="header"
style="display: inline-flex; justify-content: space-between; width: 100%;"
style="display: inline-flex; justify-content: space-between; width: 100%"
>
<img src="./favicon.ico" style="height: 100%;" />
<div style="display: flex; width: 100%;">
<a style="margin: auto;" href="https://universaldatatool.com">
<img src="./favicon.ico" style="height: 100%" />
<div style="display: flex; width: 100%">
<a style="margin: auto" href="https://universaldatatool.com">
<h1>Universal Data Tool</h1>
</a>
</div>
<img src="./favicon.ico" style="height: 100%;" />
<img src="./favicon.ico" style="height: 100%" />
</div>
<div
id="terms-and-conditions-wrapper"
style="padding-right: 5vw; padding-left: 5vw; padding-top: 2vh;"
style="padding-right: 5vw; padding-left: 5vw; padding-top: 2vh"
>
<h1>Terms and Conditions of Use</h1>
<h3>1. Terms</h3>
Expand Down
Loading

0 comments on commit b52280a

Please sign in to comment.