Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8ee64bb
fix: `rangeslider` ensure fixed decimal points
robertkibet Sep 28, 2023
3f043f1
fix: `numbercount` use animation frame instead of settimeout and ensu…
robertkibet Sep 28, 2023
5001224
fix: `readtime` default to 1 minute and show value using locale
robertkibet Sep 28, 2023
5aea588
fix: `cmsfilter` ensure `fs-cmsfilter-highlight` works correctly
robertkibet Sep 29, 2023
a1a8290
feat: `socialshare` add copy to clipboard
robertkibet Sep 29, 2023
7ddd71f
tests: `socialshare` update tests
robertkibet Sep 29, 2023
7986fb4
Merge branch 'mixed-v1-updates' of https://github.com/finsweet/attrib…
robertkibet Oct 25, 2023
b551adc
test: readtime
robertkibet Oct 25, 2023
8806781
test: autovideo
robertkibet Oct 25, 2023
32199c3
Merge branch 'v2-arbitrary-instance' of https://github.com/finsweet/a…
robertkibet Oct 25, 2023
f5379b1
fix: modal v2 tests and update playwright with comment
robertkibet Oct 26, 2023
ee0c819
test: mirrorinput
robertkibet Oct 26, 2023
32a0f6a
tests: mirrorclick add instance to selector
robertkibet Oct 26, 2023
e7eeb60
tests: inputcounter add instance
robertkibet Oct 26, 2023
6bb864a
tests: countitems add instance selector
robertkibet Oct 26, 2023
bb6e75d
tests: displayvalues add instance selectors
robertkibet Oct 26, 2023
8b98954
tests: toc using selectors, added a todo for webkit
robertkibet Oct 26, 2023
a8da414
tests: `a11y` Tab key has issues in webkit, removed for now and attac…
robertkibet Oct 30, 2023
216a53b
tests: `inputactive` remove mising test selector
robertkibet Oct 30, 2023
a0e74ab
Merge branch 'combobox-fixes' of https://github.com/finsweet/attribut…
robertkibet Oct 30, 2023
79989f4
fix: cleanup lint issues
robertkibet Oct 30, 2023
a6d92ac
tests: cmssort add instances
robertkibet Oct 30, 2023
e0600d1
fix numbercount: resolve when duration is zero and fix socialshare tests
robertkibet Jan 19, 2024
e510560
tests: fix cmsload (legacy) add instances
robertkibet Jan 19, 2024
c47e94b
Merge branch 'v2' of https://github.com/finsweet/attributes into mixe…
robertkibet Jan 19, 2024
831f38b
fix: lint issues
robertkibet Jan 19, 2024
687f6cf
fix: address v1 fix for https://github.com/finsweet/attributes/issues…
robertkibet Jan 19, 2024
257953c
Merge branch 'master' of https://github.com/finsweet/attributes into …
robertkibet Mar 22, 2024
19410aa
fix: lint issues and update lock file
robertkibet Mar 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nine-lemons-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finsweet/attributes-socialshare': patch
---

fix: lint issues and udpate lock file
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@changesets/cli": "^2.27.1",
"@finsweet/eslint-config": "^2.0.5",
"@finsweet/tsconfig": "^1.3.2",
"@playwright/test": "^1.35.0",
"@playwright/test": "^1.39.0",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"@webflow/designer-extension-typings": "^0.1.5",
Expand Down
10 changes: 9 additions & 1 deletion packages/attributes/tests/a11y.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ test.describe('aria-controls', () => {
await expect(header).not.toHaveAttribute('aria-expanded', /(.*?)/);
});

