parent
9a8b484ee8
commit
31c388a6e3
@ -0,0 +1,14 @@
|
||||
import { defineConfig } from "cypress";
|
||||
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
baseUrl: "http://localhost:3000",
|
||||
defaultCommandTimeout: 10000,
|
||||
pageLoadTimeout: 60000,
|
||||
viewportWidth: 1920,
|
||||
viewportHeight: 1080,
|
||||
},
|
||||
env: {
|
||||
baseUrl: "http://localhost:3000",
|
||||
},
|
||||
});
|
@ -0,0 +1,24 @@
|
||||
import { actor } from "../support/actors/actor";
|
||||
import { DEFAULT_USER_DATA } from "../support/const/user-data";
|
||||
import { DashboardPage } from "../support/pages/dasboard-page";
|
||||
import { SetupPage } from "../support/pages/setup-page";
|
||||
|
||||
describe("user can create a new account on setup page", () => {
|
||||
before(() => {
|
||||
cy.visit("/setup");
|
||||
});
|
||||
|
||||
it("user can create new account", () => {
|
||||
cy.url().should("be.equal", SetupPage.url);
|
||||
actor.setupTask.fillAndSubmitSetupForm(
|
||||
DEFAULT_USER_DATA.username,
|
||||
DEFAULT_USER_DATA.password,
|
||||
DEFAULT_USER_DATA.password
|
||||
);
|
||||
|
||||
cy.url().should("be.equal", DashboardPage.url);
|
||||
cy.get('[role="alert"]')
|
||||
.should("be.visible")
|
||||
.and("contain.text", "Added Successfully.");
|
||||
});
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
import { SetupTask } from "../tasks/setup-task";
|
||||
|
||||
class Actor {
|
||||
setupTask: SetupTask = new SetupTask();
|
||||
}
|
||||
|
||||
const actor = new Actor();
|
||||
export { actor };
|
@ -0,0 +1,4 @@
|
||||
export const DEFAULT_USER_DATA = {
|
||||
username: "testuser",
|
||||
password: "testuser123",
|
||||
};
|
@ -0,0 +1 @@
|
||||
import "./commands";
|
@ -0,0 +1,3 @@
|
||||
export const DashboardPage = {
|
||||
url: Cypress.env("baseUrl") + "/dashboard",
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
export const SetupPage = {
|
||||
url: Cypress.env("baseUrl") + "/setup",
|
||||
usernameInput: '[data-cy="username-input"]',
|
||||
passWordInput: '[data-cy="password-input"]',
|
||||
passwordRepeatInput: '[data-cy="password-repeat-input"]',
|
||||
submitSetupForm: '[data-cy="submit-setup-form"]',
|
||||
};
|
@ -0,0 +1,15 @@
|
||||
import { SetupPage } from "../pages/setup-page";
|
||||
|
||||
export class SetupTask {
|
||||
fillAndSubmitSetupForm(
|
||||
username: string,
|
||||
password: string,
|
||||
passwordRepeat: string
|
||||
) {
|
||||
cy.get(SetupPage.usernameInput).type(username);
|
||||
cy.get(SetupPage.passWordInput).type(password);
|
||||
cy.get(SetupPage.passwordRepeatInput).type(passwordRepeat);
|
||||
|
||||
cy.get(SetupPage.submitSetupForm).click();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue