0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-01 09:31:26 -05:00

Merge pull request #1514 from penpot/enhacement/add-profile-e2e-tests

👷 Add e2e test to profile area
This commit is contained in:
Pablo Alba 2022-01-28 10:32:49 +01:00 committed by GitHub
commit 86c394f4ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 412 additions and 206 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

View file

@ -9,33 +9,31 @@
"use strict";
describe("account creation", () => {
let validUser
let validUser;
beforeEach(() => {
cy.fixture('validuser.json').then((user) => {
cy.fixture("validuser.json").then((user) => {
validUser = user;
});
cy.visit("http://localhost:3449/#/auth/login");
cy.get("a").contains("Create an account").click()
cy.getBySel("register-submit").click();
});
it("displays the account creation form", () => {
cy.get("input[type=submit]").contains("Create an account").should("exist");
cy.getBySel("register-form-submit").should("exist");
});
it("create an account of an existent email fails", () => {
cy.get("#email").type(validUser.email);
cy.get("#password").type("anewpassword");
cy.get("input[type=submit]").contains("Create an account").click();
cy.get(".error").should("contain", "Email already used")
cy.getBySel("register-form-submit").click();
cy.getBySel("email-input-error").should("exist");
});
it("can go back", () => {
cy.get("a").contains("Login here").click()
cy.contains("Great to see you again!").should("exist");
cy.getBySel("login-here-link").click();
cy.getBySel("login-title").should("exist");
cy.get("#email").should("exist");
cy.get("#password").should("exist");
});
});

View file

@ -10,13 +10,12 @@
describe("demo account", () => {
beforeEach(() => {
cy.visit("http://localhost:3449/#/auth/login");
cy.visit("http://localhost:3449/#/auth/login");
});
it.only("create demo account", () => {
cy.get("a").contains("Create demo account").click()
cy.get(".profile").contains("Demo User")
it("create demo account", () => {
cy.getBySel("demo-account-link").should("exist");
cy.getBySel("demo-account-link").click();
cy.get(".profile").contains("Demo User");
});
});

View file

@ -14,7 +14,7 @@ describe("login", () => {
});
it("displays the login form", () => {
cy.contains("Great to see you again!").should("exist");
cy.getBySel("login-title").should("exist");
cy.get("#email").should("exist");
cy.get("#password").should("exist");
});
@ -22,20 +22,17 @@ describe("login", () => {
it("can't login with an invalid user", () => {
cy.get("#email").type("bad@mail.com");
cy.get("#password").type("badpassword");
cy.get("input[type=submit]").first().click();
cy.get(".warning")
.should("exist")
.should("contain", "Username or password seems to be wrong.");
cy.getBySel("login-submit").click();
cy.getBySel("login-banner").should("exist");
});
it("can login with a valid user", () => {
cy.fixture('validuser.json').then((user) => {
cy.fixture("validuser.json").then((user) => {
cy.get("#email").type(user.email);
cy.get("#password").type(user.password);
});
cy.get("input[type=submit]").first().click();
cy.getBySel("login-submit").click();
cy.get(".dashboard-layout").should("exist");
});
});

View file

@ -11,36 +11,31 @@
describe("recover password", () => {
beforeEach(() => {
cy.visit("http://localhost:3449/#/auth/login");
cy.get("a").contains("Forgot password?").click()
cy.getBySel("forgot-password").click();
});
it("displays the recover form", () => {
cy.get("input[type=submit]").contains("Recover Password").should("exist");
cy.getBySel("recovery-resquest-submit").should("exist");
});
it("recover password with wrong mail works", () => {
cy.get("#email").type("bad@mail.com");
cy.get("input[type=submit]").contains("Recover Password").click();
cy.get(".info")
.should("exist")
.should("contain", "Password recovery link sent to your inbox.");
cy.getBySel("recovery-resquest-submit").click();
cy.get(".info").should("exist");
});
it("recover password with good mail works", () => {
cy.fixture('validuser.json').then((user) => {
cy.fixture("validuser.json").then((user) => {
cy.get("#email").type(user.email);
});
cy.get("input[type=submit]").contains("Recover Password").click();
cy.get(".info")
.should("exist")
.should("contain", "Password recovery link sent to your inbox.");
});
cy.getBySel("recovery-resquest-submit").click();
cy.get(".info").should("exist");
});
it("can go back", () => {
cy.get("a").contains("Go back").click()
cy.contains("Great to see you again!").should("exist");
cy.getBySel("go-back-link").click();
cy.getBySel("login-title").should("exist");
cy.get("#email").should("exist");
cy.get("#password").should("exist");
});
});

View file

@ -6,75 +6,50 @@
* Copyright (c) UXBOX Labs SL
*/
"use strict";
"use strict";
import {
checkOnboardingSlide,
goToSlideByNumber,
} from "../../support/utils.js";
describe("onboarding slides", () => {
beforeEach(() => {
describe("onboarding slides", () => {
beforeEach(() => {
cy.demoLogin();
});
it("go trough all the onboarding slides", () => {
cy.get(".modal-right").should("contain", "Welcome to Penpot");
cy.get(".modal-right button").should("contain", "Continue");
cy.get(".modal-right button").click();
cy.get(".onboarding").should("contain", "Open Source Contributor?")
cy.get(".onboarding .skip").should("not.exist");
cy.get(".onboarding button").should("contain", "Continue");
cy.get(".onboarding button").click();
cy.get(".onboarding").should("contain", "Design libraries, styles and components")
cy.get(".onboarding .skip").should("exist");
cy.get(".onboarding .step-dots").should("exist");
cy.get(".onboarding button").should("contain", "Continue");
cy.get(".onboarding button").click();
cy.get(".onboarding").should("contain", "Bring your designs to life with interactions")
cy.get(".onboarding .skip").should("exist");
cy.get(".onboarding .step-dots").should("exist");
cy.get(".onboarding button").should("contain", "Continue");
cy.get(".onboarding button").click();
cy.get(".onboarding").should("contain", "Get feedback, present and share your work")
cy.get(".onboarding .skip").should("exist");
cy.get(".onboarding .step-dots").should("exist");
cy.get(".onboarding button").should("contain", "Continue");
cy.get(".onboarding button").click();
cy.get(".onboarding").should("contain", "One shared source of truth")
cy.get(".onboarding .skip").should("not.exist");
cy.get(".onboarding .step-dots").should("exist");
cy.get(".onboarding button").should("contain", "Start");
cy.get(".onboarding button").click();
cy.get(".onboarding").should("contain", "Welcome to Penpot")
});
it("go to specific onboarding slides", () => {
cy.get(".modal-right button").click();
cy.get(".onboarding button").click();
cy.get(".step-dots li:nth-child(4)").click();
cy.get(".onboarding").should("contain", "One shared source of truth")
cy.get(".step-dots li:nth-child(3)").click();
cy.get(".onboarding").should("contain", "Get feedback, present and share your work")
cy.get(".step-dots li:nth-child(2)").click();
cy.get(".onboarding").should("contain", "Bring your designs to life with interactions")
cy.get(".step-dots li:nth-child(1)").click();
cy.get(".onboarding").should("contain", "Design libraries, styles and components")
});
it("skip onboarding slides", () => {
cy.get(".modal-right button").click();
cy.get(".onboarding button").click();
cy.get(".onboarding .skip").click();
it("go trough all the onboarding slides", () => {
cy.getBySel("onboarding-welcome").should("exist");
cy.getBySel("onboarding-next-btn").should("exist");
cy.getBySel("onboarding-next-btn").click();
cy.get(".onboarding").should("contain", "Welcome to Penpot")
cy.getBySel("opsource-next-btn").should("exist");
cy.getBySel("skip-btn").should("not.exist");
cy.getBySel("opsource-next-btn").click();
var genArr = Array.from(Array(3).keys());
cy.wrap(genArr).each((index) => {
checkOnboardingSlide(index, true);
});
checkOnboardingSlide("3", false);
cy.getBySel("onboarding-welcome-title").should("exist");
});
});
it("go to specific onboarding slides", () => {
cy.getBySel("onboarding-next-btn").click();
cy.getBySel(`opsource-next-btn`).click();
var genArr = Array.from(Array(4).keys());
cy.wrap(genArr).each((index) => {
goToSlideByNumber(4 - index);
});
});
it("skip onboarding slides", () => {
cy.getBySel("onboarding-next-btn").click();
cy.getBySel("opsource-next-btn").click();
cy.getBySel("skip-btn").click();
cy.getBySel("fly-solo-op").click();
cy.getBySel("onboarding-welcome-title").should("exist");
});
});

View file

@ -17,7 +17,7 @@
});
it("displays the projects page", () => {
cy.get(".dashboard-title").should("contain", "Projects");
cy.get(".dashboard-title").should("exist");
});
});

View file

@ -0,0 +1,155 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) UXBOX Labs SL
*/
"use strict";
describe("profile", () => {
beforeEach(() => {
cy.fixture("validuser.json").then((user) => {
cy.login(user.email, user.password);
});
});
it("open profile section", () => {
cy.get(".profile").click();
cy.getBySel("profile-profile-opt").should("exist");
cy.getBySel("profile-profile-opt").click();
cy.getBySel("account-title").should("exist");
});
it("change profile name", () => {
cy.get(".profile").click();
cy.getBySel("profile-profile-opt").click();
cy.get("#fullname").should("exist");
cy.get("#fullname").clear().type("New name").type("{enter}");
cy.get(".banner.success").should("exist");
});
it("change profile image with png", () => {
cy.get(".profile").click();
cy.getBySel("profile-profile-opt").click();
cy.getBySel("profile-image-input").should("exist");
cy.get(".profile img").then((oldImg) => {
cy.getBySel("profile-image-input").attachFile("test-image-png.png");
cy.get(".profile img")
.invoke("attr", "src")
.should("not.eq", oldImg[0].src);
});
});
it("change profile image with jpg", () => {
cy.get(".profile").click();
cy.getBySel("profile-profile-opt").click();
cy.getBySel("profile-image-input").should("exist");
cy.get(".profile img").then((oldImg) => {
cy.getBySel("profile-image-input").attachFile("test-image-jpg.jpg");
cy.get(".profile img")
.invoke("attr", "src")
.should("not.eq", oldImg[0].src);
});
});
it("change profile email", () => {
cy.get(".profile").click();
cy.getBySel("profile-profile-opt").click();
cy.get(".change-email").should("exist");
cy.get(".change-email").click();
cy.getBySel("change-email-title").should("exist");
cy.fixture("validuser.json").then((user) => {
cy.get("#email-1").type(user.email);
cy.get("#email-2").type(user.email);
});
cy.getBySel("change-email-submit").click();
cy.get(".banner.info").should("exist");
});
it("type wrong email while trying to update should throw an error", () => {
cy.get(".profile").click();
cy.getBySel("profile-profile-opt").click();
cy.get(".change-email").click();
cy.fixture("validuser.json").then((user) => {
cy.get("#email-1").type(user.email);
});
cy.get("#email-2").type("bad@email.com");
cy.getBySel("change-email-submit").click();
cy.get(".error").should("exist");
});
it("open password section", () => {
cy.get(".profile").click();
cy.getBySel("password-profile-opt").click();
cy.get(".password-form").should("exist");
});
it("type old password wrong should throw an error", () => {
cy.get(".profile").click();
cy.getBySel("password-profile-opt").click();
cy.get("#password-old").type("badpassword");
cy.get("#password-1").type("pretty-new-password");
cy.get("#password-2").type("pretty-new-password");
cy.getBySel("submit-password").click();
cy.get(".error").should("exist");
});
it("type same old password should work", () => {
cy.get(".profile").click();
cy.getBySel("password-profile-opt").click();
cy.fixture("validuser.json").then((user) => {
cy.get("#password-old").type(user.password);
cy.get("#password-1").type(user.password);
cy.get("#password-2").type(user.password);
});
cy.getBySel("submit-password").click();
cy.get(".banner.success").should("exist");
});
it("open settings section", () => {
cy.get(".profile").click();
cy.getBySel("profile-profile-opt").click();
cy.getBySel("settings-profile").should("exist");
});
it("set lang to Spanish and back to english", () => {
cy.get(".profile").click();
cy.getBySel("profile-profile-opt").click();
cy.getBySel("settings-profile").click();
cy.getBySel("setting-lang").should("exist");
cy.getBySel("setting-lang").select("es");
cy.getBySel("submit-lang-change").should("exist");
cy.getBySel("submit-lang-change").click();
cy.contains("Tu cuenta").should("exist");
cy.getBySel("setting-lang").select("en");
cy.getBySel("submit-lang-change").click();
cy.contains("Your account").should("exist");
});
it("log out from app", () => {
cy.get(".profile").click();
cy.getBySel("logout-profile-opt").should("exist");
cy.getBySel("logout-profile-opt").click();
cy.getBySel("login-title").should("exist");
});
});
describe("remove account", () => {
it("create demo account and delete it", () => {
cy.visit("http://localhost:3449/#/auth/login");
cy.getBySel("demo-account-link").click();
cy.getBySel("onboarding-next-btn").click();
cy.getBySel("opsource-next-btn").click();
cy.getBySel("skip-btn").click();
cy.getBySel("fly-solo-op").click();
cy.getBySel("close-templates-btn").click();
cy.get(".profile").click();
cy.getBySel("profile-profile-opt").click();
cy.getBySel("remove-acount-btn").click();
cy.getBySel("delete-account-btn").click();
cy.getBySel("login-title").should("exist");
});
});

View file

@ -6,64 +6,88 @@
* Copyright (c) UXBOX Labs SL
*/
"use strict";
"use strict";
describe("draw shapes", () => {
beforeEach(() => {
cy.fixture('validuser.json').then((user) => {
cy.login(user.email, user.password)
cy.get(".project-th").first().dblclick()
cy.clearViewport();
describe("draw shapes", () => {
beforeEach(() => {
cy.fixture("validuser.json").then((user) => {
cy.login(user.email, user.password);
cy.get(".project-th").first().dblclick();
cy.clearViewport();
});
});
it("draw an artboard", () => {
cy.get(".viewport-controls rect").should("not.exist");
cy.get(".left-toolbar-options li[alt='Artboard (A)']").click()
cy.drawInViewport(300, 300, 400, 450)
cy.get(".viewport-controls rect").first().as("artboard");
cy.get("@artboard").should("exist");
cy.get("@artboard").invoke('attr', 'width').should('eq', '100')
cy.get("@artboard").invoke('attr', 'height').should('eq', '150')
});
});
it("draw a square", () => {
it("draw an artboard", () => {
cy.get(".viewport-controls rect").should("not.exist");
cy.get(".left-toolbar-options li[alt='Rectangle (R)']").click()
cy.drawInViewport(300, 300, 400, 450)
cy.get(".left-toolbar-options li[alt='Artboard (A)']").click();
cy.drawInViewport(300, 300, 400, 450);
cy.get(".viewport-controls rect").first().as("artboard");
cy.get("@artboard").should("exist");
cy.get("@artboard").invoke("attr", "width").should("eq", "100");
cy.get("@artboard").invoke("attr", "height").should("eq", "150");
});
it("draw a square", () => {
cy.get(".viewport-controls rect").should("not.exist");
cy.get(".left-toolbar-options li[alt='Rectangle (R)']").click();
cy.drawInViewport(300, 300, 400, 450);
cy.get(".viewport-controls rect").should("exist");
cy.get(".viewport-controls rect").invoke('attr', 'width').should('eq', '100')
cy.get(".viewport-controls rect").invoke('attr', 'height').should('eq', '150')
cy.get(".viewport-controls rect")
.invoke("attr", "width")
.should("eq", "100");
cy.get(".viewport-controls rect")
.invoke("attr", "height")
.should("eq", "150");
});
it("draw an ellipse", () => {
cy.get(".viewport-controls ellipse").should("not.exist");
cy.get(".left-toolbar-options li[alt='Ellipse (E)']").click()
cy.drawInViewport(300, 300, 400, 450)
cy.get(".viewport-controls ellipse").as("ellipse")
cy.get(".left-toolbar-options li[alt='Ellipse (E)']").click();
cy.drawInViewport(300, 300, 400, 450);
cy.get(".viewport-controls ellipse").as("ellipse");
cy.get("@ellipse").should("exist");
cy.get("@ellipse").invoke('attr', 'rx').should('eq', '50')
cy.get("@ellipse").invoke('attr', 'ry').should('eq', '75')
cy.get("@ellipse").invoke("attr", "rx").should("eq", "50");
cy.get("@ellipse").invoke("attr", "ry").should("eq", "75");
});
it("draw a curve", () => {
cy.get(".viewport-controls path").should("not.exist");
cy.get(".left-toolbar-options li[alt='Curve (Shift+C)']").click()
cy.drawMultiInViewport([{x:300, y:300}, {x:350, y:300}, {x:300, y:350}, {x:400, y:450}])
cy.get(".viewport-controls path").as("curve")
cy.get(".left-toolbar-options li[alt='Curve (Shift+C)']").click();
cy.drawMultiInViewport([
{ x: 300, y: 300 },
{ x: 350, y: 300 },
{ x: 300, y: 350 },
{ x: 400, y: 450 },
]);
cy.get(".viewport-controls path").as("curve");
cy.get("@curve").should("exist");
cy.get("@curve").invoke('attr', 'd').should('eq', "M300,300L350,300L300,350L400,450")
cy.get("@curve")
.invoke("attr", "d")
.should("eq", "M300,300L350,300L300,350L400,450");
});
it("draw a path", () => {
cy.get(".viewport-controls path").should("not.exist");
cy.get(".left-toolbar-options li[alt='Path (P)']").click()
cy.clickMultiInViewport([{x:300, y:300}, {x:350, y:300}])
cy.drawMultiInViewport([{x:400, y:450}, {x:450, y:450}], true)
cy.clickMultiInViewport([{x:300, y:300}])
cy.get(".viewport-controls path").as("curve")
cy.get(".left-toolbar-options li[alt='Path (P)']").click();
cy.clickMultiInViewport([
{ x: 300, y: 300 },
{ x: 350, y: 300 },
]);
cy.drawMultiInViewport(
[
{ x: 400, y: 450 },
{ x: 450, y: 450 },
],
true
);
cy.clickMultiInViewport([{ x: 300, y: 300 }]);
cy.get(".viewport-controls path").as("curve");
cy.get("@curve").should("exist");
cy.get("@curve").invoke('attr', 'd').should('eq', "M300,300L350,300C350,300,350,450,400,450C450,450,300,300,300,300Z")
cy.get("@curve")
.invoke("attr", "d")
.should(
"eq",
"M300,300L350,300C350,300,350,450,400,450C450,450,300,300,300,300Z"
);
});
});
});

View file

@ -23,18 +23,18 @@
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
import 'cypress-file-upload';
Cypress.Commands.add('login', (email, password) => {
cy.visit("http://localhost:3449/#/auth/login");
cy.get("#email").type(email);
cy.get("#password").type(password);
cy.get("input[type=submit]").first().click();
cy.getBySel("login-submit").click();
})
Cypress.Commands.add('demoLogin', () => {
cy.visit("http://localhost:3449/#/auth/login");
cy.get("a").contains("Create demo account").click()
cy.getBySel("demo-account-link").click()
})
Cypress.Commands.add('drawInViewport', (x1, y1, x2, y2) => {
@ -89,4 +89,12 @@ Cypress.Commands.add('clearViewport', () => {
cy.get(".viewport-controls").type('{ctrl}a');
cy.get(".viewport-controls").type('{del}');
cy.window().its("debug").invoke('reset_viewport')
})
Cypress.Commands.add('getBySel', (selector, ...args) => {
return cy.get(`[data-test=${selector}]`, ...args)
})
Cypress.Commands.add('getBySelLike', (selector, ...args) => {
return cy.get(`[data-test*=${selector}]`, ...args)
})

View file

@ -0,0 +1,12 @@
export const checkOnboardingSlide = (number, checkSkip) => {
cy.getBySel(`slide-${number}-title`).should("exist");
if(checkSkip){cy.getBySel("skip-btn").should("exist");}
cy.get(".onboarding .step-dots").should("exist");
cy.getBySel(`slide-${number}-btn`).should("exist");
cy.getBySel(`slide-${number}-btn`).click();
};
export const goToSlideByNumber = (number) => {
cy.get(`.step-dots li:nth-child(${number})`).click();
cy.getBySel(`slide-${number -1}-btn`).should("exist");
};

View file

@ -26,6 +26,7 @@
"devDependencies": {
"autoprefixer": "^10.4.1",
"cypress": "^9.2.1",
"cypress-file-upload": "^5.0.8",
"gettext-parser": "^4.2.0",
"gulp": "4.0.2",
"gulp-concat": "^2.6.1",

View file

@ -91,7 +91,8 @@
[:& msgs/inline-banner
{:type :warning
:content message
:on-close #(reset! error nil)}])
:on-close #(reset! error nil)
:data-test "login-banner"}])
[:& fm/form {:on-submit on-submit :form form}
[:div.fields-row
@ -111,7 +112,8 @@
[:div.buttons-stack
[:& fm/submit-button
{:label (tr "auth.login-submit")}]
{:label (tr "auth.login-submit")
:data-test "login-submit"}]
(when (contains? @cf/flags :login-with-ldap)
[:& fm/submit-button
@ -149,7 +151,7 @@
[{:keys [params] :as props}]
[:div.generic-form.login-form
[:div.form-container
[:h1 (tr "auth.login-title")]
[:h1 {:data-test "login-title"} (tr "auth.login-title")]
[:div.subtitle (tr "auth.login-subtitle")]
[:& login-form {:params params}]
@ -163,18 +165,21 @@
[:div.links
[:div.link-entry
[:a {:on-click #(st/emit! (rt/nav :auth-recovery-request))}
[:a {:on-click #(st/emit! (rt/nav :auth-recovery-request))
:data-test "forgot-password"}
(tr "auth.forgot-password")]]
(when (contains? @cf/flags :registration)
[:div.link-entry
[:span (tr "auth.register") " "]
[:a {:on-click #(st/emit! (rt/nav :auth-register {} params))}
[:a {:on-click #(st/emit! (rt/nav :auth-register {} params))
:data-test "register-submit"}
(tr "auth.register-submit")]])]
(when (contains? @cf/flags :demo-users)
[:div.links.demo
[:div.link-entry
[:span (tr "auth.create-demo-profile") " "]
[:a {:on-click (st/emitf (du/create-demo-profile))}
[:a {:on-click (st/emitf (du/create-demo-profile))
:data-test "demo-account-link"}
(tr "auth.create-demo-account")]]])]])

View file

@ -67,7 +67,8 @@
:type "text"}]]
[:& fm/submit-button
{:label (tr "auth.recovery-request-submit")}]]))
{:label (tr "auth.recovery-request-submit")
:data-test "recovery-resquest-submit"}]]))
;; --- Recovery Request Page
@ -82,5 +83,6 @@
[:div.links
[:div.link-entry
[:a {:on-click #(st/emit! (rt/nav :auth-login))}
[:a {:on-click #(st/emit! (rt/nav :auth-login))
:data-test "go-back-link"}
(tr "labels.go-back")]]]]])

View file

@ -98,7 +98,8 @@
:name :email
:tab-index "2"
:help-icon i/at
:label (tr "auth.email")}]]
:label (tr "auth.email")
:data-test "email-input"}]]
[:div.fields-row
[:& fm/input {:name :password
:tab-index "3"
@ -108,12 +109,13 @@
[:& fm/submit-button
{:label (tr "auth.register-submit")
:disabled @submitted?}]]))
:disabled @submitted?
:data-test "register-form-submit"}]]))
(mf/defc register-page
[{:keys [params] :as props}]
[:div.form-container
[:h1 (tr "auth.register-title")]
[:h1 {:data-test "registration-title"} (tr "auth.register-title")]
[:div.subtitle (tr "auth.register-subtitle")]
(when (contains? @cf/flags :demo-warning)
@ -132,7 +134,8 @@
[:div.link-entry
[:span (tr "auth.already-have-account") " "]
[:a {:on-click #(st/emit! (rt/nav :auth-login {} params))
:tab-index "4"}
:tab-index "4"
:data-test "login-here-link"}
(tr "auth.login-here")]]
(when (contains? @cf/flags :demo-users)

View file

@ -12,7 +12,7 @@
(mf/defc file-uploader
{::mf/forward-ref true}
[{:keys [accept multi label-text label-class input-id on-selected] :as props} input-ref]
[{:keys [accept multi label-text label-class input-id on-selected data-test] :as props} input-ref]
(let [opt-pick-one #(if multi % (first %))
on-files-selected
@ -37,5 +37,6 @@
:accept accept
:type "file"
:ref input-ref
:on-change on-files-selected}]]))
:on-change on-files-selected
:data-test data-test}]]))

