Skip to content

Commit 8372f71

Browse files
committed
cleanup test codes
1 parent fe7779e commit 8372f71

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/renderer/screens/Explorer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ const Explorer = () => {
141141
<Grid item xs={12}>
142142
<Paper css={paperSm}>
143143
<div
144+
data-testid="uiFileOpen"
144145
{...getRootProps({
145-
id: 'uiFileOpen',
146146
css: css`
147147
cursor: pointer;
148148
user-select: none;

tests/app.spec.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@ import { test, expect } from '@playwright/test';
55
let appWindow: Page;
66
let appElectron: ElectronApplication;
77

8-
function waiting(milliseconds: number) {
9-
return new Promise((resolve) => {
10-
setTimeout(() => resolve(true), milliseconds);
11-
});
12-
}
13-
14-
function isElementVisible(selector: string, waitingMilliseconds = 300) {
8+
function existElementByTestId(selector: string, waitingMilliseconds = 100) {
159
return new Promise((resolve) => {
1610
setTimeout(async () => {
17-
expect(await appWindow.isVisible(selector), `Confirm selector '${selector}' is visible`).toBe(
18-
true,
19-
);
11+
await expect(
12+
appWindow.getByTestId(selector).first(),
13+
`Confirm selector '${selector}' is visible`,
14+
).toBeVisible();
2015
resolve(true);
2116
}, waitingMilliseconds);
2217
});
@@ -40,10 +35,10 @@ test('Environment check', async () => {
4035
});
4136

4237
test('Document element check', async () => {
43-
await isElementVisible('#uiFileOpen');
38+
await existElementByTestId('uiFileOpen');
4439
});
4540

4641
test.afterAll(async () => {
47-
await waiting(2000);
42+
await appWindow.waitForTimeout(2000);
4843
await appElectron.close();
4944
});

0 commit comments

Comments
 (0)