Skip to content

Commit

Permalink
Updated tests for new run
Browse files Browse the repository at this point in the history
  • Loading branch information
chromaticWaster committed Nov 24, 2023
1 parent 755afb3 commit 5047fb5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
17 changes: 7 additions & 10 deletions src/tab/Tab.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ test(`Tab - Basic Behaviour`, async ({ page }) => {
await page.goto('/components/tab/');
await page.waitForSelector('[data-testid]', {});

// For the purposes of the demo the Tabs are slotted in a Tab Group
// For the purposes of the demo the Tabs are slotted in a Tab Group.
const tabGroup = page.locator('.Basic').getByTestId('test-tab-group');
await expect(tabGroup).toHaveScreenshot('tab-group-initial.png');
// Get the Tab bar which will contain the tab headers.
const tabBar = tabGroup.locator('.tab-bar').first();

// Get all the tab headers
// Get all the tab headers.
const nestedTabHeaders = tabBar.locator('omni-tab-header');
await expect(nestedTabHeaders).toHaveCount(3);

// Get all the omni-tabs
// Get all the omni-tabs.
const tabs = tabGroup.locator('omni-tab');
await expect(tabs).toHaveCount(3);
});
Expand All @@ -26,19 +26,19 @@ test(`Tab - Active Behaviour`, async ({ page }) => {
await page.goto('/components/tab/');
await page.waitForSelector('[data-testid]', {});

// For the purposes of the demo the Tabs are slotted in a Tab Group
// For the purposes of the demo the Tabs are slotted in a Tab Group.
const tabGroup = page.locator('.Active').getByTestId('test-tab-group');
await expect(tabGroup).toHaveScreenshot('tab-group-initial.png');
// Get the Tab bar which will contain the tab headers.
const tabBar = tabGroup.locator('.tab-bar').first();

// Mock tab-select event.
const tabSelect = await mockEventListener(tabGroup, 'tab-select');
// Get all the tab headers
// Get all the tab headers.
const nestedTabHeaders = tabBar.locator('omni-tab-header');
await expect(nestedTabHeaders).toHaveCount(3);

// Get all the omni-tabs
// Get all the omni-tabs.
const tabs = tabGroup.locator('omni-tab');
await expect(tabs).toHaveCount(3);

Expand Down Expand Up @@ -66,10 +66,8 @@ test(`Tab - Disabled Behaviour`, async ({ page }) => {
await withCoverage(page, async () => {
await page.goto('/components/tab/');
await page.waitForSelector('[data-testid]', {});
// Locate the Disabled Tab example.
const tabGroup = page.locator('.Disabled').getByTestId('test-tab-group');
await expect(tabGroup).toHaveScreenshot('tab-group-initial.png');

// Mock tab-select event.
const tabSelect = await mockEventListener(tabGroup, 'tab-select');

Expand All @@ -80,10 +78,9 @@ test(`Tab - Disabled Behaviour`, async ({ page }) => {
const nestedTabHeaders = tabBar.locator('omni-tab-header');
await expect(nestedTabHeaders).toHaveCount(3);

// Get default slot.
// Get default slot
const tabs = tabGroup.locator('omni-tab');
await expect(tabs).toHaveCount(3);

// Click the disabled tab twice.
await nestedTabHeaders.nth(2).click();
await nestedTabHeaders.nth(2).click();
Expand Down
6 changes: 3 additions & 3 deletions src/tab/TabGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { test, expect, mockEventListener, withCoverage } from '../utils/JestPlay
test(`Tab Group - Visual and Behaviour`, async ({ page }) => {
await withCoverage(page, async () => {
await page.goto('/components/tab-group/');
// Locate the interactive Tab Group example

const tabGroup = page.locator('.Interactive').getByTestId('test-tab-group');
await expect(tabGroup).toHaveScreenshot('tab-group-initial.png');
// Mock tab-select event.
Expand All @@ -12,11 +12,11 @@ test(`Tab Group - Visual and Behaviour`, async ({ page }) => {
const tabBar = tabGroup.locator('.tab-bar');
await expect(tabBar).toHaveCount(1);

// Get all the omni-tab-headers
// Get all the omni-tab-headers.
const nestedTabHeaders = tabBar.locator('omni-tab-header');
await expect(nestedTabHeaders).toHaveCount(3);

// Get all the omni-tabs
// Get all the omni-tabs.
const tabs = tabGroup.locator('omni-tab');
await expect(tabs).toHaveCount(3);

Expand Down
14 changes: 7 additions & 7 deletions src/tab/TabHeader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ import { test, expect, mockEventListener, withCoverage } from '../utils/JestPlay
test(`Tab Header - Advanced Behaviour`, async ({ page }) => {
await withCoverage(page, async () => {
await page.goto('/components/tab-header/');
// Locate the Advanced Tab Header example.

const tabGroup = page.locator('.Advanced').getByTestId('test-tab-group');
await expect(tabGroup).toHaveScreenshot('tab-group-initial.png');

// Mock tab-select event.
const tabSelect = await mockEventListener(tabGroup, 'tab-select');

// Get all the tab headers
// Get all the tab headers.
const nestedTabHeaders = tabGroup.locator('omni-tab-header');
await expect(nestedTabHeaders).toHaveCount(4);

// Get all the omni-tabs
// Get all the omni-tabs.
const tabs = tabGroup.locator('omni-tab');
await expect(tabs).toHaveCount(4);

// Get the active tab header
// Get the active tab header.
const activeTabHeader = tabGroup.locator('omni-tab-header[data-active]');
await expect(activeTabHeader).toHaveCount(1);

// Get the omni-icon in the tab header slot
// Get the omni-icon in the tab header slot.
const omniIcon = activeTabHeader.locator('omni-icon');
await expect(omniIcon).toHaveCount(1);

// Get the third tab header
// Get the third tab header.
const thirdTabHeader = nestedTabHeaders.nth(2);

// Get the omni-icon of the third tab header
// Get the omni-icon of the third tab header.
const thirdTabHeaderIcon = thirdTabHeader.locator('omni-icon');
// Get the SVG slotted in the omni-icon component.
const svg = thirdTabHeaderIcon.locator('svg');
Expand Down

0 comments on commit 5047fb5

Please sign in to comment.