Migrate from flow to typescript

This commit is contained in:
SleepWalker
2019-12-07 13:28:52 +02:00
parent 85a535430e
commit d8d2df0702
267 changed files with 2806 additions and 3535 deletions

View File

@@ -1,3 +1,4 @@
/// <reference types="cypress" />
describe('/dev/applications - guest', () => {
it('should render login button', () => {
cy.visit('/dev/applications');

View File

@@ -1,10 +1,12 @@
/// <reference types="cypress" />
describe('/dev/applications - user', () => {
before(() => {
cy.login({ account: 'default' }).then(({ user }) => {
cy.visit('/dev/applications');
// remove all previousely added apps
cy.window().then(async ({ oauthApi }) => {
cy.window().then(async (/** @type {any} */ { oauthApi }) => {
const apps = await oauthApi.getAppsByUser(user.id);
await Promise.all(apps.map(app => oauthApi.delete(app.clientId)));

View File

@@ -1,3 +1,5 @@
/// <reference types="cypress" />
// account1 - authenticated
// account2 - invalid refreshToken
import { account1, account2 } from '../fixtures/accounts.json';
@@ -23,9 +25,13 @@ describe("when user's token and refreshToken are invalid", () => {
.then(resp => resp.json())
.then(resp => {
const account = multiAccount.accounts.available.find(
account => account.username === account1.username,
item => item.username === account1.username,
);
if (!account) {
throw new Error('Can not find an account');
}
account.token = resp.access_token;
}),
),

View File

@@ -1,3 +1,4 @@
/// <reference types="cypress" />
import { account1 } from '../fixtures/accounts.json';
describe('sign in', () => {
@@ -17,10 +18,10 @@ describe('sign in', () => {
cy.get('[data-e2e-toolbar]')
.contains(account1.username)
.should(() => {
const state = JSON.parse(localStorage.getItem('redux-storage'));
const state = JSON.parse(localStorage.getItem('redux-storage') || '');
expect(state.accounts.available).to.have.length(1);
const account = state.accounts.available[0];
const [account] = state.accounts.available;
expect(account.username).to.be.equal(account1.username);
expect(account.id)
.to.be.a('number')