fix(test): use new st8 mgmt
This commit is contained in:
parent
75994c07a5
commit
a08ad8e2ee
3 changed files with 21 additions and 18 deletions
|
|
@ -476,13 +476,13 @@ describe('cp command parsing', function()
|
|||
|
||||
if num_args == 2 then
|
||||
local candidates = {}
|
||||
local cp_mod = require('cp')
|
||||
local context = cp_mod.get_current_context()
|
||||
if context.platform and context.contest_id then
|
||||
local state = require('cp.state')
|
||||
if state.get_platform() and state.get_contest_id() then
|
||||
vim.list_extend(candidates, actions)
|
||||
local cache = require('cp.cache')
|
||||
cache.load()
|
||||
local contest_data = cache.get_contest_data(context.platform, context.contest_id)
|
||||
local contest_data =
|
||||
cache.get_contest_data(state.get_platform(), state.get_contest_id())
|
||||
if contest_data and contest_data.problems then
|
||||
for _, problem in ipairs(contest_data.problems) do
|
||||
table.insert(candidates, problem.id)
|
||||
|
|
@ -525,9 +525,12 @@ describe('cp command parsing', function()
|
|||
return {}
|
||||
end
|
||||
|
||||
package.loaded['cp'] = {
|
||||
get_current_context = function()
|
||||
return { platform = nil, contest_id = nil }
|
||||
package.loaded['cp.state'] = {
|
||||
get_platform = function()
|
||||
return nil
|
||||
end,
|
||||
get_contest_id = function()
|
||||
return nil
|
||||
end,
|
||||
}
|
||||
|
||||
|
|
@ -596,9 +599,12 @@ describe('cp command parsing', function()
|
|||
end)
|
||||
|
||||
it('completes all actions and problems when contest context exists', function()
|
||||
package.loaded['cp'] = {
|
||||
get_current_context = function()
|
||||
return { platform = 'atcoder', contest_id = 'abc350' }
|
||||
package.loaded['cp.state'] = {
|
||||
get_platform = function()
|
||||
return 'atcoder'
|
||||
end,
|
||||
get_contest_id = function()
|
||||
return 'abc350'
|
||||
end,
|
||||
}
|
||||
package.loaded['cp.cache'] = {
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ describe('Error boundary handling', function()
|
|||
|
||||
after_each(function()
|
||||
package.loaded['cp.log'] = nil
|
||||
package.loaded['cp.scrape'] = nil
|
||||
package.loaded['cp.scraper'] = nil
|
||||
if state then
|
||||
state.reset()
|
||||
end
|
||||
|
|
@ -127,7 +127,6 @@ describe('Error boundary handling', function()
|
|||
it('should handle scraping failures without state corruption', function()
|
||||
cp.handle_command({ fargs = { 'codeforces', 'fail_scrape', 'a' } })
|
||||
|
||||
-- Wait for async callback to complete
|
||||
vim.wait(100)
|
||||
|
||||
local has_metadata_error = false
|
||||
|
|
@ -139,8 +138,7 @@ describe('Error boundary handling', function()
|
|||
end
|
||||
assert.is_true(has_metadata_error, 'Should log contest metadata failure')
|
||||
|
||||
local context = cp.get_current_context()
|
||||
assert.equals('codeforces', context.platform)
|
||||
assert.equals('codeforces', state.get_platform())
|
||||
|
||||
assert.has_no_errors(function()
|
||||
cp.handle_command({ fargs = { 'run' } })
|
||||
|
|
|
|||
|
|
@ -51,10 +51,9 @@ describe('Panel integration', function()
|
|||
it('should handle run command with properly set contest context', function()
|
||||
cp.handle_command({ fargs = { 'codeforces', '2146', 'b' } })
|
||||
|
||||
local context = cp.get_current_context()
|
||||
assert.equals('codeforces', context.platform)
|
||||
assert.equals('2146', context.contest_id)
|
||||
assert.equals('b', context.problem_id)
|
||||
assert.equals('codeforces', state.get_platform())
|
||||
assert.equals('2146', state.get_contest_id())
|
||||
assert.equals('b', state.get_problem_id())
|
||||
|
||||
assert.has_no_errors(function()
|
||||
cp.handle_command({ fargs = { 'run' } })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue