forked from cypress-io/cypress-realworld-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cognito.spec.ts
85 lines (65 loc) · 2.99 KB
/
cognito.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import "../../support/auth-provider-commands/cognito";
import { isMobile } from "../../support/utils";
if (Cypress.env("cognito_username")) {
// Sign in with AWS
if (Cypress.env("cognito_programmatic_login")) {
describe("AWS Cognito", function () {
beforeEach(function () {
cy.task("db:seed");
cy.intercept("POST", "/bankAccounts").as("createBankAccount");
cy.loginByCognitoApi(Cypress.env("cognito_username"), Cypress.env("cognito_password"));
});
it("should allow a visitor to login, onboard and logout", function () {
cy.contains("Get Started").should("be.visible");
// Onboarding
cy.getBySel("user-onboarding-dialog").should("be.visible");
cy.getBySel("user-onboarding-next").click();
cy.getBySel("user-onboarding-dialog-title").should("contain", "Create Bank Account");
cy.getBySelLike("bankName-input").type("The Best Bank");
cy.getBySelLike("accountNumber-input").type("123456789");
cy.getBySelLike("routingNumber-input").type("987654321");
cy.getBySelLike("submit").click();
cy.wait("@createBankAccount");
cy.getBySel("user-onboarding-dialog-title").should("contain", "Finished");
cy.getBySel("user-onboarding-dialog-content").should("contain", "You're all set!");
cy.getBySel("user-onboarding-next").click();
cy.getBySel("transaction-list").should("be.visible");
// Logout User
if (isMobile()) {
cy.getBySel("sidenav-toggle").click();
}
cy.getBySel("sidenav-signout").click();
cy.location("pathname").should("eq", "/");
});
it("shows onboarding", function () {
cy.contains("Get Started").should("be.visible");
});
});
} else {
describe("AWS Cognito", function () {
beforeEach(function () {
cy.task("db:seed");
cy.loginByCognito(Cypress.env("cognito_username"), Cypress.env("cognito_password"));
cy.visit("/");
});
it("shows onboarding", function () {
cy.contains("Get Started").should("be.visible");
});
it("should allow a visitor to login, onboard and logout", function () {
cy.contains("Get Started").should("be.visible");
// Onboarding
cy.getBySel("user-onboarding-dialog").should("be.visible");
cy.getBySel("user-onboarding-next").click();
cy.getBySel("user-onboarding-dialog-title").should("contain", "Create Bank Account");
cy.getBySelLike("bankName-input").type("The Best Bank");
cy.getBySelLike("accountNumber-input").type("123456789");
cy.getBySelLike("routingNumber-input").type("987654321");
cy.getBySelLike("submit").click();
cy.getBySel("user-onboarding-dialog-title").should("contain", "Finished");
cy.getBySel("user-onboarding-dialog-content").should("contain", "You're all set!");
cy.getBySel("user-onboarding-next").click();
cy.getBySel("transaction-list").should("be.visible");
});
});
}
}