Rebrand to Syncfuse

This commit is contained in:
DinuraSellapperuma 2026-02-12 14:09:22 +05:30
parent 0a09df5470
commit 92025c9dba
144 changed files with 1796 additions and 1977 deletions

View file

@ -1,13 +1,13 @@
---
version: '3'
version: "3"
services:
umami:
syncfuse:
build: ../
#image: ghcr.io/umami-software/umami:postgresql-latest
ports:
- '3000:3000'
- "3000:3000"
environment:
DATABASE_URL: postgresql://umami:umami@db:5432/umami
DATABASE_URL: postgresql://syncfuse:syncfuse@db:5432/syncfuse
DATABASE_TYPE: postgresql
APP_SECRET: replace-me-with-a-random-string
depends_on:
@ -15,33 +15,33 @@ services:
condition: service_healthy
restart: always
healthcheck:
test: ['CMD-SHELL', 'curl http://localhost:3000/api/heartbeat']
test: ["CMD-SHELL", "curl http://localhost:3000/api/heartbeat"]
interval: 5s
timeout: 5s
retries: 5
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: umami
POSTGRES_USER: umami
POSTGRES_PASSWORD: umami
POSTGRES_DB: syncfuse
POSTGRES_USER: syncfuse
POSTGRES_PASSWORD: syncfuse
volumes:
- umami-db-data:/var/lib/postgresql/data
- syncfuse-db-data:/var/lib/postgresql/data
restart: always
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}']
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 5
cypress:
image: 'cypress/included:13.6.0'
image: "cypress/included:13.6.0"
depends_on:
- umami
- syncfuse
- db
environment:
- CYPRESS_baseUrl=http://umami:3000
- CYPRESS_umami_user=admin
- CYPRESS_umami_password=umami
- CYPRESS_baseUrl=http://syncfuse:3000
- CYPRESS_syncfuse_user=admin
- CYPRESS_syncfuse_password=syncfuse
volumes:
- ./tsconfig.json:/tsconfig.json
- ../cypress.config.ts:/cypress.config.ts
@ -49,4 +49,4 @@ services:
- ../node_modules/:/node_modules
- ../src/lib/crypto.ts:/src/lib/crypto.ts
volumes:
umami-db-data:
syncfuse-db-data:

View file