View file

@ -12,6 +12,7 @@
[app.util.forms :as fm]
[app.util.i18n :as i18n :refer [tr]]
[app.util.object :as obj]
[clojure.string]
[cuerdas.core :as str]
[rumext.alpha :as mf]))
@ -19,7 +20,7 @@
(def use-form fm/use-form)
(mf/defc input
[{:keys [label help-icon disabled form hint trim children] :as props}]
[{:keys [label help-icon disabled form hint trim children data-test] :as props}]
(let [input-type (get props :type "text")
input-name (get props :name)
more-classes (get props :class)
@ -112,7 +113,7 @@
help-icon'])
(cond
(and touched? (:message error))
[:span.error (tr (:message error))]
[:span.error {:data-test (clojure.string/join [data-test "-error"]) }(tr (:message error))]
(string? hint)
[:span.hint hint])]]))
@ -170,7 +171,7 @@
[:span.hint hint])]]))
(mf/defc select
[{:keys [options label form default] :as props
[{:keys [options label form default data-test] :as props
:or {default ""}}]
(let [input-name (get props :name)
@ -181,7 +182,8 @@
[:div.custom-select
[:select {:value value
:on-change on-change}
:on-change on-change
:data-test data-test}
(for [item options]
[:option {:key (:value item) :value (:value item)} (:label item)])]
@ -194,7 +196,7 @@
i/arrow-slide]]]))
(mf/defc submit-button
[{:keys [label form on-click disabled] :as props}]
[{:keys [label form on-click disabled data-test] :as props}]
(let [form (or form (mf/use-ctx form-ctx))]
[:input.btn-primary.btn-large
{:name "submit"
@ -202,6 +204,7 @@
:disabled (or (not (:valid @form)) (true? disabled))
:on-click on-click
:value label
:data-test data-test
:type "submit"}]))
(mf/defc form

View file

@ -501,25 +501,30 @@
(st/emit! section))))]
[:div.profile-section
[:div.profile {:on-click #(reset! show true)}
[:div.profile {:on-click #(reset! show true)
:data-test "profile-btn"}
[:img {:src photo}]
[:span (:fullname profile)]
[:& dropdown {:on-close #(reset! show false)
:show @show}
[:ul.dropdown
[:li {:on-click (partial on-click :settings-profile)}
[:li {:on-click (partial on-click :settings-profile)
:data-test "profile-profile-opt"}
[:span.icon i/user]
[:span.text (tr "labels.profile")]]
[:li {:on-click (partial on-click :settings-password)}
[:li {:on-click (partial on-click :settings-password)
:data-test "password-profile-opt"}
[:span.icon i/lock]
[:span.text (tr "labels.password")]]
[:li {:on-click #(on-click (du/logout) %)}
[:li {:on-click #(on-click (du/logout) %)
:data-test "logout-profile-opt"}
[:span.icon i/exit]
[:span.text (tr "labels.logout")]]
(when (contains? @cf/flags :user-feedback)
[:li.feedback {:on-click (partial on-click :settings-feedback)}
[:li.feedback {:on-click (partial on-click :settings-feedback)
:data-test "feedback-profile-opt"}
[:span.icon i/msg-info]
[:span.text (tr "labels.give-feedback")]
])]]]

View file

@ -15,7 +15,7 @@
[rumext.alpha :as mf]))
(mf/defc banner
[{:keys [type position status controls content actions on-close] :as props}]
[{:keys [type position status controls content actions on-close data-test] :as props}]
[:div.banner {:class (dom/classnames
:warning (= type :warning)
:error (= type :error)
@ -34,7 +34,8 @@
i/msg-error)]
[:div.content {:class (dom/classnames
:inline-actions (= controls :inline-actions)
:bottom-actions (= controls :bottom-actions))}
:bottom-actions (= controls :bottom-actions))
:data-test data-test}
content
(when (or (= controls :bottom-actions) (= controls :inline-actions))
[:div.actions
@ -59,7 +60,7 @@
(mf/defc inline-banner
{::mf/wrap [mf/memo]}
[{:keys [type content on-close actions] :as props}]
[{:keys [type content on-close actions data-test] :as props}]
[:& banner {:type type
:position :inline
:status :visible
@ -70,5 +71,6 @@
:none))
:content content
:on-close on-close
:actions actions}])
:actions actions
:data-test data-test}])

View file

@ -27,14 +27,14 @@
[:img {:src "images/login-on.jpg" :border "0" :alt (tr "onboarding.welcome.alt")}]]
[:div.modal-right
[:div.modal-title
[:h2 (tr "onboarding.welcome.title")]]
[:h2 {:data-test "onboarding-welcome"} (tr "onboarding.welcome.title")]]
[:span.release "Beta version " (:main @cf/version)]
[:div.modal-content
[:p (tr "onboarding.welcome.desc1")]
[:p (tr "onboarding.welcome.desc2")]
[:p (tr "onboarding.welcome.desc3")]]
[:div.modal-navigation
[:button.btn-secondary {:on-click next} (tr "labels.continue")]]]
[:button.btn-secondary {:on-click next :data-test "onboarding-next-btn"} (tr "labels.continue")]]]
[:img.deco {:src "images/deco-left.png" :border "0"}]
[:img.deco.right {:src "images/deco-right.png" :border "0"}]])
@ -55,7 +55,7 @@
"\u00A0"
(tr "onboarding.contrib.desc2.2")]]
[:div.modal-navigation
[:button.btn-secondary {:on-click next} (tr "labels.continue")]]]])
[:button.btn-secondary {:on-click next :data-test "opsource-next-btn"} (tr "labels.continue")]]]])
(defmulti render-slide :slide)
@ -67,13 +67,14 @@
[:img {:src "images/on-design.gif" :border "0" :alt (tr "onboarding.slide.0.alt")}]]
[:div.modal-right
[:div.modal-title
[:h2 (tr "onboarding.slide.0.title")]]
[:h2 {:data-test "slide-0-title"} (tr "onboarding.slide.0.title")]]
[:div.modal-content
[:p (tr "onboarding.slide.0.desc1")]
[:p (tr "onboarding.slide.0.desc2")]]
[:div.modal-navigation
[:button.btn-secondary {:on-click #(navigate 1)} (tr "labels.continue")]
[:span.skip {:on-click skip} (tr "labels.skip")]
[:button.btn-secondary {:on-click #(navigate 1)
:data-test "slide-0-btn"} (tr "labels.continue")]
[:span.skip {:on-click skip :data-test "skip-btn"} (tr "labels.skip")]
[:& rc/navigation-bullets
{:slide slide
:navigate navigate
@ -87,13 +88,14 @@
[:img {:src "images/on-proto.gif" :border "0" :alt (tr "onboarding.slide.1.alt")}]]
[:div.modal-right
[:div.modal-title
[:h2 (tr "onboarding.slide.1.title")]]
[:h2 {:data-test "slide-1-title"} (tr "onboarding.slide.1.title")]]
[:div.modal-content
[:p (tr "onboarding.slide.1.desc1")]
[:p (tr "onboarding.slide.1.desc2")]]
[:div.modal-navigation
[:button.btn-secondary {:on-click #(navigate 2)} (tr "labels.continue")]
[:span.skip {:on-click skip} (tr "labels.skip")]
[:button.btn-secondary {:on-click #(navigate 2)
:data-test "slide-1-btn"} (tr "labels.continue")]
[:span.skip {:on-click skip :data-test "skip-btn"} (tr "labels.skip")]
[:& rc/navigation-bullets
{:slide slide
:navigate navigate
@ -107,12 +109,13 @@
[:img {:src "images/on-feed.gif" :border "0" :alt (tr "onboarding.slide.2.alt")}]]
[:div.modal-right
[:div.modal-title
[:h2 (tr "onboarding.slide.2.title")]]
[:h2 {:data-test "slide-2-title"} (tr "onboarding.slide.2.title")]]
[:div.modal-content
[:p (tr "onboarding.slide.2.desc1")]]
[:div.modal-navigation
[:button.btn-secondary {:on-click #(navigate 3)} (tr "labels.continue")]
[:span.skip {:on-click skip} (tr "labels.skip")]
[:button.btn-secondary {:on-click #(navigate 3)
:data-test "slide-2-btn"} (tr "labels.continue")]
[:span.skip {:on-click skip :data-test "skip-btn"} (tr "labels.skip")]
[:& rc/navigation-bullets
{:slide slide
:navigate navigate
@ -126,12 +129,13 @@
[:img {:src "images/on-handoff.gif" :border "0" :alt (tr "onboarding.slide.3.alt")}]]
[:div.modal-right
[:div.modal-title
[:h2 (tr "onboarding.slide.3.title")]]
[:h2 {:data-test "slide-3-title"} (tr "onboarding.slide.3.title")]]
[:div.modal-content
[:p (tr "onboarding.slide.3.desc1")]
[:p (tr "onboarding.slide.3.desc2")]]
[:div.modal-navigation
[:button.btn-secondary {:on-click skip} (tr "labels.start")]
[:button.btn-secondary {:on-click skip
:data-test "slide-3-btn"} (tr "labels.start")]
[:& rc/navigation-bullets
{:slide slide
:navigate navigate

View file

@ -42,11 +42,12 @@
[:div.modal-overlay
[:div.modal-container.onboarding.final.animated.fadeInUp
[:div.modal-top
[:h1 (tr "onboarding.welcome.title")]
[:h1 {:data-test "onboarding-welcome-title"} (tr "onboarding.welcome.title")]
[:p (tr "onboarding.welcome.desc3")]]
[:div.modal-columns
[:div.modal-left
[:div.content-button {:on-click on-fly-solo}
[:div.content-button {:on-click on-fly-solo
:data-test "fly-solo-op"}
[:h2 (tr "onboarding.choice.fly-solo")]
[:p (tr "onboarding.choice.fly-solo-desc")]]]
[:div.modal-right

View file

@ -70,7 +70,8 @@
[:div.modal-container.onboarding-templates
[:div.modal-header
[:div.modal-close-button
{:on-click close-fn} i/close]]
{:on-click close-fn
:data-test "close-templates-btn"} i/close]]
[:div.modal-content
[:h3 (tr "onboarding.templates.title")]

View file

@ -22,7 +22,7 @@
[]
[:header.dashboard-header
[:div.dashboard-title
[:h1 (tr "dashboard.your-account-title")]]])
[:h1 {:data-test "account-title"} (tr "dashboard.your-account-title")]]])
(mf/defc settings
[{:keys [route] :as props}]

View file

@ -86,7 +86,8 @@
[:div.modal-header
[:div.modal-header-title
[:h2 (tr "modals.change-email.title")]]
[:h2 {:data-test "change-email-title"}
(tr "modals.change-email.title")]]
[:div.modal-close-button
{:on-click on-close} i/close]]
@ -108,7 +109,7 @@
:trim true}]]]]
[:div.modal-footer
[:div.action-buttons
[:div.action-buttons {:data-test "change-email-submit"}
[:& fm/submit-button
{:label (tr "modals.change-email.submit")}]]]]]]))

View file

@ -51,7 +51,8 @@
[:div.modal-footer
[:div.action-buttons
[:button.btn-warning.btn-large {:on-click on-accept}
[:button.btn-warning.btn-large {:on-click on-accept
:data-test "delete-account-btn"}
(tr "modals.delete-account.confirm")]
[:button.btn-secondary.btn-large {:on-click on-close}
(tr "modals.delete-account.cancel")]]]]]))

View file

@ -48,20 +48,23 @@
[:h2 (t locale "labels.language")]
[:div.fields-row
[:& fm/select {:options (into [{:label "Auto (browser)" :value ""}]
[:& fm/select {:options (into [{:label "Auto (browser)" :value "default"}]
i18n/supported-locales)
:label (t locale "dashboard.select-ui-language")
:default ""
:name :lang}]]
:name :lang
:data-test "setting-lang"}]]
[:h2 (t locale "dashboard.theme-change")]
[:div.fields-row
[:& fm/select {:label (t locale "dashboard.select-ui-theme")
:name :theme
:default "default"
:options [{:label "Default" :value "default"}]}]]
:options [{:label "Default" :value "default"}]
:data-test "theme-lang"}]]
[:& fm/submit-button
{:label (t locale "dashboard.update-settings")}]]))
{:label (t locale "dashboard.update-settings")
:data-test "submit-lang-change"}]]))
;; --- Password Page
@ -72,4 +75,5 @@
[:div.dashboard-settings
[:div.form-container
{:data-test "settings-form"}
[:& options-form {:locale locale}]]])

