-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
4,043 additions
and
2,971 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
/** | ||
* Types are not supported for `@cypress/code-coverage` | ||
* | ||
* @see https://github.com/cypress-io/code-coverage/issues/257 | ||
*/ | ||
declare module '@cypress/code-coverage/task' { | ||
export default function registerCodeCoverageTasks( | ||
on: Cypress.PluginEvents, | ||
config: Cypress.PluginConfigOptions, | ||
): void; | ||
} | ||
/** | ||
* Types are not supported for `@cypress/code-coverage` | ||
* | ||
* @see https://github.com/cypress-io/code-coverage/issues/257 | ||
*/ | ||
declare module '@cypress/code-coverage/task' { | ||
export default function registerCodeCoverageTasks( | ||
on: Cypress.PluginEvents, | ||
config: Cypress.PluginConfigOptions, | ||
): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import { mount } from 'cypress/vue'; | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace Cypress { | ||
interface Chainable { | ||
/** | ||
* Helper mount function for Vue Components | ||
* @param component Vue Component or JSX Element to mount | ||
* @param options Options passed to Vue Test Utils | ||
*/ | ||
mount: typeof mount; | ||
} | ||
} | ||
} | ||
|
||
export function registerMount() { | ||
Cypress.Commands.add('mount', mount); | ||
} | ||
import { mount } from 'cypress/vue'; | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace Cypress { | ||
interface Chainable { | ||
/** | ||
* Helper mount function for Vue Components | ||
* @param component Vue Component or JSX Element to mount | ||
* @param options Options passed to Vue Test Utils | ||
*/ | ||
mount: typeof mount; | ||
} | ||
} | ||
} | ||
|
||
export function registerMount() { | ||
Cypress.Commands.add('mount', mount); | ||
} |
124 changes: 62 additions & 62 deletions
124
packages/e2e-cypress/src/helpers/commands/select-date.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace Cypress { | ||
interface Chainable { | ||
/** | ||
* Selects a given date into a QDate. | ||
* @example cy.get('.q-date').selectDate('11/02/2021') | ||
* @example cy.dataCy('start-date').selectDate(new Date()) | ||
*/ | ||
selectDate<E extends HTMLElement = HTMLElement>( | ||
value: string | Date, | ||
): Chainable<JQueryWithSelector<E>>; | ||
} | ||
} | ||
} | ||
|
||
export function registerSelectDate() { | ||
Cypress.Commands.add( | ||
'selectDate', | ||
{ prevSubject: 'element' }, | ||
(subject, value) => { | ||
if (!subject.hasClass('q-date')) { | ||
throw new Error('Subject is not a QDate'); | ||
} | ||
|
||
const targetDate = typeof value === 'string' ? new Date(value) : value; | ||
|
||
cy.wrap(subject).within(() => { | ||
cy.get('.q-date__navigation div:not(.q-date__arrow)') | ||
.last() | ||
.as('yearSelector'); | ||
cy.get('.q-date__navigation div:not(.q-date__arrow)') | ||
.first() | ||
.as('monthSelector'); | ||
|
||
const targetYear = targetDate.getFullYear(); | ||
const targetMonth = targetDate.getMonth(); | ||
const targetDay = targetDate.getDate(); | ||
|
||
// Since it's easy to detect it with the year selector, | ||
// we avoid selecting the year if it's already the target one | ||
cy.get('@yearSelector') | ||
.invoke('text') | ||
.then((currentYear) => { | ||
if (currentYear !== targetYear.toString()) { | ||
cy.get('@yearSelector').click(); | ||
cy.contains(targetYear).click(); | ||
} | ||
}); | ||
|
||
cy.get('@monthSelector').click(); | ||
cy.get('.q-date__months-item').eq(targetMonth).click(); | ||
|
||
// The target day number is searched only into days buttons, | ||
// skipping filler and out of range days | ||
cy.get('.q-date__calendar-item--in').contains(targetDay).click(); | ||
}); | ||
|
||
return cy.wrap(subject); | ||
}, | ||
); | ||
} | ||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
namespace Cypress { | ||
interface Chainable { | ||
/** | ||
* Selects a given date into a QDate. | ||
* @example cy.get('.q-date').selectDate('11/02/2021') | ||
* @example cy.dataCy('start-date').selectDate(new Date()) | ||
*/ | ||
selectDate<E extends HTMLElement = HTMLElement>( | ||
value: string | Date, | ||
): Chainable<JQueryWithSelector<E>>; | ||
} | ||
} | ||
} | ||
|
||
export function registerSelectDate() { | ||
Cypress.Commands.add( | ||
'selectDate', | ||
{ prevSubject: 'element' }, | ||
(subject, value) => { | ||
if (!subject.hasClass('q-date')) { | ||
throw new Error('Subject is not a QDate'); | ||
} | ||
|
||
const targetDate = typeof value === 'string' ? new Date(value) : value; | ||
|
||
cy.wrap(subject).within(() => { | ||
cy.get('.q-date__navigation div:not(.q-date__arrow)') | ||
.last() | ||
.as('yearSelector'); | ||
cy.get('.q-date__navigation div:not(.q-date__arrow)') | ||
.first() | ||
.as('monthSelector'); | ||
|
||
const targetYear = targetDate.getFullYear(); | ||
const targetMonth = targetDate.getMonth(); | ||
const targetDay = targetDate.getDate(); | ||
|
||
// Since it's easy to detect it with the year selector, | ||
// we avoid selecting the year if it's already the target one | ||
cy.get('@yearSelector') | ||
.invoke('text') | ||
.then((currentYear) => { | ||
if (currentYear !== targetYear.toString()) { | ||
cy.get('@yearSelector').click(); | ||
cy.contains(targetYear).click(); | ||
} | ||
}); | ||
|
||
cy.get('@monthSelector').click(); | ||
cy.get('.q-date__months-item').eq(targetMonth).click(); | ||
|
||
// The target day number is searched only into days buttons, | ||
// skipping filler and out of range days | ||
cy.get('.q-date__calendar-item--in').contains(targetDay).click(); | ||
}); | ||
|
||
return cy.wrap(subject); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import { Ref, watch } from 'vue'; | ||
|
||
// VTU won't accept reactive v-model binding, this adapter manually | ||
// set the model prop each time a new value is emitted | ||
// See https://github.com/vuejs/test-utils/discussions/279 | ||
|
||
// See https://github.com/vuejs/test-utils/issues/871 | ||
export function vModelAdapter<T>( | ||
modelRef: Ref<T>, | ||
modelName = 'modelValue', | ||
// Without this, TS will start complaining as it cannot understand the dynamic type of | ||
// the returned object and match it with the component props this helper is applied to. | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
): any { | ||
watch(modelRef, (value) => | ||
Cypress.vueWrapper.setProps({ [modelName]: value }), | ||
); | ||
|
||
return { | ||
[modelName]: modelRef.value, | ||
[`onUpdate:${modelName}`]: (emittedValue: T) => { | ||
modelRef.value = emittedValue; | ||
}, | ||
}; | ||
} | ||
import { Ref, watch } from 'vue'; | ||
|
||
// VTU won't accept reactive v-model binding, this adapter manually | ||
// set the model prop each time a new value is emitted | ||
// See https://github.com/vuejs/test-utils/discussions/279 | ||
|
||
// See https://github.com/vuejs/test-utils/issues/871 | ||
export function vModelAdapter<T>( | ||
modelRef: Ref<T>, | ||
modelName = 'modelValue', | ||
// Without this, TS will start complaining as it cannot understand the dynamic type of | ||
// the returned object and match it with the component props this helper is applied to. | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
): any { | ||
watch(modelRef, (value) => | ||
Cypress.vueWrapper.setProps({ [modelName]: value }), | ||
); | ||
|
||
return { | ||
[modelName]: modelRef.value, | ||
[`onUpdate:${modelName}`]: (emittedValue: T) => { | ||
modelRef.value = emittedValue; | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
// This module provide typings to the deep import, since the original file isn't written in TS | ||
// This should be a .ts file (instead of a .d.ts) to not being elided at compile time by TS, | ||
// which would make it useless | ||
declare module '@quasar/quasar-app-extension-testing-unit-jest/jest-preset.mjs' { | ||
import { Config } from 'jest'; | ||
|
||
export const quasarEsModulesPackageNames: string; | ||
export const config: Config; | ||
export default Config; | ||
} | ||
// This module provide typings to the deep import, since the original file isn't written in TS | ||
// This should be a .ts file (instead of a .d.ts) to not being elided at compile time by TS, | ||
// which would make it useless | ||
declare module '@quasar/quasar-app-extension-testing-unit-jest/jest-preset.mjs' { | ||
import { Config } from 'jest'; | ||
|
||
export const quasarEsModulesPackageNames: string; | ||
export const config: Config; | ||
export default Config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.