(app-desk) add panel for mail domains

Adds a panel based on teams' one. It fetches all mail-domains
the connected user has relationships with and displays them
as a list of links redirecting to
/mail-domains/<my-domain-name>. Updates e2e tests accordingly.
This commit is contained in:
daproclaima
2024-05-02 12:30:52 +02:00
committed by Sebastien Nobour
parent 3f1b446e8e
commit 9b198d0bab
14 changed files with 467 additions and 12 deletions

View File

@@ -1,16 +1,93 @@
import { expect, test } from '@playwright/test';
import { MailDomain } from 'app-desk/src/features/mail-domains';
import { keyCloakSignIn } from './common';
test.beforeEach(async ({ page, browserName }) => {
await page.goto('/');
await keyCloakSignIn(page, browserName);
});
const currentDateIso = new Date().toISOString();
const mailDomainsFixtures: MailDomain[] = [
{
name: 'domain.fr',
id: '456ac6ca-0402-4615-8005-69bc1efde43f',
created_at: currentDateIso,
updated_at: currentDateIso,
},
{
name: 'mails.fr',
id: '456ac6ca-0402-4615-8005-69bc1efde43e',
created_at: currentDateIso,
updated_at: currentDateIso,
},
{
name: 'versailles.net',
id: '456ac6ca-0402-4615-8005-69bc1efde43g',
created_at: currentDateIso,
updated_at: currentDateIso,
},
{
name: 'paris.fr',
id: '456ac6ca-0402-4615-8005-69bc1efde43h',
created_at: currentDateIso,
updated_at: currentDateIso,
},
];
test.describe('Mails', () => {
test('checks all the elements are visible', async ({ page }) => {
await page.locator('menu').first().getByLabel(`Mails button`).click();
await expect(page.getByText('john@doe.com')).toBeVisible();
await expect(page.getByText('jane@doe.com')).toBeVisible();
test.describe('Mail domain', () => {
test.describe('checks all the elements are visible', () => {
test.beforeEach(async ({ page, browserName }) => {
await page.goto('/');
await keyCloakSignIn(page, browserName);
});
test('when no mail domain exists', async ({ page }) => {
await page.route('**/api/v1.0/mail-domains/?page=*', async (route) => {
await route.fulfill({
json: {
count: 0,
next: null,
previous: null,
results: [],
},
});
});
await page
.locator('menu')
.first()
.getByLabel(`Mail Domains button`)
.click();
await expect(page).toHaveURL(/mail-domains/);
await expect(
page.getByLabel('mail domains panel', { exact: true }),
).toBeVisible();
await expect(page.getByText('0 mail domain to display.')).toBeVisible();
});
test('when 4 mail domains exist', async ({ page }) => {
await page.route('**/api/v1.0/mail-domains/?page=*', async (route) => {
await route.fulfill({
json: {
count: mailDomainsFixtures.length,
next: null,
previous: null,
results: mailDomainsFixtures,
},
});
});
await page
.locator('menu')
.first()
.getByLabel(`Mail Domains button`)
.click();
await expect(page).toHaveURL(/mail-domains/);
await expect(
page.getByLabel('mail domains panel', { exact: true }),
).toBeVisible();
await expect(page.getByText('0 mail domain to display.')).toHaveCount(0);
await expect(page.getByText('domain.fr')).toBeVisible();
await expect(page.getByText('mails.fr')).toBeVisible();
await expect(page.getByText('versailles.net')).toBeVisible();
await expect(page.getByText('paris.fr')).toBeVisible();
});
});
});

View File

@@ -16,10 +16,10 @@ test.describe('Menu', () => {
expectedText: 'Create a new team',
},
{
name: 'Mails',
name: 'Mail Domains',
isDefault: false,
expectedUrl: '/mails',
expectedText: 'Emails',
expectedUrl: '/mail-domains',
expectedText: 'Mail Domains',
},
];
for (const { name, isDefault, expectedUrl, expectedText } of menuItems) {