diff --git a/cypress/e2e/login.cy.ts b/cypress/e2e/login.cy.ts
index 4bd6a6b7..5c833113 100644
--- a/cypress/e2e/login.cy.ts
+++ b/cypress/e2e/login.cy.ts
@@ -1,15 +1,11 @@
-describe('Login test', () => {
+describe('Login tests', () => {
it(
'logs user in with correct credentials and logs user out',
{
defaultCommandTimeout: 10000,
},
() => {
- cy.visit('/login');
- cy.dataCy('input-username').type(Cypress.env('umami_user'));
- cy.dataCy('input-password').type(Cypress.env('umami_password'));
- cy.dataCy('button-submit').click();
- cy.url().should('eq', Cypress.config().baseUrl + '/dashboard');
+ cy.login(Cypress.env('umami_user'), Cypress.env('umami_password'));
cy.dataCy('button-profile').click();
cy.dataCy('item-logout').click();
cy.url().should('eq', Cypress.config().baseUrl + '/login');
diff --git a/cypress/e2e/website.cy.ts b/cypress/e2e/website.cy.ts
new file mode 100644
index 00000000..86f703eb
--- /dev/null
+++ b/cypress/e2e/website.cy.ts
@@ -0,0 +1,37 @@
+describe('Website tests', () => {
+ beforeEach(() => {
+ cy.login(Cypress.env('umami_user'), Cypress.env('umami_password'));
+ cy.get('a[href="/settings"]').click();
+ cy.url().should('include', '/settings/websites');
+ });
+
+ it.skip('Add a website', () => {
+ cy.dataCy('button-website-add').click();
+ cy.contains(/Add website/i).should('be.visible');
+ cy.dataCy('input-name').click().type('Test Website', {
+ delay: 100,
+ });
+ cy.dataCy('input-domain').click().type('testwebsite.com');
+ cy.dataCy('button-submit').click();
+ cy.get('td[label="Name"]').should('contain.text', 'Test Website');
+ cy.get('td[label="Domain"]').should('contain.text', 'testwebsite.com');
+ });
+
+ it('Test tracking script content', () => {
+ cy.dataCy('link-button-edit').first().click();
+ cy.contains(/Tracking code/i).should('be.visible');
+ cy.get('div')
+ .contains(/Tracking code/i)
+ .click();
+ cy.get('textarea').should('contain.text', Cypress.config().baseUrl + '/script2.js');
+ });
+
+ it('Test tracking script content', () => {
+ cy.dataCy('link-button-edit').first().click();
+ cy.contains(/Tracking code/i).should('be.visible');
+ cy.get('div')
+ .contains(/Tracking code/i)
+ .click();
+ cy.get('textarea').should('contain.text', Cypress.config().baseUrl + '/script.js');
+ });
+});
diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts
index 2ee2ed8e..faca6903 100644
--- a/cypress/support/e2e.ts
+++ b/cypress/support/e2e.ts
@@ -1,5 +1,24 @@
///
-Cypress.Commands.add('dataCy', value => {
+Cypress.Commands.add('dataCy', (value: string) => {
return cy.get(`[data-cy=${value}]`);
});
+
+Cypress.Commands.add('login', (username: string, password: string) => {
+ cy.session(
+ [username, password],
+ () => {
+ cy.visit('/login');
+ cy.dataCy('input-username').type(username);
+ cy.dataCy('input-password').type(password);
+ cy.dataCy('button-submit').click();
+ cy.url().should('eq', Cypress.config().baseUrl + '/dashboard');
+ },
+ {
+ validate: () => {
+ cy.visit('/profile');
+ },
+ },
+ );
+ cy.visit('/dashboard');
+});
diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts
index da94c844..1da81f1a 100644
--- a/cypress/support/index.d.ts
+++ b/cypress/support/index.d.ts
@@ -7,5 +7,10 @@ declare namespace Cypress {
* @example cy.dataCy('greeting')
*/
dataCy(value: string): Chainable>;
+ /**
+ * Custom command to login user into the app.
+ * @example cy.login('admin', 'password)
+ */
+ login(username: string, password: string): Chainable>;
}
}
diff --git a/src/app/(main)/settings/websites/WebsiteAddButton.tsx b/src/app/(main)/settings/websites/WebsiteAddButton.tsx
index 2c99f22b..5dd60b76 100644
--- a/src/app/(main)/settings/websites/WebsiteAddButton.tsx
+++ b/src/app/(main)/settings/websites/WebsiteAddButton.tsx
@@ -15,7 +15,7 @@ export function WebsiteAddButton({ teamId, onSave }: { teamId: string; onSave?:
return (
-