mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-22 09:57:00 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
2363b03d1c
@ -1,15 +1,11 @@
|
|||||||
describe('Login test', () => {
|
describe('Login tests', () => {
|
||||||
it(
|
it(
|
||||||
'logs user in with correct credentials and logs user out',
|
'logs user in with correct credentials and logs user out',
|
||||||
{
|
{
|
||||||
defaultCommandTimeout: 10000,
|
defaultCommandTimeout: 10000,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
cy.visit('/login');
|
cy.login(Cypress.env('umami_user'), Cypress.env('umami_password'));
|
||||||
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.dataCy('button-profile').click();
|
cy.dataCy('button-profile').click();
|
||||||
cy.dataCy('item-logout').click();
|
cy.dataCy('item-logout').click();
|
||||||
cy.url().should('eq', Cypress.config().baseUrl + '/login');
|
cy.url().should('eq', Cypress.config().baseUrl + '/login');
|
||||||
|
37
cypress/e2e/website.cy.ts
Normal file
37
cypress/e2e/website.cy.ts
Normal file
@ -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');
|
||||||
|
});
|
||||||
|
});
|
@ -1,5 +1,24 @@
|
|||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
Cypress.Commands.add('dataCy', value => {
|
Cypress.Commands.add('dataCy', (value: string) => {
|
||||||
return cy.get(`[data-cy=${value}]`);
|
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');
|
||||||
|
});
|
||||||
|
5
cypress/support/index.d.ts
vendored
5
cypress/support/index.d.ts
vendored
@ -7,5 +7,10 @@ declare namespace Cypress {
|
|||||||
* @example cy.dataCy('greeting')
|
* @example cy.dataCy('greeting')
|
||||||
*/
|
*/
|
||||||
dataCy(value: string): Chainable<JQuery<HTMLElement>>;
|
dataCy(value: string): Chainable<JQuery<HTMLElement>>;
|
||||||
|
/**
|
||||||
|
* Custom command to login user into the app.
|
||||||
|
* @example cy.login('admin', 'password)
|
||||||
|
*/
|
||||||
|
login(username: string, password: string): Chainable<JQuery<HTMLElement>>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export function WebsiteAddButton({ teamId, onSave }: { teamId: string; onSave?:
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalTrigger>
|
<ModalTrigger>
|
||||||
<Button variant="primary">
|
<Button data-cy="button-website-add" variant="primary">
|
||||||
<Icon>
|
<Icon>
|
||||||
<Icons.Plus />
|
<Icons.Plus />
|
||||||
</Icon>
|
</Icon>
|
||||||
|
@ -38,12 +38,17 @@ export function WebsiteAddForm({
|
|||||||
return (
|
return (
|
||||||
<Form onSubmit={handleSubmit} error={error}>
|
<Form onSubmit={handleSubmit} error={error}>
|
||||||
<FormRow label={formatMessage(labels.name)}>
|
<FormRow label={formatMessage(labels.name)}>
|
||||||
<FormInput name="name" rules={{ required: formatMessage(labels.required) }}>
|
<FormInput
|
||||||
|
data-cy="input-name"
|
||||||
|
name="name"
|
||||||
|
rules={{ required: formatMessage(labels.required) }}
|
||||||
|
>
|
||||||
<TextField autoComplete="off" />
|
<TextField autoComplete="off" />
|
||||||
</FormInput>
|
</FormInput>
|
||||||
</FormRow>
|
</FormRow>
|
||||||
<FormRow label={formatMessage(labels.domain)}>
|
<FormRow label={formatMessage(labels.domain)}>
|
||||||
<FormInput
|
<FormInput
|
||||||
|
data-cy="input-domain"
|
||||||
name="domain"
|
name="domain"
|
||||||
rules={{
|
rules={{
|
||||||
required: formatMessage(labels.required),
|
required: formatMessage(labels.required),
|
||||||
@ -54,7 +59,7 @@ export function WebsiteAddForm({
|
|||||||
</FormInput>
|
</FormInput>
|
||||||
</FormRow>
|
</FormRow>
|
||||||
<FormButtons flex>
|
<FormButtons flex>
|
||||||
<SubmitButton variant="primary" disabled={false}>
|
<SubmitButton data-cy="button-submit" variant="primary" disabled={false}>
|
||||||
{formatMessage(labels.save)}
|
{formatMessage(labels.save)}
|
||||||
</SubmitButton>
|
</SubmitButton>
|
||||||
{onClose && (
|
{onClose && (
|
||||||
|
@ -36,7 +36,7 @@ export function WebsitesTable({
|
|||||||
<>
|
<>
|
||||||
{allowEdit && (
|
{allowEdit && (
|
||||||
<LinkButton href={renderTeamUrl(`/settings/websites/${websiteId}`)}>
|
<LinkButton href={renderTeamUrl(`/settings/websites/${websiteId}`)}>
|
||||||
<Icon>
|
<Icon data-cy="link-button-edit">
|
||||||
<Icons.Edit />
|
<Icons.Edit />
|
||||||
</Icon>
|
</Icon>
|
||||||
<Text>{formatMessage(labels.edit)}</Text>
|
<Text>{formatMessage(labels.edit)}</Text>
|
||||||
|
Loading…
Reference in New Issue
Block a user