View file

@ -89,7 +89,8 @@
:label (t locale "labels.confirm-password")}]]
[:& fm/submit-button
{:label (t locale "dashboard.update-settings")}]]))
{:label (t locale "dashboard.update-settings")
:data-test "submit-password"}]]))
;; --- Password Page

View file

@ -71,7 +71,8 @@
[:div.links
[:div.link-item
[:a {:on-click #(modal/show! :delete-account {})}
[:a {:on-click #(modal/show! :delete-account {})
:data-test "remove-acount-btn"}
(t locale "dashboard.remove-account")]]]]))
;; --- Profile Photo Form
@ -94,7 +95,8 @@
[:& file-uploader {:accept "image/jpeg,image/png"
:multi false
:ref file-input
:on-selected on-file-selected}]]]))
:on-selected on-file-selected
:data-test "profile-image-input"}]]]))
;; --- Profile Page

View file

@ -80,7 +80,8 @@
[:span.element-title (tr "labels.password")]]
[:li {:class (when options? "current")
:on-click go-settings-options}
:on-click go-settings-options
:data-test "settings-profile"}
i/tree
[:span.element-title (tr "labels.settings")]]

View file

@ -1404,6 +1404,11 @@ csstype@^3.0.2:
resolved "https://registry.npmjs.org/csstype/-/csstype-3.0.8.tgz"
integrity sha512-jXKhWqXPmlUeoQnF/EhTtTl4C9SnrxSH/jZUih3jmO6lBKr99rP3/+FmrMj4EFpOXzMtXHAZkd3x0E6h6Fgflw==
cypress-file-upload@^5.0.8:
version "5.0.8"
resolved "https://registry.yarnpkg.com/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz#d8824cbeaab798e44be8009769f9a6c9daa1b4a1"
integrity sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==
cypress@^9.2.1:
version "9.2.1"
resolved "https://registry.npmjs.org/cypress/-/cypress-9.2.1.tgz"