Skip to content

Commit 21e7064

Browse files
committed
Prevent race conditions in login test
1 parent adfa1f9 commit 21e7064

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

gui/test/e2e/installed/state-dependent/login.spec.ts

+15-16
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ test('App should create account', async () => {
4949
const title = page.locator('h1')
5050
const subtitle = page.getByTestId('subtitle');
5151

52-
await page.getByText('Create account').click();
52+
expect(await util.waitForNavigation(async () => {
53+
await page.getByText('Create account').click();
5354

54-
await expect(title).toHaveText('Account created');
55-
await expect(subtitle).toHaveText('Logged in');
56-
57-
expect(await util.waitForNavigation()).toEqual(RoutePath.expired);
55+
await expect(title).toHaveText('Account created');
56+
await expect(subtitle).toHaveText('Logged in');
57+
})).toEqual(RoutePath.expired);
5858

5959
const outOfTimeTitle = page.getByTestId('title');
6060
await expect(outOfTimeTitle).toHaveText('Congrats!');
@@ -80,13 +80,14 @@ test('App should log in', async () => {
8080
await expect(title).toHaveText('Login');
8181
await expect(subtitle).toHaveText('Enter your account number');
8282

83-
await loginInput.type(process.env.ACCOUNT_NUMBER!);
84-
await loginInput.press('Enter');
83+
await loginInput.fill(process.env.ACCOUNT_NUMBER!);
8584

86-
await expect(title).toHaveText('Logged in');
87-
await expect(subtitle).toHaveText('Valid account number');
85+
expect(await util.waitForNavigation(async () => {
86+
await loginInput.press('Enter');
8887

89-
expect(await util.waitForNavigation()).toEqual(RoutePath.main);
88+
await expect(title).toHaveText('Logged in');
89+
await expect(subtitle).toHaveText('Valid account number');
90+
})).toEqual(RoutePath.main);
9091
await expectDisconnected(page);
9192
});
9293

@@ -115,13 +116,11 @@ test('App should log in to expired account', async () => {
115116
await expect(title).toHaveText('Login');
116117
await expect(subtitle).toHaveText('Enter your account number');
117118

118-
await loginInput.type(accountNumber);
119-
await loginInput.press('Enter');
120-
121-
await expect(title).toHaveText('Logged in');
122-
await expect(subtitle).toHaveText('Valid account number');
119+
await loginInput.fill(accountNumber);
123120

124-
expect(await util.waitForNavigation()).toEqual(RoutePath.expired);
121+
expect(await util.waitForNavigation(async () => {
122+
await loginInput.press('Enter');
123+
})).toEqual(RoutePath.expired);
125124

126125
const outOfTimeTitle = page.getByTestId('title');
127126
await expect(outOfTimeTitle).toHaveText('Out of time');

0 commit comments

Comments
 (0)