Skip to content

Commit

Permalink
Merge pull request #24 from Bricks666/develop
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
Bricks666 authored Feb 14, 2024
2 parents 3f0d961 + ae3ad92 commit 954fbf8
Show file tree
Hide file tree
Showing 161 changed files with 8,727 additions and 9,218 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VITE_API_HOST=''
BASE_CLIENT_URL=http://localhost:3000
API_HOST=http://localhost:5000/api
2 changes: 2 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BASE_CLIENT_URL=http://localhost:3000
API_HOST=http://localhost:5000/api
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,5 @@
"@typescript-eslint/no-empty-interface": ["off"],
"@typescript-eslint/no-explicit-any": "warn"
},
"ignorePatterns": ["templates/**/*", "*.css.d.ts", "configs/*"]
"ignorePatterns": ["templates/**/*", "*.css.d.ts", "configs/*", "e2e", "*.config.*"]
}
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ dist

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.env
.env.development
.env.test
.env.production

npm-debug.log*
yarn-debug.log*
yarn-error.log*
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
.env
74 changes: 74 additions & 0 deletions e2e/account-activate.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { expect } from '@playwright/test';
import { faker } from '@faker-js/faker';

import { User, test } from './fixtures';
import { expectAlert } from './utils';

test.describe('account activate page(online)', () => {
let user: User;
let activateLink: string;

test.beforeEach(
async ({
page,
user: getUser,
activateAccountLink: getActivateAccountLink,
}) => {
user = await getUser({
email: faker.internet.email(),
activated: false,
});

activateLink = await getActivateAccountLink(user);

await page.goto(activateLink);
}
);

test('has correct view', async ({ page }) => {
await expect(page).toHaveScreenshot();
});

test('has right title', async ({ page }) => {
await expect(page).toHaveTitle(/Account activation/);
});

test('can navigate to login page', async ({ page }) => {
const link = page.getByRole('link', { name: 'go to login page' });

await link.click();

await expect(page).toHaveURL('/login');
});

test('cannot open if authorized', async ({ page, auth }) => {
const u = await auth({
email: faker.internet.email(),
});

await page.reload();

await expect(page).toHaveURL('/rooms');
});

test('show error if account has been already activated', async ({
page,
user: getUser,
activateAccountLink: getActivateAccountLink,
}) => {
user = await getUser({
email: faker.internet.email(),
activated: true,
});

activateLink = await getActivateAccountLink(user);

await page.goto(activateLink);

await expectAlert({
type: 'error',
parent: page,
message: 'The account has already been activated',
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
122 changes: 122 additions & 0 deletions e2e/activities.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { faker } from '@faker-js/faker';
import { expect } from '@playwright/test';
import { Room, User, test } from './fixtures';

test.describe('activities page(online)', () => {
const iterator = new Array(100).fill(true);

let user: User;
let room: Room;

test.beforeEach(async ({ auth, room: getRoom, activity, page }) => {
const data = await auth({
email: faker.internet.email(),
});

user = data.user;

room = await getRoom({
ownerId: user.id,
});

await Promise.all(
iterator.map((_, index) => {
const moreThanHalf = index >= 50;
const action = moreThanHalf ? 'update' : 'create';

return activity({ room, activist: user, action });
})
);

await page.goto(`/rooms/${room.id}/activities`);
});

test('has correct view', async ({ page }) => {
await expect(page).toHaveScreenshot();
});

test('has right title', async ({ page }) => {
await expect(page).toHaveTitle(/Activities/);
});

test('has been navigated to first page by default', async ({ page }) => {
await expect(
page.getByRole('link', { name: 'page 1', exact: true })
).toBeVisible();
});

test('can navigate to another page', async ({ page }) => {
const link = page.getByRole('link', { name: 'Go to page 2', exact: true });
await link.click();

await expect(page).toHaveURL(/p=2/);
await expect(
page.getByRole('link', { name: 'page 2', exact: true })
).toBeVisible();
});

test('can filter activities', async ({ page }) => {
const filterButton = page.getByRole('button', {
name: 'Activities filters',
});
await filterButton.click();

const form = page.getByRole('form', {
name: 'Activities filters',
exact: true,
});
await expect(form).toBeVisible();
const action = form.getByLabel('Action');
await action.fill('create');
await page.getByRole('option').click();
const apply = form.getByRole('button', { name: 'Apply', exact: true });
await apply.click();

await expect(page).toHaveURL(/action=1/);
await expect(
page.getByRole('link', { name: 'Go to page 2', exact: true })
).toBeHidden();
await expect(page.getByText('updated')).toBeHidden();

await filterButton.click();
const sphere = form.getByLabel('Sphere');
await sphere.fill('tag');
await page.getByRole('option').click();
await apply.click();
370;

await expect(page).toHaveURL(/action=1&sphere=2/);
await expect(page.getByRole('list')).toBeHidden();

await filterButton.click();
await form.getByRole('button', { name: 'Reset' }).click();

await expect(
page.getByRole('link', { name: 'Go to page 2', exact: true })
).toBeVisible();
await expect(
page.getByRole('list').filter({ hasText: 'User' })
).toBeVisible();
});

test('add activities if there has been added new one', async ({
page,
activity,
}) => {
const data = {
room,
activist: user,
action: 'remove',
sphere: 'tag',
createdAt: new Date(),
};

const listitem = page.getByRole('listitem').filter({ hasText: 'removed' });

await expect(listitem).toBeHidden();

await activity(data);

await expect(listitem).toBeVisible();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions e2e/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { mergeTests } from '@playwright/test';

import { test as testingApiTest } from './testing-api';

export const test = mergeTests(testingApiTest);

export type {
User,
Login,
Room,
Tokens,
Tag,
Task,
Invitation,
Member,
} from './testing-api';
Loading

0 comments on commit 954fbf8

Please sign in to comment.