Skip to content

Commit 95595a8

Browse files
authored
Merge pull request #442 from CedricProfessionnel/2UpToDate
Cypress test export
2 parents e4abda6 + 2e42c1c commit 95595a8

File tree

22 files changed

+614
-320
lines changed

22 files changed

+614
-320
lines changed

.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CYPRESS_AWS_IDENTITY_POOL_ID="XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab"
2+
CYPRESS_AWS_AUTH_REGION="XX-XXXX-X"
3+
CYPRESS_AWS_USER_POOL_ID="XX-XXXX-X_12ab34cd9"
4+
CYPRESS_AWS_USER_POOL_WEB_CLIENT_ID="26-char alphanumeric string"
5+
CYPRESS_AWS_MANDATORY_SIGN_IN=TRUE
6+
CYPRESS_AWS_AUTHENTICATION_FLOW_TYPE="XXX_XXXX_XXX"
7+
CYPRESS_AWS_STORAGE_BUCKET="XX-XXXXX"
8+
CYPRESS_AWS_STORAGE_REGION="XX-XXXX-X"
9+
CYPRESS_COGNITO_USER_NAME="[email protected]"
10+
CYPRESS_COGNITO_USER_PASS="abc123"
11+
CYPRESS_COGNITO_USER_PASS_LENGTH="0"
12+
CYPRESS_COGNITO_USER_PASS_REQUIRE_LOWERCASE=TRUE
13+
CYPRESS_COGNITO_USER_PASS_REQUIRE_UPPERCASE=TRUE
14+
CYPRESS_COGNITO_USER_PASS_REQUIRE_NUMBER=TRUE
15+
CYPRESS_COGNITO_USER_PASS_REQUIRE_SYMBOL=TRUE
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2+
23
name: Feature request
34
about: Suggest an idea for this project
45
title: ""
56
labels: enhancement
6-
assignees: ""
7-
---
7+
assignees: ''
88

99
It would be cool if the UDT could ...

cypress/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
videos
1+
videos

cypress/fixtures/cat.jpg

