Download spectrum/cypress/integration/toasts_spec.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.3 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/cypress/integration/toasts_spec.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/cypress/integration/toasts_spec.js
-
curl -L -o toasts_spec.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/cypress/integration/toasts_spec.js
2.3 kB
| import data from '../../shared/testing/data'; | |
| const user = data.users[0]; | |
| const toastMessage = 'This is a long toast message'; | |
| describe('Toasts and url query paramaters', () => { | |
| beforeEach(() => { | |
| cy.auth(user.id); | |
| }); | |
| it('should show toast', () => { | |
| const url = new URL('http://localhost:3000/me/settings'); | |
| url.searchParams.append('toastType', 'success'); | |
| url.searchParams.append('toastMessage', toastMessage); | |
| cy.visit(url.toString()); | |
| cy.get('[data-cy="toast-success"]').contains(toastMessage); | |
| cy.url().should('eq', 'http://localhost:3000/users/mxstbr/settings'); | |
| }); | |
| it('should not show toast if no toastType', () => { | |
| const url = new URL('http://localhost:3000/me/settings'); | |
| url.searchParams.append('toastMessage', toastMessage); | |
| cy.visit(url.toString()); | |
| cy.get('[data-cy="toast-success"]').should('have.length', 0); | |
| cy.url().should('eq', 'http://localhost:3000/users/mxstbr/settings'); | |
| }); | |
| it('should not show toast if no toastMessage', () => { | |
| const url = new URL('http://localhost:3000/me/settings'); | |
| url.searchParams.append('toastType', 'success'); | |
| cy.visit(url.toString()); | |
| cy.get('[data-cy="toast-success"]', { timeout: 1 }).should( | |
| 'have.length', | |
| 0 | |
| ); | |
| cy.url().should('eq', 'http://localhost:3000/users/mxstbr/settings'); | |
| }); | |
| it('should not show toast if invalid toastType', () => { | |
| const url = new URL('http://localhost:3000/me/settings'); | |
| url.searchParams.append('toastType', 'foo'); | |
| cy.visit(url.toString()); | |
| cy.get('[data-cy="toast-success"]', { timeout: 1 }).should( | |
| 'have.length', | |
| 0 | |
| ); | |
| cy.url().should('eq', 'http://localhost:3000/users/mxstbr/settings'); | |
| }); | |
| it('should preserve existing query parameters', () => { | |
| const url = new URL( | |
| 'http://localhost:3000/spectrum/general/another-thread~thread-2?m=MTQ4MzIyNTIwMDAwMg==' | |
| ); | |
| url.searchParams.append('toastType', 'success'); | |
| url.searchParams.append('toastMessage', toastMessage); | |
| cy.visit(url.toString()); | |
| cy.get('[data-cy="toast-success"]', { timeout: 100 }).should( | |
| 'have.length', | |
| 1 | |
| ); | |
| cy.url().should( | |
| 'eq', | |
| 'http://localhost:3000/spectrum/general/another-thread~thread-2?m=MTQ4MzIyNTIwMDAwMg==' | |
| ); | |
| }); | |
| }); | |