@ -1,191 +1,191 @@
describe('Team API tests', () => {
describe("Team API tests", () => {
Cypress.session.clearAllSavedSessions();
let teamId;
let userId;
before(() => {
cy.login(Cypress.env('umami_user'), Cypress.env('umami_password'));
cy.fixture('users').then(data => {
cy.login(Cypress.env("syncfuse_user"), Cypress.env("syncfuse_password"));
cy.fixture("users").then((data) => {
const userCreate = data.userCreate;
cy.request({
method: 'POST',
url: '/api/users',
method: "POST",
url: "/api/users",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: userCreate,
}).then(response => {
}).then((response) => {
userId = response.body.id;
expect(response.status).to.eq(200);
expect(response.body).to.have.property('username', 'cypress1');
expect(response.body).to.have.property('role', 'user');
expect(response.body).to.have.property("username", "cypress1");
expect(response.body).to.have.property("role", "user");
});
});
});
it('Creates a team.', () => {
cy.fixture('teams').then(data => {
it("Creates a team.", () => {
cy.fixture("teams").then((data) => {
const teamCreate = data.teamCreate;
cy.request({
method: 'POST',
url: '/api/teams',
method: "POST",
url: "/api/teams",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: teamCreate,
}).then(response => {
}).then((response) => {
teamId = response.body[0].id;
expect(response.status).to.eq(200);
expect(response.body[0]).to.have.property('name', 'cypress');
expect(response.body[1]).to.have.property('role', 'team-owner');
expect(response.body[0]).to.have.property("name", "cypress");
expect(response.body[1]).to.have.property("role", "team-owner");
});
});
});
it('Gets a teams by ID.', () => {
it("Gets a teams by ID.", () => {
cy.request({
method: 'GET',
method: "GET",
url: `/api/teams/${teamId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('id', teamId);
expect(response.body).to.have.property("id", teamId);
});
});
it('Updates a team.', () => {
cy.fixture('teams').then(data => {
it("Updates a team.", () => {
cy.fixture("teams").then((data) => {
const teamUpdate = data.teamUpdate;
cy.request({
method: 'POST',
method: "POST",
url: `/api/teams/${teamId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: teamUpdate,
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('id', teamId);
expect(response.body).to.have.property('name', 'cypressUpdate');
expect(response.body).to.have.property("id", teamId);
expect(response.body).to.have.property("name", "cypressUpdate");
});
});
});
it('Get all users that belong to a team.', () => {
it("Get all users that belong to a team.", () => {
cy.request({
method: 'GET',
method: "GET",
url: `/api/teams/${teamId}/users`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data[0]).to.have.property('id');
expect(response.body.data[0]).to.have.property('teamId');
expect(response.body.data[0]).to.have.property('userId');
expect(response.body.data[0]).to.have.property('user');
expect(response.body.data[0]).to.have.property("id");
expect(response.body.data[0]).to.have.property("teamId");
expect(response.body.data[0]).to.have.property("userId");
expect(response.body.data[0]).to.have.property("user");
});
});
it('Get a user belonging to a team.', () => {
it("Get a user belonging to a team.", () => {
cy.request({
method: 'GET',
url: `/api/teams/${teamId}/users/${Cypress.env('umami_user_id')}`,
method: "GET",
url: `/api/teams/${teamId}/users/${Cypress.env("syncfuse_user_id")}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('teamId');
expect(response.body).to.have.property('userId');
expect(response.body).to.have.property('role');
expect(response.body).to.have.property("teamId");
expect(response.body).to.have.property("userId");
expect(response.body).to.have.property("role");
});
});
it('Get all websites belonging to a team.', () => {
it("Get all websites belonging to a team.", () => {
cy.request({
method: 'GET',
method: "GET",
url: `/api/teams/${teamId}/websites`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('data');
expect(response.body).to.have.property("data");
});
});
it('Add a user to a team.', () => {
it("Add a user to a team.", () => {
cy.request({
method: 'POST',
method: "POST",
url: `/api/teams/${teamId}/users`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: {
userId,
role: 'team-member',
role: "team-member",
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('userId', userId);
expect(response.body).to.have.property('role', 'team-member');
expect(response.body).to.have.property("userId", userId);
expect(response.body).to.have.property("role", "team-member");
});
});
it(`Update a user's role on a team.`, () => {
cy.request({
method: 'POST',
method: "POST",
url: `/api/teams/${teamId}/users/${userId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: {
role: 'team-view-only',
role: "team-view-only",
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('userId', userId);
expect(response.body).to.have.property('role', 'team-view-only');
expect(response.body).to.have.property("userId", userId);
expect(response.body).to.have.property("role", "team-view-only");
});
});
it(`Remove a user from a team.`, () => {
cy.request({
method: 'DELETE',
method: "DELETE",
url: `/api/teams/${teamId}/users/${userId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
});
});
it('Deletes a team.', () => {
it("Deletes a team.", () => {
cy.request({
method: 'DELETE',
method: "DELETE",
url: `/api/teams/${teamId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('ok', true);
expect(response.body).to.have.property("ok", true);
});
});

View file

@ -1,125 +1,125 @@
describe('User API tests', () => {
describe("User API tests", () => {
Cypress.session.clearAllSavedSessions();
before(() => {
cy.login(Cypress.env('umami_user'), Cypress.env('umami_password'));
cy.login(Cypress.env("syncfuse_user"), Cypress.env("syncfuse_password"));
});
let userId;
it('Creates a user.', () => {
cy.fixture('users').then(data => {
it("Creates a user.", () => {
cy.fixture("users").then((data) => {
const userCreate = data.userCreate;
cy.request({
method: 'POST',
url: '/api/users',
method: "POST",
url: "/api/users",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: userCreate,
}).then(response => {
}).then((response) => {
userId = response.body.id;
expect(response.status).to.eq(200);
expect(response.body).to.have.property('username', 'cypress1');
expect(response.body).to.have.property('role', 'user');
expect(response.body).to.have.property("username", "cypress1");
expect(response.body).to.have.property("role", "user");
});
});
});
it('Returns all users. Admin access is required.', () => {
it("Returns all users. Admin access is required.", () => {
cy.request({
method: 'GET',
url: '/api/admin/users',
method: "GET",
url: "/api/admin/users",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data[0]).to.have.property('id');
expect(response.body.data[0]).to.have.property('username');
expect(response.body.data[0]).to.have.property('password');
expect(response.body.data[0]).to.have.property('role');
expect(response.body.data[0]).to.have.property("id");
expect(response.body.data[0]).to.have.property("username");
expect(response.body.data[0]).to.have.property("password");
expect(response.body.data[0]).to.have.property("role");
});
});
it('Updates a user.', () => {
cy.fixture('users').then(data => {
it("Updates a user.", () => {
cy.fixture("users").then((data) => {
const userUpdate = data.userUpdate;
cy.request({
method: 'POST',
method: "POST",
url: `/api/users/${userId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: userUpdate,
}).then(response => {
}).then((response) => {
userId = response.body.id;
expect(response.status).to.eq(200);
expect(response.body).to.have.property('id', userId);
expect(response.body).to.have.property('username', 'cypress1');
expect(response.body).to.have.property('role', 'view-only');
expect(response.body).to.have.property("id", userId);
expect(response.body).to.have.property("username", "cypress1");
expect(response.body).to.have.property("role", "view-only");
});
});
});
it('Gets a user by ID.', () => {
it("Gets a user by ID.", () => {
cy.request({
method: 'GET',
method: "GET",
url: `/api/users/${userId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('id', userId);
expect(response.body).to.have.property('username', 'cypress1');
expect(response.body).to.have.property('role', 'view-only');
expect(response.body).to.have.property("id", userId);
expect(response.body).to.have.property("username", "cypress1");
expect(response.body).to.have.property("role", "view-only");
});
});
it('Deletes a user.', () => {
it("Deletes a user.", () => {
cy.request({
method: 'DELETE',
method: "DELETE",
url: `/api/users/${userId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('ok', true);
expect(response.body).to.have.property("ok", true);
});
});
it('Gets all websites that belong to a user.', () => {
it("Gets all websites that belong to a user.", () => {
cy.request({
method: 'GET',
method: "GET",
url: `/api/users/${userId}/websites`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('data');
expect(response.body).to.have.property("data");
});
});
it('Gets all teams that belong to a user.', () => {
it("Gets all teams that belong to a user.", () => {
cy.request({
method: 'GET',
method: "GET",
url: `/api/users/${userId}/teams`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('data');
expect(response.body).to.have.property("data");
});
});
});

View file

@ -1,194 +1,194 @@
import { uuid } from '../../src/lib/crypto';
import { uuid } from "../../src/lib/crypto";
describe('Website API tests', () => {
describe("Website API tests", () => {
Cypress.session.clearAllSavedSessions();
let websiteId;
let teamId;
before(() => {
cy.login(Cypress.env('umami_user'), Cypress.env('umami_password'));
cy.fixture('teams').then(data => {
cy.login(Cypress.env("syncfuse_user"), Cypress.env("syncfuse_password"));
cy.fixture("teams").then((data) => {
const teamCreate = data.teamCreate;
cy.request({
method: 'POST',
url: '/api/teams',
method: "POST",
url: "/api/teams",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: teamCreate,
}).then(response => {
}).then((response) => {
teamId = response.body[0].id;
expect(response.status).to.eq(200);
expect(response.body[0]).to.have.property('name', 'cypress');
expect(response.body[1]).to.have.property('role', 'team-owner');
expect(response.body[0]).to.have.property("name", "cypress");
expect(response.body[1]).to.have.property("role", "team-owner");
});
});
});
it('Creates a website for user.', () => {
cy.fixture('websites').then(data => {
it("Creates a website for user.", () => {
cy.fixture("websites").then((data) => {
const websiteCreate = data.websiteCreate;
cy.request({
method: 'POST',
url: '/api/websites',
method: "POST",
url: "/api/websites",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: websiteCreate,
}).then(response => {
}).then((response) => {
websiteId = response.body.id;
expect(response.status).to.eq(200);
expect(response.body).to.have.property('name', 'Cypress Website');
expect(response.body).to.have.property('domain', 'cypress.com');
expect(response.body).to.have.property("name", "Cypress Website");
expect(response.body).to.have.property("domain", "cypress.com");
});
});
});
it('Creates a website for team.', () => {
it("Creates a website for team.", () => {
cy.request({
method: 'POST',
url: '/api/websites',
method: "POST",
url: "/api/websites",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: {
name: 'Team Website',
domain: 'teamwebsite.com',
name: "Team Website",
domain: "teamwebsite.com",
teamId: teamId,
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('name', 'Team Website');
expect(response.body).to.have.property('domain', 'teamwebsite.com');
expect(response.body).to.have.property("name", "Team Website");
expect(response.body).to.have.property("domain", "teamwebsite.com");
});
});
it('Creates a website with a fixed ID.', () => {
cy.fixture('websites').then(data => {
it("Creates a website with a fixed ID.", () => {
cy.fixture("websites").then((data) => {
const websiteCreate = data.websiteCreate;
const fixedId = uuid();
cy.request({
method: 'POST',
url: '/api/websites',
method: "POST",
url: "/api/websites",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: { ...websiteCreate, id: fixedId },
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('id', fixedId);
expect(response.body).to.have.property('name', 'Cypress Website');
expect(response.body).to.have.property('domain', 'cypress.com');
expect(response.body).to.have.property("id", fixedId);
expect(response.body).to.have.property("name", "Cypress Website");
expect(response.body).to.have.property("domain", "cypress.com");
// cleanup
cy.request({
method: 'DELETE',
method: "DELETE",
url: `/api/websites/${fixedId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
});
});
});
});
it('Returns all tracked websites.', () => {
it("Returns all tracked websites.", () => {
cy.request({
method: 'GET',
url: '/api/websites',
method: "GET",
url: "/api/websites",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data[0]).to.have.property('id');
expect(response.body.data[0]).to.have.property('name');
expect(response.body.data[0]).to.have.property('domain');
expect(response.body.data[0]).to.have.property("id");
expect(response.body.data[0]).to.have.property("name");
expect(response.body.data[0]).to.have.property("domain");
});
});
it('Gets a website by ID.', () => {
it("Gets a website by ID.", () => {
cy.request({
method: 'GET',
method: "GET",
url: `/api/websites/${websiteId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('name', 'Cypress Website');
expect(response.body).to.have.property('domain', 'cypress.com');
expect(response.body).to.have.property("name", "Cypress Website");
expect(response.body).to.have.property("domain", "cypress.com");
});
});
it('Updates a website.', () => {
cy.fixture('websites').then(data => {
it("Updates a website.", () => {
cy.fixture("websites").then((data) => {
const websiteUpdate = data.websiteUpdate;
cy.request({
method: 'POST',
method: "POST",
url: `/api/websites/${websiteId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: websiteUpdate,
}).then(response => {
}).then((response) => {
websiteId = response.body.id;
expect(response.status).to.eq(200);
expect(response.body).to.have.property('name', 'Cypress Website Updated');
expect(response.body).to.have.property('domain', 'cypressupdated.com');
expect(response.body).to.have.property("name", "Cypress Website Updated");
expect(response.body).to.have.property("domain", "cypressupdated.com");
});
});
});
it('Updates a website with only shareId.', () => {
it("Updates a website with only shareId.", () => {
cy.request({
method: 'POST',
method: "POST",
url: `/api/websites/${websiteId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: { shareId: 'ABCDEF' },
}).then(response => {
body: { shareId: "ABCDEF" },
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('shareId', 'ABCDEF');
expect(response.body).to.have.property("shareId", "ABCDEF");
});
});
it('Resets a website by removing all data related to the website.', () => {
it("Resets a website by removing all data related to the website.", () => {
cy.request({
method: 'POST',
method: "POST",
url: `/api/websites/${websiteId}/reset`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('ok', true);
expect(response.body).to.have.property("ok", true);
});
});
it('Deletes a website.', () => {
it("Deletes a website.", () => {
cy.request({
method: 'DELETE',
method: "DELETE",
url: `/api/websites/${websiteId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.body).to.have.property('ok', true);
expect(response.body).to.have.property("ok", true);
});
});

View file

@ -1,36 +1,34 @@
describe('Login tests', () => {
describe("Login tests", () => {
beforeEach(() => {
cy.visit('/login');
cy.visit("/login");
});
it(
'logs user in with correct credentials and logs user out',
"logs user in with correct credentials and logs user out",
{
defaultCommandTimeout: 10000,
},
() => {
cy.getDataTest('input-username').find('input').as('inputUsername').click();
cy.get('@inputUsername').type(Cypress.env('umami_user'), { delay: 0 });
cy.get('@inputUsername').click();
cy.getDataTest('input-password')
.find('input')
.type(Cypress.env('umami_password'), { delay: 0 });
cy.getDataTest('button-submit').click();
cy.url().should('eq', Cypress.config().baseUrl + '/dashboard');
cy.getDataTest("input-username").find("input").as("inputUsername").click();
cy.get("@inputUsername").type(Cypress.env("syncfuse_user"), { delay: 0 });
cy.get("@inputUsername").click();
cy.getDataTest("input-password").find("input").type(Cypress.env("syncfuse_password"), { delay: 0 });
cy.getDataTest("button-submit").click();
cy.url().should("eq", Cypress.config().baseUrl + "/dashboard");
cy.logout();
},
);
it('login with blank inputs or incorrect credentials', () => {
cy.getDataTest('button-submit').click();
cy.contains(/Required/i).should('be.visible');
it("login with blank inputs or incorrect credentials", () => {
cy.getDataTest("button-submit").click();
cy.contains(/Required/i).should("be.visible");
cy.getDataTest('input-username').find('input').as('inputUsername');
cy.get('@inputUsername').click();
cy.get('@inputUsername').type(Cypress.env('umami_user'), { delay: 0 });
cy.get('@inputUsername').click();
cy.getDataTest('input-password').find('input').type('wrongpassword', { delay: 0 });
cy.getDataTest('button-submit').click();
cy.contains(/Incorrect username and\/or password./i).should('be.visible');
cy.getDataTest("input-username").find("input").as("inputUsername");
cy.get("@inputUsername").click();
cy.get("@inputUsername").type(Cypress.env("syncfuse_user"), { delay: 0 });
cy.get("@inputUsername").click();
cy.getDataTest("input-password").find("input").type("wrongpassword", { delay: 0 });
cy.getDataTest("button-submit").click();
cy.contains(/Incorrect username and\/or password./i).should("be.visible");
});
});

View file

@ -1,65 +1,65 @@
describe('User tests', () => {
describe("User tests", () => {
Cypress.session.clearAllSavedSessions();
beforeEach(() => {
cy.login(Cypress.env('umami_user'), Cypress.env('umami_password'));
cy.visit('/settings/users');
cy.login(Cypress.env("syncfuse_user"), Cypress.env("syncfuse_password"));
cy.visit("/settings/users");
});
it('Add a User', () => {
it("Add a User", () => {
// add user
cy.contains(/Create user/i).should('be.visible');
cy.getDataTest('button-create-user').click();
cy.getDataTest('input-username').find('input').as('inputName').click();
cy.get('@inputName').type('Test-user', { delay: 0 });
cy.getDataTest('input-password').find('input').as('inputPassword').click();
cy.get('@inputPassword').type('testPasswordCypress', { delay: 0 });
cy.getDataTest('dropdown-role').click();
cy.getDataTest('dropdown-item-user').click();
cy.getDataTest('button-submit').click();
cy.get('td[label="Username"]').should('contain.text', 'Test-user');
cy.get('td[label="Role"]').should('contain.text', 'User');
cy.contains(/Create user/i).should("be.visible");
cy.getDataTest("button-create-user").click();
cy.getDataTest("input-username").find("input").as("inputName").click();
cy.get("@inputName").type("Test-user", { delay: 0 });
cy.getDataTest("input-password").find("input").as("inputPassword").click();
cy.get("@inputPassword").type("testPasswordCypress", { delay: 0 });
cy.getDataTest("dropdown-role").click();
cy.getDataTest("dropdown-item-user").click();
cy.getDataTest("button-submit").click();
cy.get('td[label="Username"]').should("contain.text", "Test-user");
cy.get('td[label="Role"]').should("contain.text", "User");
});
it('Edit a User role and password', () => {
it("Edit a User role and password", () => {
// edit user
cy.get('table tbody tr')
.contains('td', /Test-user/i)
cy.get("table tbody tr")
.contains("td", /Test-user/i)
.parent()
.within(() => {
cy.getDataTest('link-button-edit').click(); // Clicks the button inside the row
cy.getDataTest("link-button-edit").click(); // Clicks the button inside the row
});
cy.getDataTest('input-password').find('input').as('inputPassword').click();
cy.get('@inputPassword').type('newPassword', { delay: 0 });
cy.getDataTest('dropdown-role').click();
cy.getDataTest('dropdown-item-viewOnly').click();
cy.getDataTest('button-submit').click();
cy.getDataTest("input-password").find("input").as("inputPassword").click();
cy.get("@inputPassword").type("newPassword", { delay: 0 });
cy.getDataTest("dropdown-role").click();
cy.getDataTest("dropdown-item-viewOnly").click();
cy.getDataTest("button-submit").click();
cy.visit('/settings/users');
cy.get('table tbody tr')
.contains('td', /Test-user/i)
cy.visit("/settings/users");
cy.get("table tbody tr")
.contains("td", /Test-user/i)
.parent()
.should('contain.text', 'View only');
.should("contain.text", "View only");
cy.logout();
cy.url().should('eq', Cypress.config().baseUrl + '/login');
cy.getDataTest('input-username').find('input').as('inputUsername').click();
cy.get('@inputUsername').type('Test-user', { delay: 0 });
cy.get('@inputUsername').click();
cy.getDataTest('input-password').find('input').type('newPassword', { delay: 0 });
cy.getDataTest('button-submit').click();
cy.url().should('eq', Cypress.config().baseUrl + '/dashboard');
cy.url().should("eq", Cypress.config().baseUrl + "/login");
cy.getDataTest("input-username").find("input").as("inputUsername").click();
cy.get("@inputUsername").type("Test-user", { delay: 0 });
cy.get("@inputUsername").click();
cy.getDataTest("input-password").find("input").type("newPassword", { delay: 0 });
cy.getDataTest("button-submit").click();
cy.url().should("eq", Cypress.config().baseUrl + "/dashboard");
});
it('Delete a user', () => {
it("Delete a user", () => {
// delete user
cy.get('table tbody tr')
.contains('td', /Test-user/i)
cy.get("table tbody tr")
.contains("td", /Test-user/i)
.parent()
.within(() => {
cy.getDataTest('button-delete').click(); // Clicks the button inside the row
cy.getDataTest("button-delete").click(); // Clicks the button inside the row
});
cy.contains(/Are you sure you want to delete Test-user?/i).should('be.visible');
cy.getDataTest('button-confirm').click();
cy.contains(/Are you sure you want to delete Test-user?/i).should("be.visible");
cy.getDataTest("button-confirm").click();
});
});

View file

@ -1,89 +1,89 @@
describe('Website tests', () => {
describe("Website tests", () => {
Cypress.session.clearAllSavedSessions();
beforeEach(() => {
cy.login(Cypress.env('umami_user'), Cypress.env('umami_password'));
cy.login(Cypress.env("syncfuse_user"), Cypress.env("syncfuse_password"));
});
it('Add a website', () => {
it("Add a website", () => {
// add website
cy.visit('/settings/websites');
cy.getDataTest('button-website-add').click();
cy.contains(/Add website/i).should('be.visible');
cy.getDataTest('input-name').find('input').as('inputUsername').click();
cy.getDataTest('input-name').find('input').type('Add test', { delay: 0 });
cy.getDataTest('input-domain').find('input').click();
cy.getDataTest('input-domain').find('input').type('addtest.com', { delay: 0 });
cy.getDataTest('button-submit').click();
cy.get('td[label="Name"]').should('contain.text', 'Add test');
cy.get('td[label="Domain"]').should('contain.text', 'addtest.com');
cy.visit("/settings/websites");
cy.getDataTest("button-website-add").click();
cy.contains(/Add website/i).should("be.visible");
cy.getDataTest("input-name").find("input").as("inputUsername").click();
cy.getDataTest("input-name").find("input").type("Add test", { delay: 0 });
cy.getDataTest("input-domain").find("input").click();
cy.getDataTest("input-domain").find("input").type("addtest.com", { delay: 0 });
cy.getDataTest("button-submit").click();
cy.get('td[label="Name"]').should("contain.text", "Add test");
cy.get('td[label="Domain"]').should("contain.text", "addtest.com");
// clean-up data
cy.getDataTest('link-button-edit').first().click();
cy.contains(/Details/i).should('be.visible');
cy.getDataTest('text-field-websiteId')
.find('input')
.then($input => {
cy.getDataTest("link-button-edit").first().click();
cy.contains(/Details/i).should("be.visible");
cy.getDataTest("text-field-websiteId")
.find("input")
.then(($input) => {
const websiteId = $input[0].value;
cy.deleteWebsite(websiteId);
});
cy.visit('/settings/websites');
cy.contains(/Add test/i).should('not.exist');
cy.visit("/settings/websites");
cy.contains(/Add test/i).should("not.exist");
});
it('Edit a website', () => {
it("Edit a website", () => {
// prep data
cy.addWebsite('Update test', 'updatetest.com');
cy.visit('/settings/websites');
cy.addWebsite("Update test", "updatetest.com");
cy.visit("/settings/websites");
// edit website
cy.getDataTest('link-button-edit').first().click();
cy.contains(/Details/i).should('be.visible');
cy.getDataTest('input-name').find('input').click();
cy.getDataTest('input-name').find('input').clear();
cy.getDataTest('input-name').find('input').type('Updated website', { delay: 0 });
cy.getDataTest('input-domain').find('input').click();
cy.getDataTest('input-domain').find('input').clear();
cy.getDataTest('input-domain').find('input').type('updatedwebsite.com', { delay: 0 });
cy.getDataTest('button-submit').click({ force: true });
cy.getDataTest('input-name').find('input').should('have.value', 'Updated website');
cy.getDataTest('input-domain').find('input').should('have.value', 'updatedwebsite.com');
cy.getDataTest("link-button-edit").first().click();
cy.contains(/Details/i).should("be.visible");
cy.getDataTest("input-name").find("input").click();
cy.getDataTest("input-name").find("input").clear();
cy.getDataTest("input-name").find("input").type("Updated website", { delay: 0 });
cy.getDataTest("input-domain").find("input").click();
cy.getDataTest("input-domain").find("input").clear();
cy.getDataTest("input-domain").find("input").type("updatedwebsite.com", { delay: 0 });
cy.getDataTest("button-submit").click({ force: true });
cy.getDataTest("input-name").find("input").should("have.value", "Updated website");
cy.getDataTest("input-domain").find("input").should("have.value", "updatedwebsite.com");
// verify tracking script
cy.get('div')
cy.get("div")
.contains(/Tracking code/i)
.click();
cy.get('textarea').should('contain.text', Cypress.config().baseUrl + '/script.js');
cy.get("textarea").should("contain.text", Cypress.config().baseUrl + "/script.js");
// clean-up data
cy.get('div')
cy.get("div")
.contains(/Details/i)
.click();
cy.contains(/Details/i).should('be.visible');
cy.getDataTest('text-field-websiteId')
.find('input')
.then($input => {
cy.contains(/Details/i).should("be.visible");
cy.getDataTest("text-field-websiteId")
.find("input")
.then(($input) => {
const websiteId = $input[0].value;
cy.deleteWebsite(websiteId);
});
cy.visit('/settings/websites');
cy.contains(/Add test/i).should('not.exist');
cy.visit("/settings/websites");
cy.contains(/Add test/i).should("not.exist");
});
it('Delete a website', () => {
it("Delete a website", () => {
// prep data
cy.addWebsite('Delete test', 'deletetest.com');
cy.visit('/settings/websites');
cy.addWebsite("Delete test", "deletetest.com");
cy.visit("/settings/websites");
// delete website
cy.getDataTest('link-button-edit').first().click();
cy.contains(/Data/i).should('be.visible');
cy.get('div').contains(/Data/i).click();
cy.contains(/All website data will be deleted./i).should('be.visible');
cy.getDataTest('button-delete').click();
cy.contains(/Type DELETE in the box below to confirm./i).should('be.visible');
cy.get('input[name="confirm"').type('DELETE');
cy.getDataTest("link-button-edit").first().click();
cy.contains(/Data/i).should("be.visible");
cy.get("div").contains(/Data/i).click();
cy.contains(/All website data will be deleted./i).should("be.visible");
cy.getDataTest("button-delete").click();
cy.contains(/Type DELETE in the box below to confirm./i).should("be.visible");
cy.get('input[name="confirm"').type("DELETE");
cy.get('button[type="submit"]').click();
cy.contains(/Delete test/i).should('not.exist');
cy.contains(/Delete test/i).should("not.exist");
});
});

View file

@ -1,123 +1,123 @@
/// <reference types="cypress" />
import { uuid } from '../../src/lib/crypto';
import { uuid } from "../../src/lib/crypto";
Cypress.Commands.add('getDataTest', (value: string) => {
Cypress.Commands.add("getDataTest", (value: string) => {
return cy.get(`[data-test=${value}]`);
});
Cypress.Commands.add('logout', () => {
cy.getDataTest('button-profile').click();
cy.getDataTest('item-logout').click();
cy.url().should('eq', Cypress.config().baseUrl + '/login');
Cypress.Commands.add("logout", () => {
cy.getDataTest("button-profile").click();
cy.getDataTest("item-logout").click();
cy.url().should("eq", Cypress.config().baseUrl + "/login");
});
Cypress.Commands.add('login', (username: string, password: string) => {
Cypress.Commands.add("login", (username: string, password: string) => {
cy.session([username, password], () => {
cy.request({
method: 'POST',
url: '/api/auth/login',
method: "POST",
url: "/api/auth/login",
body: {
username,
password,
},
})
.then(response => {
Cypress.env('authorization', `bearer ${response.body.token}`);
window.localStorage.setItem('umami.auth', JSON.stringify(response.body.token));
.then((response) => {
Cypress.env("authorization", `bearer ${response.body.token}`);
window.localStorage.setItem("syncfuse.auth", JSON.stringify(response.body.token));
})
.its('status')
.should('eq', 200);
.its("status")
.should("eq", 200);
});
});
Cypress.Commands.add('addWebsite', (name: string, domain: string) => {
Cypress.Commands.add("addWebsite", (name: string, domain: string) => {
cy.request({
method: 'POST',
url: '/api/websites',
method: "POST",
url: "/api/websites",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: {
id: uuid(),
createdBy: '41e2b680-648e-4b09-bcd7-3e2b10c06264',
createdBy: "41e2b680-648e-4b09-bcd7-3e2b10c06264",
name: name,
domain: domain,
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
});
});
Cypress.Commands.add('deleteWebsite', (websiteId: string) => {
Cypress.Commands.add("deleteWebsite", (websiteId: string) => {
cy.request({
method: 'DELETE',
method: "DELETE",
url: `/api/websites/${websiteId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
});
});
Cypress.Commands.add('addUser', (username: string, password: string, role: string) => {
Cypress.Commands.add("addUser", (username: string, password: string, role: string) => {
cy.request({
method: 'POST',
url: '/api/users',
method: "POST",
url: "/api/users",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: {
username: username,
password: password,
role: role,
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
});
});
Cypress.Commands.add('deleteUser', (userId: string) => {
Cypress.Commands.add("deleteUser", (userId: string) => {
cy.request({
method: 'DELETE',
method: "DELETE",
url: `/api/users/${userId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
});
});
Cypress.Commands.add('addTeam', (name: string) => {
Cypress.Commands.add("addTeam", (name: string) => {
cy.request({
method: 'POST',
url: '/api/teams',
method: "POST",
url: "/api/teams",
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
body: {
name: name,
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
});
});
Cypress.Commands.add('deleteTeam', (teamId: string) => {
Cypress.Commands.add("deleteTeam", (teamId: string) => {
cy.request({
method: 'DELETE',
method: "DELETE",
url: `/api/teams/${teamId}`,
headers: {
'Content-Type': 'application/json',
Authorization: Cypress.env('authorization'),
"Content-Type": "application/json",
Authorization: Cypress.env("authorization"),
},
}).then(response => {
}).then((response) => {
expect(response.status).to.eq(200);
});
});