Skip to content

Commit

Permalink
Changed visibility settings to use 'members' instead of 'subscribers' (
Browse files Browse the repository at this point in the history
…#1371)

REF PLG-179
  • Loading branch information
sanne-san committed Aug 22, 2024
1 parent 37e0152 commit d04cfd6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions packages/koenig-lexical/src/hooks/useVisibilityToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export const useVisibilityToggle = (editor, nodeKey, cardConfig) => {
const dropdownOptions = () => {
if (isStripeEnabled) {
return [{
label: 'All subscribers',
label: 'All members',
name: ''
}, {
label: 'Free subscribers',
label: 'Free members',
name: 'status:free'
}, {
label: 'Paid subscribers',
label: 'Paid members',
name: 'status:-free'
}];
}
Expand All @@ -38,13 +38,13 @@ export const useVisibilityToggle = (editor, nodeKey, cardConfig) => {
let segmentLabel = '';

if (segment === 'status:free') {
segmentLabel = 'free subscribers';
segmentLabel = 'free members';
} else if (segment === 'status:-free') {
segmentLabel = 'paid subscribers';
segmentLabel = 'paid members';
}

if (!showOnWeb && !showOnEmail) {
message = 'Hidden from both email and web';
message = 'Hidden from both web and email';
} else if (showOnWeb && !showOnEmail) {
message = 'Only shown on web';
} else if (showOnWeb && showOnEmail && segmentLabel) {
Expand Down
18 changes: 9 additions & 9 deletions packages/koenig-lexical/test/e2e/content-visibility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test.describe('Content Visibility', async () => {
await expect(card.locator('[aria-label="Visibility"]')).toHaveAttribute('data-kg-active', 'true');
});

test('visibility settings - defaults to show on email and web and all subscribers', async function () {
test('visibility settings - defaults to show on email and web and all members', async function () {
const card = await insertHtmlCard();

await card.locator('[aria-label="Visibility"]').click();
Expand Down Expand Up @@ -94,15 +94,15 @@ test.describe('Content Visibility', async () => {
await expect(card.getByTestId('visibility-message')).toContainText('Only shown on web');
});

test('can toggle visibility settings - show on email and web and all subscribers', async function () {
test('can toggle visibility settings - show on email and web and all members', async function () {
const card = await insertHtmlCard();

await card.locator('[aria-label="Visibility"]').click();

await expect(card.getByTestId('visibility-message')).not.toBeVisible();
});

test('can toggle visibility settings segments - free subscribers', async function () {
test('can toggle visibility settings segments - free members', async function () {
const card = await insertHtmlCard();

await card.locator('[aria-label="Visibility"]').click();
Expand All @@ -111,21 +111,21 @@ test.describe('Content Visibility', async () => {

await card.locator('[data-test-value="status:free"]').click();

await expect(card.getByTestId('visibility-message')).toContainText('Shown on web, and to free subscribers only in email');
await expect(card.getByTestId('visibility-message')).toContainText('Shown on web, and to free members only in email');
});

test('can toggle visibility settings segments - paid subscribers', async function () {
test('can toggle visibility settings segments - paid members', async function () {
const card = await insertHtmlCard();

await card.locator('[aria-label="Visibility"]').click();

await card.getByTestId('visibility-dropdown-segment').click();
await card.locator('[data-test-value="status:-free"]').click();

await expect(card.getByTestId('visibility-message')).toContainText('Shown on web, and to paid subscribers only in email');
await expect(card.getByTestId('visibility-message')).toContainText('Shown on web, and to paid members only in email');
});

test('can toggle visibility settings segments - all subscribers', async function () {
test('can toggle visibility settings segments - all members', async function () {
const card = await insertHtmlCard();

await card.locator('[aria-label="Visibility"]').click();
Expand All @@ -144,10 +144,10 @@ test.describe('Content Visibility', async () => {
await card.getByTestId('visibility-show-on-web-Toggle').click();
await card.getByTestId('visibility-show-on-email-Toggle').click();

await expect(card.getByTestId('visibility-message')).toContainText('Hidden from both email and web');
await expect(card.getByTestId('visibility-message')).toContainText('Hidden from both web and email');
});

test('can toggle visibility - subscriber settings hidden when stripe is not enabled', async function () {
test('can toggle visibility - member settings hidden when stripe is not enabled', async function () {
await initialize({page, uri: '/#/?content=false&labs=contentVisibility&stripe=false'});
const card = await insertHtmlCard();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ describe('useVisibilityToggle', () => {
expect(result.current[5]).toBe(node.visibility.showOnWeb); // webVisibility

expect(result.current[6]).toEqual([
{label: 'All subscribers', name: ''},
{label: 'Free subscribers', name: 'status:free'},
{label: 'Paid subscribers', name: 'status:-free'}
{label: 'All members', name: ''},
{label: 'Free members', name: 'status:free'},
{label: 'Paid members', name: 'status:-free'}
]); // dropdownOptions

expect(result.current[7]).toBe(''); // message
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('useVisibilityToggle', () => {

expect(result.current[3]).toBe('status:free'); // segment
expect(node.visibility.segment).toBe('status:free');
expect(result.current[7]).toBe('Shown on web, and to free subscribers only in email'); // message
expect(result.current[7]).toBe('Shown on web, and to free members only in email'); // message
});

it('should update the message correctly when both toggles are off', () => {
Expand All @@ -120,7 +120,7 @@ describe('useVisibilityToggle', () => {

expect(result.current[4]).toBe(false); // emailVisibility
expect(result.current[5]).toBe(false); // webVisibility
expect(result.current[7]).toBe('Hidden from both email and web'); // message
expect(result.current[7]).toBe('Hidden from both web and email'); // message
});

it('does not return dropdownOptions if stripe is not enabled', () => {
Expand Down

0 comments on commit d04cfd6

Please sign in to comment.