Skip to content

Commit

Permalink
test(accordion): refactor tests to use beforeEach for page navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
max-umain committed Dec 12, 2024
1 parent c9ec1ad commit 110ffaa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ const componentTestPath = 'src/components/accordion/test/basic/primary_darkmode/
const accordionSelector = 'tds-accordion';

test.describe.parallel('tds-accordion-primary-darkmode', () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders basic accordion correctly with primary mode variant and darkmode', async ({
page,
}) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
Expand All @@ -22,7 +25,6 @@ test.describe.parallel('tds-accordion-primary-darkmode', () => {

test('second accordion item opens on click', async ({ page }) => {
// Define selector for second accordion item
await page.goto(componentTestPath);
const accordionSecondItem = page.getByText('Second item');

// Hover second accordion item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ const componentTestPath = 'src/components/accordion/test/basic/primary_lightmode
const accordionSelector = 'tds-accordion';

test.describe.parallel('tds-accordion-primary-lightmode', () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders basic accordion correctly with primary mode variant and lightmode', async ({
page,
}) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
Expand All @@ -22,7 +25,6 @@ test.describe.parallel('tds-accordion-primary-lightmode', () => {

test('second accordion item opens on click', async ({ page }) => {
// Define selector for second accordion item
await page.goto(componentTestPath);
const accordionSecondItem = page.getByText('Second item');

// Hover second accordion item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ const componentTestPath = 'src/components/accordion/test/basic/secondary_darkmod
const accordionSelector = 'tds-accordion';

test.describe.parallel('tds-accordion-secondary-darkmode', () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders basic accordion correctly with secondary mode variant and darkmode', async ({
page,
}) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
Expand All @@ -22,7 +25,6 @@ test.describe.parallel('tds-accordion-secondary-darkmode', () => {

test('second accordion item opens on click', async ({ page }) => {
// Define selector for second accordion item
await page.goto(componentTestPath);
const accordionSecondItem = page.getByText('Second item');

// Hover second accordion item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ const componentTestPath = 'src/components/accordion/test/basic/secondary_lightmo
const accordionSelector = 'tds-accordion';

test.describe.parallel('tds-accordion-secondary-lightmode', () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders basic accordion correctly with secondary mode variant and lightmode', async ({
page,
}) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
Expand All @@ -22,7 +25,6 @@ test.describe.parallel('tds-accordion-secondary-lightmode', () => {

test('second accordion item opens on click', async ({ page }) => {
// Define selector for second accordion item
await page.goto(componentTestPath);
const accordionSecondItem = page.getByText('Second item');

// Hover second accordion item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ const componentTestPath = 'src/components/accordion/test/basic/unspecified/index
const accordionSelector = 'tds-accordion';

test.describe.parallel('tds-accordion', () => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders basic accordion correctly', async ({ page }) => {
// Define selector for accordion
await page.goto(componentTestPath);
const accordion = page.locator(accordionSelector);

// Check if accordion contains the correct text
Expand All @@ -20,7 +23,6 @@ test.describe.parallel('tds-accordion', () => {

test('should handle hover on accordion items', async ({ page }) => {
// Define selector for first accordion item
await page.goto(componentTestPath);
const accordionFirstItem = page.getByText('First item');

// Hover first accordion item
Expand All @@ -42,7 +44,6 @@ test.describe.parallel('tds-accordion', () => {

test('second accordion item opens on click', async ({ page }) => {
// Define selector for second accordion item
await page.goto(componentTestPath);
const accordionSecondItem = page.getByText('Second item');

// Hover second accordion item
Expand All @@ -54,7 +55,6 @@ test.describe.parallel('tds-accordion', () => {

test('fires tdsToggle event on click', async ({ page }) => {
// Define selector for first accordion item
await page.goto(componentTestPath);
const accordionFirstItem = page.getByText('First item');

// Define selector for second accordion item
Expand Down

0 comments on commit 110ffaa

Please sign in to comment.