Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 1d68c32

Browse files
committed
chore: test cases and design fix
1 parent 05cc84e commit 1d68c32

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/features/dashboard/components/ApiTokenForm/__tests__/api-token.form.test.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { cleanup, render, screen, within } from '@site/src/test-utils';
2+
import { cleanup, render, screen, waitFor, within } from '@site/src/test-utils';
33
import userEvent from '@testing-library/user-event';
44
import ApiTokenForm from '../api-token.form';
55
import useCreateToken from '../../../hooks/useCreateToken';
@@ -134,6 +134,13 @@ describe('Home Page', () => {
134134
expect(adminCheckbox.checked).toBeTruthy();
135135
});
136136

137+
it('Should show dynamic token label', async () => {
138+
const tokenLabel = screen.getByTestId('token-count-label');
139+
await waitFor(() => {
140+
expect(tokenLabel).toBeVisible();
141+
});
142+
});
143+
137144
it('Should create token on form submit', async () => {
138145
const nameInput = screen.getByRole('textbox');
139146

@@ -155,6 +162,20 @@ describe('Home Page', () => {
155162
expect(error).toBeVisible;
156163
});
157164

165+
it('Should update token a value on create token', async () => {
166+
const tokenLabel = screen.getByTestId('token-count-label');
167+
const nameInput = screen.getByRole('textbox');
168+
169+
await userEvent.type(nameInput, 'test create token');
170+
171+
const submitButton = screen.getByRole('button', { name: /Create/i });
172+
await userEvent.click(submitButton);
173+
174+
await waitFor(() => {
175+
expect(tokenLabel).toHaveTextContent('2');
176+
});
177+
});
178+
158179
it('should hide restrictions if error is present', async () => {
159180
const nameInput = screen.getByRole('textbox');
160181
const restrictions = screen.getByRole('list');

src/features/dashboard/components/ApiTokenForm/api-token.form.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ form {
9696
color: var(--ifm-color-emphasis-1000);
9797
height: rem(4);
9898
min-width: 0;
99+
width: 100%;
99100
border: none;
100101
text-indent: rem(1.2);
101102
font-size: rem(1.6);

0 commit comments

Comments
 (0)