Skip to content

Commit 9c6faae

Browse files
committed
cleanup and fix tests
1 parent 4d0b799 commit 9c6faae

File tree

5 files changed

+8
-88
lines changed

5 files changed

+8
-88
lines changed

packages/browser-sdk/FEEDBACK.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ new ReflagClient({
291291
"Dans quelle mesure êtes-vous satisfait de cette fonctionnalité ?",
292292
QuestionPlaceholder:
293293
"Comment pouvons-nous améliorer cette fonctionnalité ?",
294-
ScoreStatusDescription: "Choisissez une note et laissez un commentaire",
295294
ScoreStatusLoading: "Chargement...",
296295
ScoreStatusReceived: "La note a été reçue !",
297296
ScoreVeryDissatisfiedLabel: "Très insatisfait",

packages/browser-sdk/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"build": "tsc --project tsconfig.build.json && vite build",
1616
"test": "tsc --project tsconfig.json && vitest -c vitest.config.ts",
1717
"test:e2e": "yarn build && playwright test",
18+
"test:e2e-ui": "yarn build && playwright test --ui",
1819
"test:ci": "tsc --project tsconfig.json && vitest run -c vitest.config.ts --reporter=default --reporter=junit --outputFile=junit.xml && yarn test:e2e",
1920
"coverage": "vitest run --coverage",
2021
"lint": "eslint .",

packages/browser-sdk/src/feedback/ui/config/defaultTranslations.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { FeedbackTranslations } from "../types";
55
export const DEFAULT_TRANSLATIONS: FeedbackTranslations = {
66
DefaultQuestionLabel: "How satisfied are you with this feature?",
77
QuestionPlaceholder: "Write a comment",
8-
ScoreStatusDescription: "Pick a score and leave a comment",
98
ScoreStatusLoading: "Saving score, please wait...",
109
ScoreStatusReceived: "Score has been received!",
1110
ScoreVeryDissatisfiedLabel: "Very dissatisfied (1/5)",

packages/browser-sdk/src/feedback/ui/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export type FeedbackTranslations = {
4747
*/
4848
DefaultQuestionLabel: string;
4949
QuestionPlaceholder: string;
50-
ScoreStatusDescription: string;
5150
ScoreStatusLoading: string;
5251
ScoreStatusReceived: string;
5352
ScoreVeryDissatisfiedLabel: string;

packages/browser-sdk/test/e2e/feedback-widget.browser.spec.ts

Lines changed: 7 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ function pick<T>(options: T[]): T {
2525
return options[Math.floor(Math.random() * options.length)];
2626
}
2727

28+
const DEFAULT_TITLE = "baz";
29+
const DEFAULT_FLAG_KEY = "flag1";
30+
2831
async function getOpenedWidgetContainer(
2932
page: Page,
3033
initOptions: Omit<InitOptions, "publishableKey"> = {},
@@ -54,8 +57,8 @@ async function getOpenedWidgetContainer(
5457
const reflag = new ReflagClient({publishableKey: "${KEY}", user: {id: "foo"}, company: {id: "bar"}, ...${JSON.stringify(initOptions ?? {})}});
5558
await reflag.initialize();
5659
await reflag.requestFeedback({
57-
flagKey: "flag1",
58-
title: "baz",
60+
flagKey: "${DEFAULT_FLAG_KEY}",
61+
title: "${DEFAULT_TITLE}",
5962
...${JSON.stringify(feedbackOptions ?? {})},
6063
});
6164
})()
@@ -177,7 +180,7 @@ test("Opens a feedback widget in the bottom right by default", async ({
177180
const bbox = await container.locator("dialog").boundingBox();
178181
expect(bbox?.x).toEqual(WINDOW_WIDTH - bbox!.width - 16);
179182
expect(bbox?.y).toBeGreaterThan(WINDOW_HEIGHT - bbox!.height - 30); // Account for browser differences
180-
expect(bbox?.y).toBeLessThan(WINDOW_HEIGHT - bbox!.height);
183+
expect(bbox?.y).toBeLessThan(WINDOW_HEIGHT - bbox!.height + 10);
181184
});
182185

183186
test("Opens a feedback widget in the correct position when overridden", async ({
@@ -206,7 +209,6 @@ test("Opens a feedback widget with the correct translations", async ({
206209
page,
207210
}) => {
208211
const translations: Partial<FeedbackTranslations> = {
209-
ScoreStatusDescription: "Choisissez une note et laissez un commentaire",
210212
ScoreVeryDissatisfiedLabel: "Très insatisfait",
211213
ScoreDissatisfiedLabel: "Insatisfait",
212214
ScoreNeutralLabel: "Neutre",
@@ -224,7 +226,6 @@ test("Opens a feedback widget with the correct translations", async ({
224226
});
225227

226228
await expect(container).toBeAttached();
227-
await expect(container).toContainText(translations.ScoreStatusDescription!);
228229
await expect(container).toContainText(
229230
translations.ScoreVeryDissatisfiedLabel!,
230231
);
@@ -235,86 +236,6 @@ test("Opens a feedback widget with the correct translations", async ({
235236
await expect(container).toContainText(translations.SendButton!);
236237
});
237238

238-
test("Sends a request when choosing a score immediately", async ({ page }) => {
239-
const expectedScore = pick([1, 2, 3, 4, 5]);
240-
let sentJSON: object | null = null;
241-
242-
await page.route(`${API_HOST}/feedback`, async (route) => {
243-
sentJSON = route.request().postDataJSON();
244-
await route.fulfill({
245-
status: 200,
246-
body: JSON.stringify({ feedbackId: "123" }),
247-
contentType: "application/json",
248-
});
249-
});
250-
251-
const container = await getOpenedWidgetContainer(page);
252-
await setScore(container, expectedScore);
253-
254-
await expect
255-
.poll(() => sentJSON)
256-
.toEqual({
257-
companyId: "bar",
258-
key: "flag1",
259-
score: expectedScore,
260-
question: "baz",
261-
userId: "foo",
262-
source: "widget",
263-
});
264-
});
265-
266-
test("Shows a success message after submitting a score", async ({ page }) => {
267-
await page.route(`${API_HOST}/feedback`, async (route) => {
268-
await route.fulfill({
269-
status: 200,
270-
body: JSON.stringify({ feedbackId: "123" }),
271-
contentType: "application/json",
272-
});
273-
});
274-
275-
const container = await getOpenedWidgetContainer(page);
276-
277-
await expect(
278-
container.getByText(DEFAULT_TRANSLATIONS.ScoreStatusDescription),
279-
).toHaveCSS("opacity", "1");
280-
await expect(
281-
container.getByText(DEFAULT_TRANSLATIONS.ScoreStatusReceived),
282-
).toHaveCSS("opacity", "0");
283-
284-
await setScore(container, 3);
285-
286-
await expect(
287-
container.getByText(DEFAULT_TRANSLATIONS.ScoreStatusDescription),
288-
).toHaveCSS("opacity", "0");
289-
await expect(
290-
container.getByText(DEFAULT_TRANSLATIONS.ScoreStatusReceived),
291-
).toHaveCSS("opacity", "1");
292-
});
293-
294-
test("Shows the comment field after submitting a score", async ({ page }) => {
295-
await page.route(`${API_HOST}/feedback`, async (route) => {
296-
await route.fulfill({
297-
status: 200,
298-
body: JSON.stringify({ feedbackId: "123" }),
299-
contentType: "application/json",
300-
});
301-
});
302-
303-
const container = await getOpenedWidgetContainer(page);
304-
305-
await expect(container.locator(".form-expanded-content")).toHaveCSS(
306-
"opacity",
307-
"0",
308-
);
309-
310-
await setScore(container, 1);
311-
312-
await expect(container.locator(".form-expanded-content")).toHaveCSS(
313-
"opacity",
314-
"1",
315-
);
316-
});
317-
318239
test("Sends a request with both the score and comment when submitting", async ({
319240
page,
320241
}) => {
@@ -557,6 +478,7 @@ test("Submits feedback with score-only inputMode", async ({ page }) => {
557478
);
558479

559480
await setScore(container, expectedScore);
481+
await submitForm(container);
560482

561483
await expect
562484
.poll(() => sentJSON)

0 commit comments

Comments
 (0)