1.37 MB
Loading
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import enterCredentialsCognitoS3 from "../utils/credentials-test/enter-credentials-cognito-s3.spec"
2+
import enterCredentialsUser from "../utils/credentials-test/enter-credentials-user.spec"
3+
import setLanguage from "../utils/set-language.spec"
4+
import goToImportPage from "../utils/go-to-import-page.spec"
5+
import removeAWSFile from "../utils/remove-cypress-file-in-aws.spec"
6+
import "regenerator-runtime/runtime"
7+
if (Cypress.env().AWS_IDENTITY_POOL_ID)
8+
describe("aws test", () => {
9+
it("Try to export a natif project to aws", () => {
10+
cy.log("should be able to join the web site")
11+
cy.visit(`http://localhost:6001`)
12+
13+
cy.wait(400)
14+
setLanguage()
15+
enterCredentialsCognitoS3()
16+
enterCredentialsUser()
17+
goToImportPage()
18+
19+
cy.log("should be able to use export project")
20+
cy.wait(200)
21+
cy.contains("Export to S3 (Cognito)").click()
22+
cy.get("input[id='ProjectName']")
23+
.clear()
24+
.type("CypressTest1")
25+
.type("{enter}")
26+
cy.contains("Create Project").click()
27+
28+
cy.log("should be able to see the new project")
29+
cy.wait(2000)
30+
cy.contains("Export to S3 (Cognito)").click()
31+
cy.wait(200)
32+
cy.contains("CypressTest1")
33+
cy.contains("Close").click()
34+
35+
removeAWSFile("CypressTest1")
36+
37+
cy.log("should not be able to see the new project")
38+
cy.wait(2000)
39+
cy.contains("Export to S3 (Cognito)").click()
40+
cy.wait(200)
41+
cy.contains("CypressTest1").should("not.exist")
42+
})
43+
})
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const enterCredentialsCognitoS3 = () => {
2+
var credentials = Cypress.env()
3+
cy.get('input[placeholder="XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab"]')
4+
.focus()
5+
.type(credentials.AWS_IDENTITY_POOL_ID)
6+
cy.get('input[placeholder="XX-XXXX-X"]')
7+
.first()
8+
.focus()
9+
.type(credentials.AWS_AUTH_REGION)
10+
cy.get('input[placeholder="XX-XXXX-X_12ab34cd9"]')
11+
.focus()
12+
.type(credentials.AWS_USER_POOL_ID)
13+
cy.get('input[placeholder="26-char alphanumeric string"]')
14+
.focus()
15+
.type(credentials.AWS_USER_POOL_WEB_CLIENT_ID)
16+
cy.get('input[placeholder="Name of the bucket"]')
17+
.focus()
18+
.type(credentials.AWS_STORAGE_BUCKET)
19+
cy.get('input[placeholder="XX-XXXX-X"]')
20+
.last()
21+
.focus()
22+
.type(credentials.AWS_STORAGE_REGION)
23+
cy.get('input[class="MuiInputBase-input MuiInput-input"]')
24+
.last()
25+
.focus()
26+
.type(credentials.COGNITO_USER_PASS_LENGTH)
27+
if (credentials.COGNITO_USER_PASS_REQUIRE_LOWERCASE == "TRUE") {
28+
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(0).click()
29+
} else {
30+
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(1).click()
31+
}
32+
if (credentials.COGNITO_USER_PASS_REQUIRE_UPPERCASE == "TRUE") {
33+
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(2).click()
34+
} else {
35+
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(3).click()
36+
}
37+
if (credentials.COGNITO_USER_PASS_REQUIRE_NUMBER == "TRUE") {
38+
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(4).click()
39+
} else {
40+
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(5).click()
41+
}
42+
if (credentials.COGNITO_USER_PASS_REQUIRE_SYMBOL == "TRUE") {
43+
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(6).click()
44+
} else {
45+
cy.get('input[class="PrivateSwitchBase-input-63"]').eq(7).click()
46+
}
47+
}
48+
49+
const test = () => {
50+
cy.log("should be able to set s3 config")
51+
cy.contains("Add Authentification").click()
52+
cy.contains("AWS - Cognito").click()
53+
enterCredentialsCognitoS3()
54+
cy.contains("Complete").click()
55+
}
56+
57+
export default test
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const enterCredentialsUser = () => {
2+
var credentials = Cypress.env()
3+
cy.get('input[id="username"]').focus().type(credentials.COGNITO_USER_NAME)
4+
cy.get('input[id="password"]').focus().type(credentials.COGNITO_USER_PASS)
5+
}
6+
const test = () => {
7+
cy.log("should be able to set user cognito config")
8+
cy.contains("Cognito").click()
9+
enterCredentialsUser()
10+
cy.get(
11+
'button[class="MuiButtonBase-root MuiButton-root MuiButton-contained makeStyles-submit-68 MuiButton-containedPrimary MuiButton-fullWidth"]'
12+
).click()
13+
cy.wait(2000)
14+
}
15+
export default test
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const test = (typeProject) => {
2+
cy.log("should be able to go to the import page")
3+
cy.contains("New File").click()
4+
if (typeProject) cy.contains(typeProject).click()
5+
cy.get('button[id="tab-samples"]').click()
6+
cy.contains("Samples").click()
7+
cy.contains("Import").click()
8+
}
9+
10+
export default test

cypress/utils/interface-test/create-new-file.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const createNewFile = () => {
22
it("Should be able to select all the interfaces", () => {
33
cy.contains("New File").click()
44
cy.contains("Image Segmentation").click()
5+
cy.wait(200)
56
cy.matchImageSnapshot("image_segmentation", {
67
failureThresholdType: "percent",
78
})
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import datasetManagerCognito from "udt-dataset-managers/dist/CognitoDatasetManager"
2+
3+
const removeAWSFile = (name) => {
4+
var credentials = Cypress.env()
5+
cy.then(
6+
async () => {
7+
const authConfig = {
8+
Auth: {
9+
identityPoolId: credentials.AWS_IDENTITY_POOL_ID,
10+
region: credentials.AWS_AUTH_REGION,
11+
userPoolId: credentials.AWS_USER_POOL_ID,
12+
userPoolWebClientId: credentials.AWS_USER_POOL_WEB_CLIENT_ID,
13+
mandatorySignIn: credentials.AWS_MANDATORY_SIGN_IN,
14+
authenticationFlowType: credentials.AWS_AUTHENTICATION_FLOW_TYPE,
15+
},
16+
Storage: {
17+
AWSS3: {
18+
bucket: credentials.AWS_STORAGE_BUCKET,
19+
region: credentials.AWS_STORAGE_REGION,
20+
},
21+
},
22+
}
23+
const ds = await new datasetManagerCognito({ authConfig })
24+
await ds.removeProject(name)
25+
},
26+
{ timeout: 10000 }
27+
)
28+
}
29+
export default removeAWSFile

0 commit comments

Comments
 (0)