Skip to content

Commit be0527d

Browse files
committed
After review 1
1 parent c107198 commit be0527d

6 files changed

Lines changed: 29 additions & 23 deletions

File tree

assets/vue/components/subscribers/SubscriberDirectory.spec.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,31 @@ const ListSubscribersExportPanelStub = {
5050
}
5151

5252
describe('SubscriberDirectory', () => {
53-
const subscribers = [
53+
const createSubscribers = () => ([
5454
{
5555
id: 1,
5656
email: 'john@example.com',
5757
confirmed: true,
5858
blacklisted: false,
5959
listCount: 2,
6060
},
61-
]
61+
])
6262

63-
const pagination = {
63+
const createPagination = () => ({
6464
total: 1,
6565
isFirstPage: true,
6666
hasMore: false,
6767
afterId: null,
6868
prevId: null,
69-
}
69+
})
70+
7071

7172
const createWrapper = () =>
7273
mount(SubscriberDirectory, {
7374
global: {
7475
provide: {
75-
subscribers,
76-
pagination,
76+
subscribers: createSubscribers(),
77+
pagination: createPagination(),
7778
},
7879
stubs: {
7980
BaseIcon: BaseIconStub,
@@ -114,7 +115,7 @@ describe('SubscriberDirectory', () => {
114115
const table = wrapper.findComponent(SubscriberTableStub)
115116

116117
expect(table.props('subscribers')).toEqual(
117-
subscribers
118+
createSubscribers()
118119
)
119120
})
120121

@@ -192,9 +193,9 @@ describe('SubscriberDirectory', () => {
192193
backendFetch.mockResolvedValue({
193194
json: () =>
194195
Promise.resolve({
195-
items: subscribers,
196+
items: createSubscribers(),
196197
pagination: {
197-
...pagination,
198+
...createPagination(),
198199
hasMore: true,
199200
afterId: 10,
200201
},

assets/vue/components/subscribers/SubscriberFilters.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SubscriberFilters.spec.js
2-
32
import { describe, it, expect } from 'vitest'
43
import { mount } from '@vue/test-utils'
54
import SubscriberFilters from './SubscriberFilters.vue'
@@ -121,7 +120,7 @@ describe('SubscriberFilters', () => {
121120

122121
const buttons = wrapper.findAll('button')
123122

124-
if (buttons.length < 2) return
123+
expect(buttons.length).toBeGreaterThan(2)
125124

126125
await buttons[1].trigger('click')
127126
await buttons[2].trigger('click')
@@ -143,7 +142,7 @@ describe('SubscriberFilters', () => {
143142

144143
const buttons = wrapper.findAll('button')
145144

146-
if (buttons.length < 2) return
145+
expect(buttons.length).toBeGreaterThan(2)
147146

148147
await buttons[1].trigger('click')
149148

assets/vue/components/subscribers/SubscriberTable.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const BaseIconStub = {
1111
}
1212

1313
describe('SubscriberTable', () => {
14-
const subscribers = [
14+
const createSubscribers = () => ([
1515
{
1616
id: 1,
1717
email: 'john@example.com',
@@ -28,12 +28,12 @@ describe('SubscriberTable', () => {
2828
listCount: 1,
2929
createdAt: '2025-01-02',
3030
},
31-
]
31+
])
3232

3333
const createWrapper = (props = {}) =>
3434
mount(SubscriberTable, {
3535
props: {
36-
subscribers,
36+
subscribers: createSubscribers(),
3737
...props,
3838
},
3939
global: {

assets/vue/components/templates/TemplateLibrary.spec.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// TemplateLibrary.spec.js
22

3-
import { describe, it, expect, beforeEach, vi } from 'vitest'
3+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
44
import { mount, flushPromises } from '@vue/test-utils'
55
import TemplateLibrary from './TemplateLibrary.vue'
66
import { templateClient } from '../../api'
@@ -28,6 +28,7 @@ const BaseIconStub = {
2828
}
2929

3030
describe('TemplateLibrary', () => {
31+
const originalConfirm = window.confirm
3132
beforeEach(() => {
3233
vi.clearAllMocks()
3334
window.confirm = vi.fn()
@@ -37,6 +38,10 @@ describe('TemplateLibrary', () => {
3738
})
3839
})
3940

41+
afterEach(() => {
42+
window.confirm = originalConfirm
43+
})
44+
4045
const createWrapper = () =>
4146
mount(TemplateLibrary, {
4247
global: {

src/Service/PhpListTranslationLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ private function mapLocaleToPhpListFile(string $locale): string
7171
$baseLocale = strtok($normalized, '_') ?: 'en';
7272

7373
$map = [
74-
'en' => 'english.php',
75-
'es' => 'spanish.php',
76-
'fr' => 'french.php',
74+
'en' => 'english.inc',
75+
'es' => 'spanish.inc',
76+
'fr' => 'french.inc',
7777
];
7878

7979
return $map[$baseLocale] ?? 'english.php';

tests/Integration/Controller/PublicSubscribeControllerPantherTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,17 @@ public function testSubscribePageDisplaysEmailFieldAndSubmitButton(): void
7272
]);
7373
$client->request('GET', '/index.php/subscribe/1');
7474

75+
$client->takeScreenshot('var/screenshots/public-subscribe-0.png');
7576
$client->waitFor('form.legacy-form', 10);
76-
$client->takeScreenshot('var/screenshots/public-subscribe.png');
77+
$client->takeScreenshot('var/screenshots/public-subscribe-1.png');
7778

7879
$currentPath = (string) parse_url($client->getCurrentURL(), PHP_URL_PATH);
7980

8081
$this->assertSame('/index.php/subscribe/1', $currentPath);
8182
$this->assertNotSame('/login', $currentPath);
82-
$this->assertSelectorExists('form.legacy-form');
83-
$this->assertSelectorExists('input#email[name="email"][type="email"]');
84-
$this->assertSelectorExists('button[type="submit"].legacy-button');
83+
$this->assertSelectorExists('form');
84+
$this->assertSelectorExists('input[name="email"][type="email"]');
85+
$this->assertSelectorExists('button[type="submit"]');
8586
}
8687

8788
/**

0 commit comments

Comments
 (0)