Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const pagination = page.getByRole('navigation')
const lastPageButton = rtl.getByLabelText(pagination, 'Last item')
rtl.fireEvent.click(lastPageButton)
_(MOCK_ADMINS)
.orderBy(['EmailAddress'])
.drop(
Math.floor(MOCK_ADMINS.length / AccountsTable.DEFAULT_PAGE_SIZE) *
AccountsTable.DEFAULT_PAGE_SIZE,
)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
// Order descending, go back to first page
rtl.fireEvent.click(emailAddressHeader)
const firstPageButton = rtl.getByLabelText(pagination, 'First item')
rtl.fireEvent.click(firstPageButton)
// Check that first page is correct
_(MOCK_ADMINS)
.orderBy(['EmailAddress'], ['desc'])
.take(AccountsTable.DEFAULT_PAGE_SIZE)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
})
// Check that last page is correct
const pagination = page.getByRole('navigation')
const lastPageButton = rtl.getByLabelText(pagination, 'Last item')
rtl.fireEvent.click(lastPageButton)
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'], ['asc'])
.drop(
Math.floor(NUM_MOCK_ACCOUNTS / AccountsTable.DEFAULT_PAGE_SIZE) *
AccountsTable.DEFAULT_PAGE_SIZE,
)
.forEach(({ EmailAddress }) => rtl.getByText(table, EmailAddress))
// Order descending, go back to first page
rtl.fireEvent.click(emailAddressHeader)
const firstPageButton = rtl.getByLabelText(pagination, 'First item')
rtl.fireEvent.click(firstPageButton)
// Check that first page is correct
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'], ['desc'])
.take(AccountsTable.DEFAULT_PAGE_SIZE)
.forEach(({ EmailAddress }) => rtl.getByText(table, EmailAddress))
})
await accountsTestUtils.waitForAccountsToLoad(page)
// Order ascending
const table = page.getByTestId('accountsTable')
const emailAddressHeader = rtl.getByText(table, 'Email address')
rtl.fireEvent.click(emailAddressHeader)
// Check that first page is correct
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'], ['asc'])
.take(AccountsTable.DEFAULT_PAGE_SIZE)
.forEach(({ EmailAddress }) => rtl.getByText(table, EmailAddress))
// Check that last page is correct
const pagination = page.getByRole('navigation')
const lastPageButton = rtl.getByLabelText(pagination, 'Last item')
rtl.fireEvent.click(lastPageButton)
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'], ['asc'])
.drop(
Math.floor(NUM_MOCK_ACCOUNTS / AccountsTable.DEFAULT_PAGE_SIZE) *
AccountsTable.DEFAULT_PAGE_SIZE,
)
.forEach(({ EmailAddress }) => rtl.getByText(table, EmailAddress))
// Order descending, go back to first page
rtl.fireEvent.click(emailAddressHeader)
const firstPageButton = rtl.getByLabelText(pagination, 'First item')
rtl.fireEvent.click(firstPageButton)
// Check that first page is correct
_(MOCK_ACCOUNTS)
const pagination = page.getByRole('navigation')
const lastPageButton = rtl.getByLabelText(pagination, 'Last item')
rtl.fireEvent.click(lastPageButton)
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'])
.drop(
Math.floor(MOCK_ACCOUNTS.length / AccountsTable.DEFAULT_PAGE_SIZE) *
AccountsTable.DEFAULT_PAGE_SIZE,
)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
// Order descending, go back to first page
rtl.fireEvent.click(emailAddressHeader)
const firstPageButton = rtl.getByLabelText(pagination, 'First item')
rtl.fireEvent.click(firstPageButton)
// Check that first page is correct
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'], ['desc'])
.take(AccountsTable.DEFAULT_PAGE_SIZE)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
})
const pagination = page.getByRole('navigation')
const lastPageButton = rtl.getByLabelText(pagination, 'Last item')
rtl.fireEvent.click(lastPageButton)
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'])
.drop(
Math.floor(MOCK_ACCOUNTS.length / AccountsTable.DEFAULT_PAGE_SIZE) *
AccountsTable.DEFAULT_PAGE_SIZE,
)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
// Order descending, go back to first page
rtl.fireEvent.click(emailAddressHeader)
const firstPageButton = rtl.getByLabelText(pagination, 'First item')
rtl.fireEvent.click(firstPageButton)
// Check that first page is correct
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'], ['desc'])
.take(AccountsTable.DEFAULT_PAGE_SIZE)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
})
// Order ascending
const table = page.getByTestId(AccountsTable.ACCOUNTS_TABLE_TESTID)
const emailAddressHeader = rtl.getByText(table, 'Email address')
rtl.fireEvent.click(emailAddressHeader)
// Check that first page is correct
_(MOCK_ADMINS)
.orderBy(['EmailAddress'])
.take(AccountsTable.DEFAULT_PAGE_SIZE)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
// Check that last page is correct
const pagination = page.getByRole('navigation')
const lastPageButton = rtl.getByLabelText(pagination, 'Last item')
rtl.fireEvent.click(lastPageButton)
_(MOCK_ADMINS)
.orderBy(['EmailAddress'])
.drop(
Math.floor(MOCK_ADMINS.length / AccountsTable.DEFAULT_PAGE_SIZE) *
AccountsTable.DEFAULT_PAGE_SIZE,
)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
// Order descending, go back to first page
rtl.fireEvent.click(emailAddressHeader)
const firstPageButton = rtl.getByLabelText(pagination, 'First item')
rtl.fireEvent.click(firstPageButton)
// Order ascending
const table = page.getByTestId(AccountsTable.ACCOUNTS_TABLE_TESTID)
const emailAddressHeader = rtl.getByText(table, 'Email address')
rtl.fireEvent.click(emailAddressHeader)
// Check that first page is correct
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'])
.take(AccountsTable.DEFAULT_PAGE_SIZE)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
// Check that last page is correct
const pagination = page.getByRole('navigation')
const lastPageButton = rtl.getByLabelText(pagination, 'Last item')
rtl.fireEvent.click(lastPageButton)
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'])
.drop(
Math.floor(MOCK_ACCOUNTS.length / AccountsTable.DEFAULT_PAGE_SIZE) *
AccountsTable.DEFAULT_PAGE_SIZE,
)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
// Order descending, go back to first page
rtl.fireEvent.click(emailAddressHeader)
const firstPageButton = rtl.getByLabelText(pagination, 'First item')
rtl.fireEvent.click(firstPageButton)
// Order ascending
const table = page.getByTestId(AccountsTable.ACCOUNTS_TABLE_TESTID)
const emailAddressHeader = rtl.getByText(table, 'Email address')
rtl.fireEvent.click(emailAddressHeader)
// Check that first page is correct
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'])
.take(AccountsTable.DEFAULT_PAGE_SIZE)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
// Check that last page is correct
const pagination = page.getByRole('navigation')
const lastPageButton = rtl.getByLabelText(pagination, 'Last item')
rtl.fireEvent.click(lastPageButton)
_(MOCK_ACCOUNTS)
.orderBy(['EmailAddress'])
.drop(
Math.floor(MOCK_ACCOUNTS.length / AccountsTable.DEFAULT_PAGE_SIZE) *
AccountsTable.DEFAULT_PAGE_SIZE,
)
.forEach(({ EmailAddress }) =>
accountsTestUtils.expectEmailIn(EmailAddress, table),
)
// Order descending, go back to first page
rtl.fireEvent.click(emailAddressHeader)
const firstPageButton = rtl.getByLabelText(pagination, 'First item')
rtl.fireEvent.click(firstPageButton)
function updateTextInput(
container: HTMLElement,
labelText: string,
value: string
) {
const headerImageInput = getByLabelText(
container,
labelText
) as HTMLInputElement;
fireEvent.change(headerImageInput, { target: { value } });
return headerImageInput;
}