Skip to content

The open alternative to Salesforce, designed for AI.

3.2 KB
Raw Blame
import { expect, test } from '../lib/fixtures/screenshot';
test.describe.serial('Create Kanban View', () => {
  // Unique per run: serial-group retries re-create the field, and a duplicate label blocks the form.
  const industryLabel = `Industry ${Date.now()}`;
  test('Create Industry Select Field', async ({ page }) => {
    await page.getByRole('button', { name: 'Settings', exact: true }).click();
    await page.getByRole('link', { name: 'Data model' }).click();
    await page.getByRole('link', { name: 'Opportunities' }).click();
    await expect(page.getByRole('link', { name: 'New Field' })).toBeVisible();
    await page.getByRole('link', { name: 'New Field' }).click();
    await page.getByRole('link', { name: 'Select', exact: true }).click();
    await page.getByRole('textbox', { name: 'Employees' }).click();
    await page.getByRole('textbox', { name: 'Employees' }).fill(industryLabel);
    await page.getByRole('textbox').nth(1).click();
    await page.getByRole('textbox').nth(1).press('ControlOrMeta+a');
    await page.getByRole('textbox').nth(1).fill('Food');
    await page.getByRole('button', { name: 'Add option' }).click();
    await page
      .getByRole('button', { name: 'Option 2' })
      .getByRole('textbox')
      .fill('Tech');
    await page.getByRole('button', { name: 'Add option' }).click();
    await page
      .getByRole('button', { name: 'Option 3' })
      .getByRole('textbox')
      .fill('Travel');
    await page.getByRole('button', { name: 'Save' }).click();
    await page.waitForURL('**/objects/opportunities');
    await page.waitForSelector(`text=${industryLabel}`);
    await expect(page.getByText(industryLabel)).toBeVisible();
  });

  test('Create Kanban View from Industry Select Field', async ({ page }) => {
    await page.getByRole('link', { name: 'Opportunities' }).click();
    await page.getByRole('button', { name: /By Stage/ }).click();
    await page.getByText('Add view').click();
    await page.getByRole('textbox').press('ControlOrMeta+a');
    await page.getByRole('textbox').fill('By industry');
    await page
      .getByText('Stages', { exact: true })
      .locator('xpath=..')
      .getByRole('button')
      .click();
    await page
      .getByRole('dialog', { name: 'Stages' })
      .getByRole('option', { name: industryLabel })
      .click();
    await page.getByRole('button', { name: 'Create new view' }).click();
    await expect(page.getByText('Food')).toBeVisible({ timeout: 30000 });
    await expect(page.getByText('Tech')).toBeVisible();
    await expect(page.getByText('Travel')).toBeVisible();
    await expect(page.getByText('No Value')).toBeVisible();
    const byIndustryElements = await page.locator('text=By industry').all();
    expect(byIndustryElements.length).toBeGreaterThanOrEqual(1);
    for (const element of byIndustryElements) {
      await expect(element).toBeVisible();
    }
    await page.getByText('Options').click();
    await page.getByText('Group', { exact: true }).click();
    await Promise.all([
      page.getByTestId('hide-group-').click(),
      page.waitForRequest((request) => {
        return (
          request.url().includes('/metadata') && request.method() === 'POST'
        );
      }),
    ]);
    await expect(page.getByText('No Value')).not.toBeVisible();
  });
});