Skip to content

Commit dd2d494

Browse files
credentials test without functions
1 parent fd311c7 commit dd2d494

File tree

5 files changed

+105
-34
lines changed

5 files changed

+105
-34
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import enterCredentialsCognitoS3 from "../utils/credentials-test/enter-credentials-cognito-s3"
2+
import enterCredentialsUser from "../utils/credentials-test/enter-credentials-user"
3+
import commandLocalStorage from "../utils/cypress-command/local-storage"
4+
import commandSetLanguage from "../utils/cypress-command/set-language"
5+
commandLocalStorage()
6+
commandSetLanguage()
7+
8+
Cypress.config("defaultCommandTimeout", 3000)
9+
if (Cypress.env().AWS_IDENTITY_POOL_ID)
10+
describe("Credentials test", () => {
11+
before("Prepare tests", () => {
12+
cy.log("should be able to join the web site")
13+
cy.visit(`http://localhost:6001`)
14+
cy.setLanguage("en")
15+
})
16+
17+
beforeEach("Restore local storage", () => {
18+
cy.restoreLocalStorage()
19+
})
20+
21+
enterCredentialsCognitoS3()
22+
enterCredentialsUser()
23+
24+
afterEach("Save local storage", () => {
25+
cy.saveLocalStorage()
26+
})
27+
})
Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,99 @@
1+
require("cypress-xpath")
12
const enterCredentialsCognitoS3 = () => {
2-
var credentials = Cypress.env()
33
cy.get('input[placeholder="XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab"]')
44
.focus()
5-
.type(credentials.AWS_IDENTITY_POOL_ID)
5+
.type(Cypress.env().AWS_IDENTITY_POOL_ID)
66
cy.get('input[placeholder="XX-XXXX-X"]')
77
.first()
88
.focus()
9-
.type(credentials.AWS_AUTH_REGION)
9+
.type(Cypress.env().AWS_AUTH_REGION)
1010
cy.get('input[placeholder="XX-XXXX-X_12ab34cd9"]')
1111
.focus()
12-
.type(credentials.AWS_USER_POOL_ID)
12+
.type(Cypress.env().AWS_USER_POOL_ID)
1313
cy.get('input[placeholder="26-char alphanumeric string"]')
1414
.focus()
15-
.type(credentials.AWS_USER_POOL_WEB_CLIENT_ID)
15+
.type(Cypress.env().AWS_USER_POOL_WEB_CLIENT_ID)
1616
cy.get('input[placeholder="Name of the bucket"]')
1717
.focus()
18-
.type(credentials.AWS_STORAGE_BUCKET)
18+
.type(Cypress.env().AWS_STORAGE_BUCKET)
1919
cy.get('input[placeholder="XX-XXXX-X"]')
2020
.last()
2121
.focus()
22-
.type(credentials.AWS_STORAGE_REGION)
22+
.type(Cypress.env().AWS_STORAGE_REGION)
2323
cy.get('input[class="MuiInputBase-input MuiInput-input"]')
2424
.last()
2525
.focus()
26-
.type(credentials.COGNITO_USER_PASS_LENGTH)
27-
if (credentials.COGNITO_USER_PASS_REQUIRE_LOWERCASE == "TRUE") {
28-
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(0).click()
26+
.type(Cypress.env().COGNITO_USER_PASS_LENGTH)
27+
if (Cypress.env().COGNITO_USER_PASS_REQUIRE_LOWERCASE === "TRUE") {
28+
cy.xpath(
29+
"./html/body/div[3]/div[3]/div/div[2]/div/div[2]/div[8]/div[3]/div/button[1]/span[1]/span/span[1]/input"
30+
)
31+
.click()
32+
.focus()
33+
.blur()
2934
} else {
30-
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(1).click()
35+
cy.xpath(
36+
"./html/body/div[3]/div[3]/div/div[2]/div/div[2]/div[8]/div[3]/div/button[2]/span[1]/span/span[1]/input"
37+
)
38+
.click()
39+
.focus()
40+
.blur()
3141
}
32-
if (credentials.COGNITO_USER_PASS_REQUIRE_UPPERCASE == "TRUE") {
33-
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(2).click()
42+
if (Cypress.env().COGNITO_USER_PASS_REQUIRE_UPPERCASE === "TRUE") {
43+
cy.xpath(
44+
"./html/body/div[3]/div[3]/div/div[2]/div/div[2]/div[9]/div[3]/div/button[1]/span[1]/span/span[1]/input"
45+
)
46+
.click()
47+
.focus()
48+
.blur()
3449
} else {
35-
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(3).click()
50+
cy.xpath(
51+
"./html/body/div[3]/div[3]/div/div[2]/div/div[2]/div[9]/div[3]/div/button[2]/span[1]/span/span[1]/input"
52+
)
53+
.click()
54+
.focus()
55+
.blur()
3656
}
37-
if (credentials.COGNITO_USER_PASS_REQUIRE_NUMBER == "TRUE") {
38-
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(4).click()
57+
if (Cypress.env().COGNITO_USER_PASS_REQUIRE_NUMBER === "TRUE") {
58+
cy.xpath(
59+
"./html/body/div[3]/div[3]/div/div[2]/div/div[2]/div[10]/div[3]/div/button[1]/span[1]/span/span[1]/input"
60+
)
61+
.click()
62+
.focus()
63+
.blur()
3964
} else {
40-
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(5).click()
65+
cy.xpath(
66+
"./html/body/div[3]/div[3]/div/div[2]/div/div[2]/div[10]/div[3]/div/button[2]/span[1]/span/span[1]/input"
67+
)
68+
.click()
69+
.focus()
70+
.blur()
4171
}
42-
if (credentials.COGNITO_USER_PASS_REQUIRE_SYMBOL == "TRUE") {
43-
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(6).click()
72+
if (Cypress.env().COGNITO_USER_PASS_REQUIRE_SYMBOL === "TRUE") {
73+
cy.xpath(
74+
"./html/body/div[3]/div[3]/div/div[2]/div/div[2]/div[11]/div[3]/div/button[1]/span[1]/span/span[1]/input"
75+
)
76+
.click()
77+
.focus()
78+
.blur()
4479
} else {
45-
cy.get('input[class="PrivateSwitchBase-input-65"]').eq(7).click()
80+
cy.xpath(
81+
"./html/body/div[3]/div[3]/div/div[2]/div/div[2]/div[11]/div[3]/div/button[2]/span[1]/span/span[1]/input"
82+
)
83+
.click()
84+
.focus()
85+
.blur()
4686
}
4787
}
4888

4989
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()
90+
it("Enter credentials cognito-s3", () => {
91+
cy.log("should be able to set s3 config")
92+
cy.contains("Add Authentification").click()
93+
cy.contains("AWS - Cognito").click()
94+
enterCredentialsCognitoS3()
95+
cy.contains("Complete").click()
96+
})
5597
}
5698

5799
export default test
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
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)
2+
cy.get('input[id="username"]').focus().type(Cypress.env().COGNITO_USER_NAME)
3+
cy.get('input[id="password"]').focus().type(Cypress.env().COGNITO_USER_PASS)
54
}
65
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-70 MuiButton-containedPrimary MuiButton-fullWidth"]'
12-
).click()
6+
it("Enter credentials user cognito", () => {
7+
cy.log("should be able to set user cognito config")
8+
cy.contains("Cognito").click()
9+
enterCredentialsUser()
10+
cy.get("button[id='sign-in']").click()
11+
cy.get("button[id='sign-in']", { timeout: 30000 }).should("not.exist")
12+
})
1313
}
1414
export default test

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"cypress-image-snapshot": "^3.1.1",
7070
"cypress-terminal-report": "^2.4.0",
7171
"electron": "^11.2.3",
72+
"cypress-xpath": "^1.6.1",
7273
"electron-builder": "^22.8.0",
7374
"electron-builder-notarize": "^1.2.0",
7475
"eslint-plugin-cypress": "^2.11.2",

src/components/LoginDrawer/SignIn.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export default ({ onRequireCompleteSignUp }) => {
134134
variant="contained"
135135
color="primary"
136136
className={classes.submit}
137+
id="sign-in"
137138
>
138139
{t("sign-in")}
139140
</Button>

0 commit comments

Comments
 (0)