Skip to content

Commit

Permalink
Adapt to API random code change
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentTreguier committed Aug 26, 2024
1 parent caf6e1c commit 8d7d98c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib/data/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"identifier": "Identifier",
"identifier-placeholder": "Username or email",
"randomCode": "One-time code",
"randomCode-placeholder": "123456",
"randomCode-placeholder": "abcd1234",
"help": {
"randomCode": "A one-time use code has been sent to your email address."
},
Expand Down
4 changes: 2 additions & 2 deletions src/lib/openapi/fakes/tokens-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { fail } from './utils';
export default class FakeTokensEndpointApi implements TokensEndpointApiInterface {
static readonly badIdentifier = 'bad-identifier';
static readonly goodIdentifier = 'good-identifier';
static readonly badSecret = '000000';
static readonly goodSecret = '123456';
static readonly badSecret = 'nopenope';
static readonly goodSecret = 'abcd1234';
static readonly badToken = 'bad-token';
static readonly goodToken = 'good-token';

Expand Down
2 changes: 1 addition & 1 deletion src/routes/login/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[identifier, randomCode, isWaitingForRandomCode],
([$identifier, $randomCode, $isWaitingForRandomCode]) =>
$isWaitingForRandomCode
? $randomCode.length === 6
? $randomCode.length >= 8
: $identifier.length >= 3 && $identifier.length <= 254
);
Expand Down
7 changes: 2 additions & 5 deletions src/routes/login/page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,13 @@ test('Random code must have correct length', async () => {
await sleep(100);
const randomCode = screen.getByRole('textbox', { name: 'One-time code' });

await user.type(randomCode, '12345');
await user.type(randomCode, 'abcd123');
expect(submit).to.have.property('disabled', true);
await user.clear(randomCode);

await user.type(randomCode, '123456');
await user.type(randomCode, 'abcd1234');
expect(submit).to.have.property('disabled', false);
await user.clear(randomCode);

await user.type(randomCode, '1234567');
expect(submit).to.have.property('disabled', true);
});

test('Invalid random code produces an error', async () => {
Expand Down

0 comments on commit 8d7d98c

Please sign in to comment.