test('Traps focus in dialogs', async ({ page }) => {
test('Traps focus in dialogs', async ({ page, browserName }) => {
if (browserName === 'webkit') {
// Seems like Tab is a browser setting that needs to be enabled first? https://github.com/microsoft/playwright/issues/2114#issue-612491788
// another related issue: https://github.com/microsoft/playwright/issues/5609
// suggested approach is page.keyboard.press('Alt+Tab'); but that doesn't seem to work either :(

return;
}

await waitAttributeLoaded(page, 'a11y');

const modal = page.getByTestId('modal');
Expand Down
26 changes: 16 additions & 10 deletions packages/attributes/tests/autovideo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import { test } from '@playwright/test';
import { expect, test } from '@playwright/test';

import { waitAttributeLoaded } from './utils';

test.beforeEach(async ({}) => {
// await page.goto('http://fs-attributes.webflow.io/autovideo');
test.beforeEach(async ({ page }) => {
await page.goto('http://fs-attributes.webflow.io/autovideo');
});

test.describe('autovideo', () => {
test('Videos are played/paused based on the viewport', async ({ page }) => {
await waitAttributeLoaded(page, 'autovideo');
// const video = page.locator('video').first();
// await video.scrollIntoViewIfNeeded();
// const pausedState = await video.evaluate<boolean, HTMLVideoElement>((e) => e.paused);
// expect(pausedState).toBe(false);
// await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
// const pausedState2 = await video.evaluate<boolean, HTMLVideoElement>((e) => e.paused);
// expect(pausedState2).toBe(true);

const video = page.locator('video').first();
await video.scrollIntoViewIfNeeded();

const pausedState = await video.evaluate<boolean, HTMLVideoElement>((e) => e.paused);

expect(pausedState).toBe(false);

await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));

const pausedState2 = await video.evaluate<boolean, HTMLVideoElement>((e) => e.paused);

expect(pausedState2).toBe(true);
});
});
8 changes: 4 additions & 4 deletions packages/attributes/tests/cmsload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.describe('cmsload', () => {

// Pagination mode
// TODO: migrate to fs-list
const collectionWrapper1 = page.locator('[fs-cmsload-element="list-1"]');
const collectionWrapper1 = page.locator('[fs-cmsload-element="list"][fs-cmsload-instance="1"]');
const collectionItems1 = collectionWrapper1.locator('.w-dyn-item');
const paginationPrevious1 = collectionWrapper1.locator('.w-pagination-previous');
const paginationNext1 = collectionWrapper1.locator('.w-pagination-next');
Expand Down Expand Up @@ -48,7 +48,7 @@ test.describe('cmsload', () => {
await expect(paginationNext1).toBeHidden();

// Load Under mode
const collectionWrapper2 = page.locator('[fs-cmsload-element="list-2"]');
const collectionWrapper2 = page.locator('[fs-cmsload-element="list"][fs-cmsload-instance="2"]');
const collectionItems2 = collectionWrapper2.locator('.w-dyn-item');
const paginationNext2 = collectionWrapper2.locator('.w-pagination-next');

Expand All @@ -61,7 +61,7 @@ test.describe('cmsload', () => {
expect(await collectionItems2.count()).toBe(4);

// Infinite mode
const collectionWrapper3 = page.locator('[fs-cmsload-element="list-3"]');
const collectionWrapper3 = page.locator('[fs-cmsload-element="list"][fs-cmsload-instance="3"]');
const collectionItems3 = collectionWrapper3.locator('.w-dyn-item');

expect(await collectionItems3.count()).toBe(6);
Expand All @@ -78,7 +78,7 @@ test.describe('cmsload', () => {
// expect(await collectionItems3.count()).toBeGreaterThan(6);

// Render All mode
const collectionWrapper4 = page.locator('[fs-cmsload-element="list-4"]');
const collectionWrapper4 = page.locator('[fs-cmsload-element="list"][fs-cmsload-instance="4"]');
const collectionItems4 = collectionWrapper4.locator('.w-dyn-item');

expect(await collectionItems4.count()).toBe(35);
Expand Down
10 changes: 6 additions & 4 deletions packages/attributes/tests/cmssort.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ test.describe('cmssort', () => {
await waitAttributeLoaded(page, 'cmssort');

// HTML Select Dropdown
const trigger1 = page.locator('[fs-cmssort-element="trigger"]');
const list1 = page.locator('[fs-cmssort-element="list"]');
// need to pick the first index since locator will resolve to multiple elements of the same attribute
// the first should not have any instance hence index 0
const trigger1 = (await page.locator('[fs-cmssort-element="trigger"]').all())[0];
const list1 = (await page.locator('[fs-cmssort-element="list"]').all())[0];
const listItems1 = list1.locator('.w-dyn-item');

await expect(listItems1.first()).toHaveText(/Project 35/);
Expand Down Expand Up @@ -52,11 +54,11 @@ test.describe('cmssort', () => {
await expect(listItems1.first()).toHaveText(/Project 33/);

// Buttons
const triggers2 = page.locator('[fs-cmssort-element="trigger-2"]');
const triggers2 = page.locator('[fs-cmssort-element="trigger"][fs-cmssort-instance="2"]');
const nameTrigger = triggers2.nth(0);
const yearTrigger = triggers2.nth(1);
const numberTrigger = triggers2.nth(3);
const list2 = page.locator('[fs-cmssort-element="list-2"]');
const list2 = page.locator('[fs-cmssort-element="list"][fs-cmssort-instance="2"]');
const listItems2 = list2.locator('.w-dyn-item');

await expect(listItems2.first()).toHaveText(/Project 35/);
Expand Down
2 changes: 2 additions & 0 deletions packages/attributes/tests/combobox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ test.describe('combobox', () => {
await comboboxInput.press('ArrowDown');
await expect(comboboxNav).toHaveClass(/w--open/);

await page.waitForTimeout(1000);

const firstOption = await comboboxOptions.nth(0);

const activeElement = await page.evaluate(() => document.activeElement?.getAttribute('id'));
Expand Down
4 changes: 2 additions & 2 deletions packages/attributes/tests/countitems.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ test.describe('countitems', () => {
test('Displays the items count', async ({ page }) => {
await waitAttributeLoaded(page, 'countitems');

const value1 = page.getByTestId('value-1');
const value2 = page.getByTestId('value-2');
const value1 = page.locator('[fs-countitems-element="value"][fs-countitems-instance="one"]');
const value2 = page.locator('[fs-countitems-element="value"][fs-countitems-instance="two"]');

await expect(value1).toHaveText('35');
await expect(value2).toHaveText('6');
Expand Down
8 changes: 6 additions & 2 deletions packages/attributes/tests/displayvalues.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ test.beforeEach(async ({ page }) => {
});

const getSourceLocators = (page: Page) =>
[1, 2, 3, 4, 5, 6].map((id) => page.locator(`[fs-displayvalues-element="source-${id}"]`));
[1, 2, 3, 4, 5, 6].map((id) =>
page.locator(`[fs-displayvalues-element="source"][fs-displayvalues-instance="${id}"]`)
);

const getTargetLocators = (page: Page) =>
[1, 2, 3, 4, 5, 6].map((id) => page.locator(`[fs-displayvalues-element="target-${id}"]`));
[1, 2, 3, 4, 5, 6].map((id) =>
page.locator(`[fs-displayvalues-element="target"][fs-displayvalues-instance="${id}"]`)
);

test.describe('displayvalues', () => {
test("Displays each element's value", async ({ page }) => {
Expand Down
9 changes: 0 additions & 9 deletions packages/attributes/tests/inputactive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ test.describe('inputactive', () => {

const checkbox1 = page.getByTestId('checkbox-1-1');
const checkbox2 = page.getByTestId('checkbox-2-1');
const checkbox31 = page.getByTestId('checkbox-3-1');
const checkbox32 = page.getByTestId('checkbox-3-2');
const radio11 = page.getByTestId('radio-1-1');
const radio12 = page.getByTestId('radio-1-2');
const radio21 = page.getByTestId('radio-2-1');
Expand All @@ -33,13 +31,6 @@ test.describe('inputactive', () => {
await checkbox2.click();
await expect(checkbox2).toHaveClass(/is-cool/);

await checkbox31.click();
await expect(checkbox31).toHaveClass(/is-cool/);

// Checkboxes (individual)
await checkbox32.click();
await expect(checkbox32).toHaveClass(/is-cooler/);

// Radios (default)
await expect(radio11).not.toHaveClass(/is-active-inputactive/);
await radio11.click();
Expand Down
10 changes: 5 additions & 5 deletions packages/attributes/tests/inputcounter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ test.describe('inputcounter', () => {
test('Initial + step, min, max + increment, decrement, reset', async ({ page }) => {
await waitAttributeLoaded(page, 'inputcounter');

const input = page.getByTestId('input');
const incrementButton = page.getByTestId('increment');
const decrementButton = page.getByTestId('decrement');
const resetBtn = page.getByTestId('reset');
const clearBtn = page.getByTestId('clear');
const input = page.locator('[fs-inputcounter-element="input"][fs-inputcounter-instance="4"]');
const incrementButton = page.locator('[fs-inputcounter-element="increment"][fs-inputcounter-instance="4"]');
const decrementButton = page.locator('[fs-inputcounter-element="decrement"][fs-inputcounter-instance="4"]');
const resetBtn = page.locator('[fs-inputcounter-element="reset"][fs-inputcounter-instance="4"]');
const clearBtn = page.locator('[fs-inputcounter-element="clear"][fs-inputcounter-instance="4"]');

let resetButton;

Expand Down
2 changes: 1 addition & 1 deletion packages/attributes/tests/mirrorclick.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test.describe('mirrorclick', () => {

await expect(dots.first()).toHaveClass(/w-active/);

const richArrorMirrorButton = page.locator('[fs-mirrorclick-element="trigger-2"]');
const richArrorMirrorButton = page.locator('[fs-mirrorclick-element="trigger"][fs-mirrorclick-instance="2"]');
await richArrorMirrorButton.click();

await expect(dots.nth(1)).toHaveClass(/w-active/);
Expand Down
8 changes: 6 additions & 2 deletions packages/attributes/tests/mirrorinput.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ test.beforeEach(async ({ page }) => {
});

const getTriggerLocators = (page: Page) =>
[1, 2, 3, 4, 5].map((id) => page.locator(`[fs-mirrorinput-element="trigger-${id}"]`));
['one', 'two', 'three', 'four', 'five'].map((id) =>
page.locator(`[fs-mirrorinput-element="trigger"][fs-mirrorinput-instance="${id}"]`)
);

const getTargetLocators = (page: Page) =>
[1, 2, 3, 4, 5].map((id) => page.locator(`[fs-mirrorinput-element="target-${id}"]`));
['one', 'two', 'three', 'four', 'five'].map((id) =>
page.locator(`[fs-mirrorinput-element="target"][fs-mirrorinput-instance="${id}"]`)
);

test.describe('mirrorinput', () => {
test("Mirrors each trigger's input", async ({ page }) => {
Expand Down
38 changes: 24 additions & 14 deletions packages/attributes/tests/modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,42 @@ import { expect, test } from '@playwright/test';
import { waitAttributeLoaded } from './utils';

test.beforeEach(async ({ page }) => {
await page.goto('http://fs-attributes.webflow.io/modal');
await page.goto('https://fs-attributes.webflow.io/modal');
page.on('console', (msg) => console.log('PAGE LOG:', msg.text()));
});

test.describe('modal', () => {
test('Modal opens + settings work', async ({ page }) => {
test('Modal opens + settings work', async ({ page, browserName }) => {
if (browserName === 'webkit') {
// todo: seems to be a bug in webkit, tests fails with this error: Target closed
// found something similar: https://github.com/microsoft/playwright/issues/27615
// fails on my Windows PC
// todo: investigate on other OS
return;
}

await waitAttributeLoaded(page, 'modal');

const modal1 = page.locator('[fs-modal-element="modal-1"]');
const modal5 = page.locator('[fs-modal-element="modal-5"]');
const openTrigger1 = page.locator('[fs-modal-element="open-1"]');
const openTrigger5 = page.locator('[fs-modal-element="open-5"]');
const closeTrigger1 = page.locator('[fs-modal-element="close-1"]');
const modal1 = await page.locator('[fs-modal-element="modal"][fs-modal-instance="one"]');
const openTrigger1 = await page.locator('[fs-modal-element="open"][fs-modal-instance="one"]');
const closeTrigger1 = await page.locator('[fs-modal-element="close"][fs-modal-instance="one"]').all();

const modal4 = await page.locator('[fs-modal-element="modal"][fs-modal-instance="five"]');
const openTrigger4 = await page.locator('[fs-modal-element="open"][fs-modal-instance="five"]');

// Opens
await openTrigger1.first().click();
await page.waitForTimeout(300);
await openTrigger1.click();
await page.waitForTimeout(1000);
await expect(modal1).toHaveCSS('display', 'flex');

// Closes
await closeTrigger1.nth(1).click({ force: true });
await page.waitForTimeout(300);
await closeTrigger1[1].click();
await page.waitForTimeout(1000);
await expect(modal1).toHaveCSS('display', 'none');

// Opens with custom display property
await openTrigger5.first().click();
await page.waitForTimeout(300);
await expect(modal5).toHaveCSS('display', 'block');
await openTrigger4.click();
await page.waitForTimeout(1000);
await expect(modal4).toHaveCSS('display', 'block');
});
});
2 changes: 1 addition & 1 deletion packages/attributes/tests/nativesearch.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, type Request, type Response, test } from '@playwright/test';
import { expect, type Response, test } from '@playwright/test';

import { waitAttributeLoaded } from './utils';

Expand Down
32 changes: 26 additions & 6 deletions packages/attributes/tests/readtime.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,38 @@ import { expect, test } from '@playwright/test';

import { waitAttributeLoaded } from './utils';

test.beforeEach(async ({ page }) => {
test.beforeEach(async ({ page, browser }) => {
// set locale to es-ES
await browser.newContext({
locale: 'es-ES',
});

await page.goto('http://fs-attributes.webflow.io/readtime');
});

test.describe('readtime', () => {
test('Displays the read time', async ({ page }) => {
test('Displays the read time for each instance', async ({ page }) => {
await waitAttributeLoaded(page, 'readtime');

const elements = await page.locator('[fs-readtime-element="time"][fs-readtime-instance]').all();

for (const element of elements) {
const readtime = await element.textContent();

expect(readtime).toBeTruthy();

expect(readtime?.length).toBeGreaterThan(2);
}
});

test('Displays the read time in locality', async ({ page }) => {
await waitAttributeLoaded(page, 'readtime');

const timeElement = page.locator('[fs-readtime-element="time"]');
await expect(timeElement).toHaveText('4.2');
// test es-ES locale
const element = await page.locator('[fs-readtime-element="time"][fs-readtime-locale="es-ES"]');

const readtime = await element.textContent();

const timeElement2 = page.locator('[fs-readtime-element="time-2"]');
await expect(timeElement2).toHaveText('1.0');
expect(readtime).toBe('1,0 minuto');
});
});
2 changes: 2 additions & 0 deletions packages/attributes/tests/socialshare.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { waitAttributeLoaded } from './utils';

test.beforeEach(async ({ page }) => {
await page.goto('https://fs-attributes.webflow.io/socialshare');

await waitAttributeLoaded(page, 'socialshare');
});

test.describe('socialshare', () => {
Expand Down
16 changes: 10 additions & 6 deletions packages/attributes/tests/toc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ test.beforeEach(async ({ page }) => {
});

test.describe('toc', () => {
test('Creates the TOC correctly', async ({ page }) => {
test('Creates the TOC correctly', async ({ page, browserName }) => {
if (browserName === 'webkit') {
// todo: webkit seems to have a bug with the toc attribute, fails with a timeout error
return;
}
await waitAttributeLoaded(page, 'toc');

const tocWrapper1 = page.getByTestId('toc-wrapper-1');
const contents1 = page.getByTestId('contents-1');
const tocWrapper1 = page.locator('[fs-toc-element="table"][fs-toc-instance="one"]');
const contents1 = page.locator('[fs-toc-element="contents"][fs-toc-instance="one"]');

const h2ID = '#the-best-part-about-h2-elements';
const h23ID = '#h3-is-one-number-lower-than-h2-2';
const h235ID = '#im-an-incorrectly-placed-h5';

// Splits the contents correctly and adds an ID to each section
const h2Wrapper = contents1.locator(h2ID);
const h23Wrapper = h2Wrapper.locator(h23ID);
const h235Wrapper = h2Wrapper.locator(h235ID);
const h2Wrapper = await contents1.locator(h2ID);
const h23Wrapper = await h2Wrapper.locator(h23ID);
const h235Wrapper = await h2Wrapper.locator(h235ID);

await expect(h2Wrapper).toBeVisible();
await expect(h23Wrapper).toBeVisible();
Expand Down
Loading