// Copyright (c) Mito
// Distributed under the terms of the Modified BSD License.

/*
    Contains tests for basic, single sheet mito rendering, column additions,
    and column editing.
*/


import {
    addColumnButton,
    setFormula
} from './utils/columnHelpers';

import { 
    createNotebookRunCell,
    deleteAllNotebooks,
} from './utils/helpers';

import { checkGeneratedCode } from './utils/generatedCodeHelpers';


fixture `Test Transpiled Code`
    .page `http://staging.trymito.io`
    .beforeEach( async t => {
        await createNotebookRunCell(t, true, "import pandas as pd\nimport mitosheet\ndf1 = pd.DataFrame(data={'String': ['123', '1', '2', '3', '4', '5'], 'Number': [123, 1, 2, 3, 4, 5],'Date': ['2001-01-01', '2002-01-01', '2003-01-01','2004-01-01', '2005-01-01', '2006-01-01'],'Mixed': [123, '1', '2', '3', 4, 5]})\nmitosheet.sheet(df1)");
    })
    .afterEach(async t => {
        // Delete notebook, at the end of the test
        await deleteAllNotebooks(t)
    })


    test('Test run generated code', async t => {

        // Create a new column and set it equal to the String column
        await t.click(addColumnButton)
        await setFormula(t, '=String', 'E', '0')

        const expectedDf = {
            'String': ['123', '1', '2', '3', '4', '5'],
            'Number': ['123', '1', '2', '3', '4', '5'],
            'Date': ['2001-01-01', '2002-01-01', '2003-01-01','2004-01-01', '2005-01-01', '2006-01-01'],
            'Mixed': ['123', '1', '2', '3', '4', '5'],
            'E': ['123', '1', '2', '3', '4', '5']
        }

        // Run the generated code
        await checkGeneratedCode(t, 'df1', expectedDf)
    });
           