mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Migrate from flow to typescript
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/// <reference types="cypress" />
|
||||
describe('/dev/applications - guest', () => {
|
||||
it('should render login button', () => {
|
||||
cy.visit('/dev/applications');
|
@@ -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)));
|
@@ -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;
|
||||
}),
|
||||
),
|
@@ -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')
|
Reference in New Issue
Block a user